From 170d7a61f720ece9dc4b347b19f5a8213f1d8984 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 20 Jun 2020 16:50:49 +0200 Subject: viewer: prettier formatting based on eslint-prettier plugin --- viewer/src/store/uiStore.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'viewer/src/store/uiStore.ts') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 892d35e..91ac338 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -21,11 +21,10 @@ import { createModule, mutation, action } from "vuex-class-component"; const VuexModule = createModule({ namespaced: "uiStore", - strict: true -}) + strict: true, +}); export default class UIStore extends VuexModule { - fullscreen: boolean = false; fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; -- cgit v1.2.3 From e6c2a8d9653ffde924632ca2f260c3a8cddc14ed Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 11 Sep 2020 00:15:04 +0200 Subject: viewer: item display order github: resolves #28 --- viewer/src/store/uiStore.ts | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'viewer/src/store/uiStore.ts') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 91ac338..1fe9f49 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -18,16 +18,20 @@ */ import { createModule, mutation, action } from "vuex-class-component"; +import ItemSortFn from "@/services/itemSortFn"; const VuexModule = createModule({ namespaced: "uiStore", strict: true, }); +type TItemSortFn = (left: Gallery.Item, right: Gallery.Item) => number; + export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; + sortFn: TItemSortFn = ItemSortFn.sortByName; // --- @@ -42,4 +46,8 @@ export default class UIStore extends VuexModule { @mutation toggleSearchMode(value?: boolean) { this.searchMode = value ?? !this.searchMode; } + + @mutation setSortFn(sortFn: TItemSortFn) { + this.sortFn = sortFn; + } } -- cgit v1.2.3 From f89ed0bd94ea570d9e6533301783d13b13033db0 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 11 Sep 2020 20:10:56 +0200 Subject: viewer: PR #238 code review changes --- viewer/src/store/uiStore.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'viewer/src/store/uiStore.ts') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 1fe9f49..2d583fc 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -31,7 +31,7 @@ export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; - sortFn: TItemSortFn = ItemSortFn.sortByName; + sortFn: TItemSortFn = ItemSortFn.sortByNameAsc; // --- -- cgit v1.2.3 From 96ed5e6583a7f03d4ea7fa0512e66fffb656cc6e Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 12 Sep 2020 06:34:58 +0200 Subject: viewer: make default sort order configurable github: resolves #239 --- viewer/src/store/uiStore.ts | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'viewer/src/store/uiStore.ts') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 2d583fc..04f14a0 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -18,20 +18,18 @@ */ import { createModule, mutation, action } from "vuex-class-component"; -import ItemSortFn from "@/services/itemSortFn"; +import ItemComparators, { ItemComparator } from "@/services/itemComparators"; const VuexModule = createModule({ namespaced: "uiStore", strict: true, }); -type TItemSortFn = (left: Gallery.Item, right: Gallery.Item) => number; - export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; - sortFn: TItemSortFn = ItemSortFn.sortByNameAsc; + sortFn: ItemComparator = ItemComparators.sortByNameAsc; // --- @@ -47,7 +45,20 @@ export default class UIStore extends VuexModule { this.searchMode = value ?? !this.searchMode; } - @mutation setSortFn(sortFn: TItemSortFn) { + @mutation setSortFn(sortFn: ItemComparator) { this.sortFn = sortFn; } + + @action async initFromConfig(config: Gallery.Config) { + switch (config.initialSort ?? "") { + case "date_desc": + this.setSortFn(ItemComparators.sortByDateDesc); + break; + case "name_asc": + case "": + break; + default: + throw new Error("Unknown sort type: " + config.initialSort); + } + } } -- cgit v1.2.3 From b909ec093591b50950c0de54b2005d471ca28116 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Sat, 12 Sep 2020 22:33:37 +0200 Subject: viewer: make default sort order configurable. code review improvements github: resolves #239 --- viewer/src/store/uiStore.ts | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'viewer/src/store/uiStore.ts') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 04f14a0..84e7fed 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -29,7 +29,7 @@ export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; - sortFn: ItemComparator = ItemComparators.sortByNameAsc; + sortFn: ItemComparator = ItemComparators.DEFAULT; // --- @@ -50,15 +50,10 @@ export default class UIStore extends VuexModule { } @action async initFromConfig(config: Gallery.Config) { - switch (config.initialSort ?? "") { - case "date_desc": - this.setSortFn(ItemComparators.sortByDateDesc); - break; - case "name_asc": - case "": - break; - default: - throw new Error("Unknown sort type: " + config.initialSort); + if (config.initialItemSort) { + const itemSort = ItemComparators.ITEM_SORTS.find(s => s.name == config.initialItemSort); + if (itemSort) this.setSortFn(itemSort.fn); + else throw new Error("Unknown sort type: " + config.initialItemSort); } } } -- cgit v1.2.3 From 26210d495aed813baac1095b5c7a7c7879d2d206 Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 25 Sep 2020 10:42:33 +0200 Subject: viewer: refactor how the available sorts are stored github: resolves #259 --- viewer/src/store/uiStore.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'viewer/src/store/uiStore.ts') diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 84e7fed..f065cdd 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts @@ -18,7 +18,7 @@ */ import { createModule, mutation, action } from "vuex-class-component"; -import ItemComparators, { ItemComparator } from "@/services/itemComparators"; +import ItemComparators, { ItemSort } from "@/services/itemComparators"; const VuexModule = createModule({ namespaced: "uiStore", @@ -29,7 +29,7 @@ export default class UIStore extends VuexModule { fullscreen: boolean = false; fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); searchMode: boolean = false; - sortFn: ItemComparator = ItemComparators.DEFAULT; + sort: ItemSort = ItemComparators.DEFAULT; // --- @@ -45,14 +45,14 @@ export default class UIStore extends VuexModule { this.searchMode = value ?? !this.searchMode; } - @mutation setSortFn(sortFn: ItemComparator) { - this.sortFn = sortFn; + @mutation setSort(sort: ItemSort) { + this.sort = sort; } @action async initFromConfig(config: Gallery.Config) { if (config.initialItemSort) { - const itemSort = ItemComparators.ITEM_SORTS.find(s => s.name == config.initialItemSort); - if (itemSort) this.setSortFn(itemSort.fn); + const itemSort = ItemComparators.ITEM_SORTS[config.initialItemSort]; + if (itemSort) this.setSort(itemSort); else throw new Error("Unknown sort type: " + config.initialItemSort); } } -- cgit v1.2.3