-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add dropdown filter to show rooms, languages, session types. Ensure it works in mobile view #228
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<template> | ||
<div v-on-clickaway="away" :class="elClass"> | ||
Check warning on line 2 in webapp/src/components/AppDropdown.vue GitHub Actions / build
|
||
<bunt-button @click="toggle"> | ||
<slot name="toggler"> Toggle </slot> | ||
Check warning on line 4 in webapp/src/components/AppDropdown.vue GitHub Actions / build
Check warning on line 4 in webapp/src/components/AppDropdown.vue GitHub Actions / build
|
||
<svg | ||
v-if="this.sharedState.active" | ||
Check warning on line 6 in webapp/src/components/AppDropdown.vue GitHub Actions / build
|
||
xmlns="http://www.w3.org/2000/svg" | ||
width="1em" | ||
height="1em" | ||
viewBox="0 0 24 24" | ||
> | ||
<path fill="currentColor" d="m7 15l5-5l5 5z" /> | ||
</svg> | ||
<svg | ||
v-else | ||
xmlns="http://www.w3.org/2000/svg" | ||
width="1em" | ||
height="1em" | ||
viewBox="0 0 24 24" | ||
> | ||
<path fill="currentColor" d="m7 10l5 5l5-5z" /> | ||
</svg> | ||
</bunt-button> | ||
<slot /> | ||
</div> | ||
</template> | ||
<script> | ||
import { computed } from 'vue'; | ||
Check failure on line 28 in webapp/src/components/AppDropdown.vue GitHub Actions / build
Check failure on line 28 in webapp/src/components/AppDropdown.vue GitHub Actions / build
|
||
import { mixin as clickaway } from 'vue-clickaway' | ||
|
||
export default { | ||
name: 'AppDropdown', | ||
mixins: [clickaway], | ||
props: { | ||
className: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
provide () { | ||
return { | ||
sharedState: this.sharedState | ||
} | ||
}, | ||
data () { | ||
return { | ||
sharedState: { | ||
active: false, | ||
}, | ||
} | ||
}, | ||
methods: { | ||
toggle () { | ||
this.sharedState.active = !this.sharedState.active | ||
}, | ||
away () { | ||
this.sharedState.active = false | ||
} | ||
}, | ||
computed: { | ||
elClass () { | ||
return this.className ? this.className + " app-drop-down" : 'app-drop-down' | ||
}, | ||
} | ||
} | ||
</script> | ||
<style> | ||
.app-drop-down { | ||
margin: 12px 4px 12px 14px; | ||
border-radius: 5px; | ||
border: 2px solid rgba(0, 0, 0, 0.38); | ||
} | ||
|
||
.app-drop-down .bunt-button { | ||
background-color: white; | ||
} | ||
|
||
.app-drop-down .bunt-button .bunt-button-content { | ||
text-transform: capitalize; | ||
} | ||
</style> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
<template> | ||
<transition :name="elClass"> | ||
<div v-if="active" :class="elClass" @click.stop> | ||
<slot /> | ||
</div> | ||
</transition> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'AppDropdownContent', | ||
inject: ['sharedState'], | ||
props: { | ||
className: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
computed: { | ||
active () { | ||
return this.sharedState.active | ||
}, | ||
elClass () { | ||
return this.className ? this.className + " dropdown-content" : 'dropdown-content' | ||
}, | ||
}, | ||
} | ||
</script> | ||
|
||
<style> | ||
.dropdown-content { | ||
position: absolute; | ||
margin-top: 4px; | ||
left: 0; | ||
right: 0; | ||
width: 100%; | ||
max-width: none; | ||
min-width: 400px; | ||
border: 1px solid rgba(0, 0, 0, 0.38); | ||
background-color: #fff; | ||
z-index: 1000; | ||
max-height: 350px; | ||
overflow-y: auto; | ||
padding-bottom: 10px; | ||
} | ||
.dropdown-content .checkbox-line { | ||
margin: 8px; | ||
} | ||
.dropdown-content .checkbox-line .bunt-checkbox .bunt-checkbox-box { | ||
min-width: 20px; | ||
} | ||
.dropdown-content-enter-active, | ||
.dropdown-content-leave-active { | ||
transition: all 0.2s; | ||
} | ||
.dropdown-content-enter, | ||
.dropdown-content-leave-to { | ||
opacity: 0; | ||
transform: translateY(-5px); | ||
} | ||
|
||
.checkbox-text { | ||
margin-left: 10px; | ||
flex: 1; | ||
white-space: normal; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
text-align: left; | ||
} | ||
|
||
@media (max-width: 480px) { | ||
.dropdown-content { | ||
width: 70vw; | ||
left: 5vw; | ||
right: auto; | ||
max-width: calc(100% - 40px); | ||
min-width: 350px; | ||
margin-left: -20px; | ||
position: fixed; | ||
} | ||
} | ||
</style> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<template> | ||
<div> | ||
<slot/> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: "AppDropdownItem" | ||
}; | ||
</script> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,6 +47,10 @@ export default { | |
if (!state.schedule) return {} | ||
return state.schedule.speakers.reduce((acc, s) => { acc[s.code] = s; return acc }, {}) | ||
}, | ||
sessionTypeLookup (state) { | ||
if (!state.schedule) return {} | ||
return state.schedule.session_type.reduce((acc, s) => { acc[s.code] = s; return acc }, {}) | ||
}, | ||
sessions (state, getters, rootState) { | ||
if (!state.schedule) return | ||
const sessions = [] | ||
|
@@ -70,7 +74,8 @@ export default { | |
speakers: session.speakers?.map(s => getters.speakersLookup[s]), | ||
track: getters.tracksLookup[session.track], | ||
room: getters.roomsLookup[session.room], | ||
tags: session.tags | ||
tags: session.tags, | ||
session_type: session.session_type | ||
}) | ||
} | ||
sessions.sort((a, b) => ( | ||
|
@@ -117,6 +122,9 @@ export default { | |
} | ||
} | ||
return rooms | ||
}, | ||
schedule (state) { | ||
return state.schedule | ||
} | ||
}, | ||
actions: { | ||
|
@@ -127,6 +135,13 @@ export default { | |
// console.log(version.results[0].version) | ||
try { | ||
state.schedule = await (await fetch(getters.pretalxScheduleUrl)).json() | ||
state.schedule.session_type = state.schedule.talks.reduce((acc, current) => { | ||
const isDuplicate = acc.some(item => item.session_type === current.session_type); | ||
if (!isDuplicate) { | ||
acc.push(current); | ||
} | ||
return acc; | ||
}, []); | ||
Comment on lines
+138
to
+144
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Move session type processing to a separate action The processing of session types could be moved to a separate action or mutation for better organization and potential reusability. This would also make the main action cleaner and easier to understand.
|
||
} catch (error) { | ||
state.errorLoading = error | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider consolidating logic to avoid redundancy.
The new code introduces some complexity that could be streamlined. The
sessionTypeLookup
function adds redundancy similar totracksLookup
andspeakersLookup
, which can complicate maintenance. Consider consolidating this logic to avoid duplication. Thefetch
action now includes data processing, which should ideally be separated from data fetching to maintain clear separation of concerns. Direct state mutation within actions can lead to side effects; using mutations to commit processed data to the state is more Vuex-compliant. Additionally, inconsistent naming, such assession_type
used in different contexts, can be confusing. Consistent naming conventions would improve readability. Refactoring these aspects could enhance maintainability and clarity.