Skip to content
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

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"uuid": "^8.3.0",
"vue": "^2.6.12",
"vue-advanced-cropper": "^0.16.10",
"vue-clickaway": "^2.2.2",
"vue-js-modal": "^2.0.1",
"vue-router": "^3.4.3",
"vue-slicksort": "^1.2.0",
Expand Down
82 changes: 82 additions & 0 deletions webapp/src/components/AppDropdown.vue
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

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 spaces but found 4 spaces

Check warning on line 2 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

':class' should be on a new line
<bunt-button @click="toggle">

Check warning on line 3 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6 spaces
<slot name="toggler"> Toggle </slot>

Check warning on line 4 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 8 spaces

Check warning on line 4 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected 1 line break after opening tag (`<slot>`), but no line breaks found

Check warning on line 4 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected 1 line break before closing tag (`</slot>`), but no line breaks found
<svg

Check warning on line 5 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 6 spaces but found 8 spaces
v-if="this.sharedState.active"

Check warning on line 6 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 10 spaces

Check warning on line 6 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Unexpected usage of 'this'
xmlns="http://www.w3.org/2000/svg"

Check warning on line 7 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 8 spaces but found 10 spaces
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>

Check failure on line 27 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 0 tabs but found 2 spaces
import { computed } from 'vue';

Check failure on line 28 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 0 tabs but found 2 spaces

Check failure on line 28 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

'computed' is defined but never used

Check failure on line 28 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Extra semicolon
import { mixin as clickaway } from 'vue-clickaway'

Check failure on line 30 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Trailing spaces not allowed
export default {

Check failure on line 31 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 0 tabs but found 2 spaces
name: 'AppDropdown',

Check failure on line 32 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 1 tab but found 6 spaces
mixins: [clickaway],

Check failure on line 33 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 1 tab but found 6 spaces
props: {

Check failure on line 34 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 1 tab but found 6 spaces
className: {

Check failure on line 35 in webapp/src/components/AppDropdown.vue

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 2 tabs but found 8 spaces
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>

82 changes: 82 additions & 0 deletions webapp/src/components/AppDropdownContent.vue
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>
11 changes: 11 additions & 0 deletions webapp/src/components/AppDropdownItem.vue
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>
17 changes: 16 additions & 1 deletion webapp/src/store/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Copy link

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 to tracksLookup and speakersLookup, which can complicate maintenance. Consider consolidating this logic to avoid duplication. The fetch 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 as session_type used in different contexts, can be confusing. Consistent naming conventions would improve readability. Refactoring these aspects could enhance maintainability and clarity.

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 = []
Expand All @@ -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) => (
Expand Down Expand Up @@ -117,6 +122,9 @@ export default {
}
}
return rooms
},
schedule (state) {
return state.schedule
}
},
actions: {
Expand All @@ -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
Copy link

Choose a reason for hiding this comment

The 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.

// In store/schedule.js
const processSessionTypes = (talks) => {
  return talks.reduce((acc, current) => {
    if (!acc.some(item => item.session_type === current.session_type)) {
      acc.push(current);
    }
    return acc;
  }, []);
};

// In the action
state.schedule.session_type = processSessionTypes(state.schedule.talks);

} catch (error) {
state.errorLoading = error
}
Expand Down
Loading
Loading