diff options
author | pacien | 2020-09-25 16:01:49 +0200 |
---|---|---|
committer | pacien | 2020-09-25 16:01:49 +0200 |
commit | e93f7b1eb84c083d67567115284c0002a3a7d5fc (patch) | |
tree | 8d373e8f7f571485e1330928f43b090ed004c525 /viewer/src/store/uiStore.ts | |
parent | 8e3ac8fe44bebb38e1882ca7f06b8100078ad88d (diff) | |
parent | fd542f75a1d94ee5f804d0925823276b97f38581 (diff) | |
download | ldgallery-e93f7b1eb84c083d67567115284c0002a3a7d5fc.tar.gz |
Merge branch 'develop' for release v2.0v2.0
Diffstat (limited to 'viewer/src/store/uiStore.ts')
-rw-r--r-- | viewer/src/store/uiStore.ts | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 892d35e..f065cdd 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts | |||
@@ -18,17 +18,18 @@ | |||
18 | */ | 18 | */ |
19 | 19 | ||
20 | import { createModule, mutation, action } from "vuex-class-component"; | 20 | import { createModule, mutation, action } from "vuex-class-component"; |
21 | import ItemComparators, { ItemSort } from "@/services/itemComparators"; | ||
21 | 22 | ||
22 | const VuexModule = createModule({ | 23 | const VuexModule = createModule({ |
23 | namespaced: "uiStore", | 24 | namespaced: "uiStore", |
24 | strict: true | 25 | strict: true, |
25 | }) | 26 | }); |
26 | 27 | ||
27 | export default class UIStore extends VuexModule { | 28 | export default class UIStore extends VuexModule { |
28 | |||
29 | fullscreen: boolean = false; | 29 | fullscreen: boolean = false; |
30 | fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); | 30 | fullWidth: boolean = window.innerWidth < Number(process.env.VUE_APP_FULLWIDTH_LIMIT); |
31 | searchMode: boolean = false; | 31 | searchMode: boolean = false; |
32 | sort: ItemSort = ItemComparators.DEFAULT; | ||
32 | 33 | ||
33 | // --- | 34 | // --- |
34 | 35 | ||
@@ -43,4 +44,16 @@ export default class UIStore extends VuexModule { | |||
43 | @mutation toggleSearchMode(value?: boolean) { | 44 | @mutation toggleSearchMode(value?: boolean) { |
44 | this.searchMode = value ?? !this.searchMode; | 45 | this.searchMode = value ?? !this.searchMode; |
45 | } | 46 | } |
47 | |||
48 | @mutation setSort(sort: ItemSort) { | ||
49 | this.sort = sort; | ||
50 | } | ||
51 | |||
52 | @action async initFromConfig(config: Gallery.Config) { | ||
53 | if (config.initialItemSort) { | ||
54 | const itemSort = ItemComparators.ITEM_SORTS[config.initialItemSort]; | ||
55 | if (itemSort) this.setSort(itemSort); | ||
56 | else throw new Error("Unknown sort type: " + config.initialItemSort); | ||
57 | } | ||
58 | } | ||
46 | } | 59 | } |