aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/components
diff options
context:
space:
mode:
authorZero~Informatique2020-09-25 10:42:33 +0200
committerZero~Informatique2020-09-25 10:44:45 +0200
commit26210d495aed813baac1095b5c7a7c7879d2d206 (patch)
tree59360f49bb18c71f0576841fcc66ca8154567130 /viewer/src/components
parent25a9af7212d757a53258990668620157c8ebe2e5 (diff)
downloadldgallery-26210d495aed813baac1095b5c7a7c7879d2d206.tar.gz
viewer: refactor how the available sorts are stored
github: resolves #259
Diffstat (limited to 'viewer/src/components')
-rw-r--r--viewer/src/components/LdCommandSort.vue13
-rw-r--r--viewer/src/components/LdGallery.vue2
2 files changed, 7 insertions, 8 deletions
diff --git a/viewer/src/components/LdCommandSort.vue b/viewer/src/components/LdCommandSort.vue
index 30644c1..cfaa5c1 100644
--- a/viewer/src/components/LdCommandSort.vue
+++ b/viewer/src/components/LdCommandSort.vue
@@ -23,8 +23,8 @@
23 <a slot="trigger" class="link"> 23 <a slot="trigger" class="link">
24 <fa-icon icon="sort-amount-down" size="lg" /> 24 <fa-icon icon="sort-amount-down" size="lg" />
25 </a> 25 </a>
26 <b-dropdown-item v-for="(sort, idx) in ITEM_SORTS" :key="idx" :value="idx"> 26 <b-dropdown-item v-for="(sort, idx) in ITEM_SORTS" :key="idx" :value="sort">
27 <fa-icon :icon="['far', idx === selectedSort ? 'dot-circle' : 'circle']" /> 27 <fa-icon :icon="['far', sort === selectedSort ? 'dot-circle' : 'circle']" />
28 <span :class="$style.dropdownLabel">{{ sort.text }}</span> 28 <span :class="$style.dropdownLabel">{{ sort.text }}</span>
29 </b-dropdown-item> 29 </b-dropdown-item>
30 </b-dropdown> 30 </b-dropdown>
@@ -32,19 +32,18 @@
32 32
33<script lang="ts"> 33<script lang="ts">
34import { Component, Vue, Prop } from "vue-property-decorator"; 34import { Component, Vue, Prop } from "vue-property-decorator";
35import { RawLocation } from "vue-router"; 35import ItemComparators, { ItemSort } from "@/services/itemComparators";
36import ItemComparators, { ItemComparator } from "@/services/itemComparators";
37 36
38@Component 37@Component
39export default class LdCommandSort extends Vue { 38export default class LdCommandSort extends Vue {
40 readonly ITEM_SORTS = ItemComparators.ITEM_SORTS; 39 readonly ITEM_SORTS = ItemComparators.ITEM_SORTS;
41 40
42 get selectedSort() { 41 get selectedSort() {
43 return this.ITEM_SORTS.map(s => s.fn).indexOf(this.$uiStore.sortFn); 42 return this.$uiStore.sort;
44 } 43 }
45 44
46 set selectedSort(newValue: number) { 45 set selectedSort(newValue: ItemSort) {
47 this.$uiStore.setSortFn(this.ITEM_SORTS[newValue].fn); 46 this.$uiStore.setSort(newValue);
48 } 47 }
49} 48}
50</script> 49</script>
diff --git a/viewer/src/components/LdGallery.vue b/viewer/src/components/LdGallery.vue
index 0c0a43c..edd479c 100644
--- a/viewer/src/components/LdGallery.vue
+++ b/viewer/src/components/LdGallery.vue
@@ -36,7 +36,7 @@ export default class LdPicture extends Vue {
36 @Prop(String) readonly noresult?: string; 36 @Prop(String) readonly noresult?: string;
37 37
38 get sortedItems() { 38 get sortedItems() {
39 return this.items.sort(this.$uiStore.sortFn); 39 return this.items.sort(this.$uiStore.sort.fn);
40 } 40 }
41 41
42 get hasNoResults(): boolean { 42 get hasNoResults(): boolean {