diff options
author | Zero~Informatique | 2020-09-25 10:42:33 +0200 |
---|---|---|
committer | Zero~Informatique | 2020-09-25 10:44:45 +0200 |
commit | 26210d495aed813baac1095b5c7a7c7879d2d206 (patch) | |
tree | 59360f49bb18c71f0576841fcc66ca8154567130 /viewer/src/components/LdCommandSort.vue | |
parent | 25a9af7212d757a53258990668620157c8ebe2e5 (diff) | |
download | ldgallery-26210d495aed813baac1095b5c7a7c7879d2d206.tar.gz |
viewer: refactor how the available sorts are stored
github: resolves #259
Diffstat (limited to 'viewer/src/components/LdCommandSort.vue')
-rw-r--r-- | viewer/src/components/LdCommandSort.vue | 13 |
1 files changed, 6 insertions, 7 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"> |
34 | import { Component, Vue, Prop } from "vue-property-decorator"; | 34 | import { Component, Vue, Prop } from "vue-property-decorator"; |
35 | import { RawLocation } from "vue-router"; | 35 | import ItemComparators, { ItemSort } from "@/services/itemComparators"; |
36 | import ItemComparators, { ItemComparator } from "@/services/itemComparators"; | ||
37 | 36 | ||
38 | @Component | 37 | @Component |
39 | export default class LdCommandSort extends Vue { | 38 | export 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> |