Skip to content

Commit

Permalink
Merge branch 'qa' into fix/MUWM-5349
Browse files Browse the repository at this point in the history
  • Loading branch information
fanglinfang committed Jul 11, 2024
2 parents 8d57d90 + c6af524 commit b7a8abd
Showing 1 changed file with 63 additions and 1 deletion.
64 changes: 63 additions & 1 deletion myuw_vue/components/teaching/classlist/photo-list.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,19 @@
<h3 class="visually-hidden">
Grid of Student Photos
</h3>
<div class="sort-buttons myuw-text-md">
<span class="py-1" style=""><strong>Sort by:</strong></span><button
v-for="field in fields"
:key="field.key"
type="button"
:class="buttonClass(field.key)"
@click="setSortKey(field.key)"
>
{{ field.label }}
</button>
</div>
<ol class="list-unstyled d-flex flex-wrap">
<li v-for="(reg, i) in registrations"
<li v-for="(reg, i) in sortedRegistrations"
:id="`student-photo-${reg.regid}`"
:key="i"
class="p-1 mb-1"
Expand Down Expand Up @@ -41,5 +52,56 @@ export default {
default: false,
},
},
data() {
return {
sortKey: 'surname',
fields: [
{ key: 'first_name', label: 'first name', sortable: true },
{ key: 'surname', label: 'last name', sortable: true }
]
};
},
computed: {
sortedRegistrations() {
const key = this.sortKey;
return [...this.registrations].sort((a, b) => {
if (a[key] < b[key]) return -1;
if (a[key] > b[key]) return 1;
return 0;
});
},
},
methods: {
setSortKey(key) {
this.sortKey = key;
},
buttonClass(key) {
return {
'btn': true,
'btn-link': true,
'active': this.sortKey === key,
'inactive': this.sortKey !== key,
'disabled': this.sortKey === key,
'myuw-text-md': true,
'px-1': true,
'py-1': true
};
}
}
};
</script>
<style scoped>
.sort-buttons{
padding-bottom:.5em;
}
.active {
font-weight: bold;
}
.inactive {
font-weight: normal;
}
.btn-link.disabled {
color: #000;
opacity:1;
}
</style>

0 comments on commit b7a8abd

Please sign in to comment.