Skip to content

Commit

Permalink
feat: add filter by department
Browse files Browse the repository at this point in the history
  • Loading branch information
stadial committed Oct 23, 2022
1 parent 4fdafa4 commit fd099ee
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 3 deletions.
22 changes: 20 additions & 2 deletions components/ClassesFilters.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@
@input="$emit('college:change', $event)"
></v-select>
</v-col>

<v-col class="d-flex" cols="12" sm="4">
<v-select
v-model="selectedDepartments"
:items="allDepartments"
item-text="name"
item-value="abbrv"
label="Departments"
return-object
:disabled="!selectedCollege"
@input="$emit('department:change', $event)"
chips
multiple
></v-select>
</v-col>

</v-row>
</v-container>
</v-card-actions>
Expand All @@ -40,12 +56,14 @@ export default {
colleges : { type: Array, default: () => [] },
loading: { type: Boolean, default: false },
genders: {type: Array, default: () => []},
allDepartments: {type: Array, default: () => []},
},
emits: ['major:change', 'semsters:change', 'department:change'],
emits: ['gender:change', 'college:change', 'department:change'],
data() {
return {
selectedGender: null, /* "male" or "female" */
selectedCollege: null,
selectedCollege: null,
selectedDepartments: [],
}
},
computed: {},
Expand Down
15 changes: 14 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
<ClassesFilters
@college:change="collegeChange($event)"
@gender:change="genderChange($event)"
@department:change="selectedDepartments = $event"
:colleges="colleges"
:genders="genders"
:allDepartments="allDepartments"
/>
<ClassesList
:loading="loadingClasses"
Expand Down Expand Up @@ -58,12 +60,23 @@ export default {
loadingClasses: false,
snackbarText: '',
snackbarActive: false,
selectedDepartments: [],
}
},
computed: {
allDepartments(){
// with duplicates
let departments = this.rawClasses.map((a)=> a.department);
// without dups
let unique = [...new Set(departments)];
return unique;
},
filteredClasses() {
// it no longer filters, this naming is due to historic reasons
let filtered = this.rawClasses.map((clas) =>
let filtered = this.rawClasses.filter(clas =>
this.selectedDepartments.includes(clas.department)
)
filtered = filtered.map((clas) =>
findConflicts(clas, this.selectedClasses)
)
filtered = filtered.map(buttonOptions)
Expand Down

0 comments on commit fd099ee

Please sign in to comment.