aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/components/LdCommandSort.vue
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/src/components/LdCommandSort.vue')
-rw-r--r--viewer/src/components/LdCommandSort.vue17
1 files changed, 13 insertions, 4 deletions
diff --git a/viewer/src/components/LdCommandSort.vue b/viewer/src/components/LdCommandSort.vue
index 1eef5d3..a412afc 100644
--- a/viewer/src/components/LdCommandSort.vue
+++ b/viewer/src/components/LdCommandSort.vue
@@ -31,19 +31,28 @@
31</template> 31</template>
32 32
33<script lang="ts"> 33<script lang="ts">
34import { Component, Vue, Prop } from "vue-property-decorator"; 34import { Component, Vue, Prop, Watch } from "vue-property-decorator";
35import { RawLocation } from "vue-router"; 35import { RawLocation } from "vue-router";
36import ItemSortFn from "@/services/itemSortFn"; 36import ItemComparators, { ItemComparator } from "@/services/itemComparators";
37 37
38@Component 38@Component
39export default class LdCommandSort extends Vue { 39export default class LdCommandSort extends Vue {
40 readonly SORTS = [ 40 readonly SORTS = [
41 { name: this.$t("command.sort.byNameAsc"), fn: ItemSortFn.sortByNameAsc }, 41 { name: this.$t("command.sort.byNameAsc"), fn: ItemComparators.sortByNameAsc },
42 { name: this.$t("command.sort.byDateDesc"), fn: ItemSortFn.sortByDateDesc }, 42 { name: this.$t("command.sort.byDateDesc"), fn: ItemComparators.sortByDateDesc },
43 ]; 43 ];
44 44
45 selectedSort = 0; 45 selectedSort = 0;
46 46
47 created() {
48 this.onChangeStore(this.$uiStore.sortFn);
49 }
50
51 @Watch("$uiStore.sortFn")
52 onChangeStore(newFn: ItemComparator) {
53 this.selectedSort = this.SORTS.map(s => s.fn).indexOf(newFn);
54 }
55
47 onChangeSort(newValue: number) { 56 onChangeSort(newValue: number) {
48 this.$uiStore.setSortFn(this.SORTS[newValue].fn); 57 this.$uiStore.setSortFn(this.SORTS[newValue].fn);
49 } 58 }