aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/components
diff options
context:
space:
mode:
authorZero~Informatique2020-09-12 06:34:58 +0200
committerG.Fouet2020-09-12 23:19:44 +0200
commit96ed5e6583a7f03d4ea7fa0512e66fffb656cc6e (patch)
tree7df81984c78d616bff317be25f99c7c2d02286c8 /viewer/src/components
parent7a8eba922ad34182628f80cf2496d8654abe91e6 (diff)
downloadldgallery-96ed5e6583a7f03d4ea7fa0512e66fffb656cc6e.tar.gz
viewer: make default sort order configurable
github: resolves #239
Diffstat (limited to 'viewer/src/components')
-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 }