diff options
author | Zero~Informatique | 2020-02-28 04:09:40 +0100 |
---|---|---|
committer | Zero~Informatique | 2020-02-28 04:09:40 +0100 |
commit | 8d889762872501eebd5edb5d7cacddfd4cd55ad4 (patch) | |
tree | 984ceda461f5dc5294653f8edac3ef125b516159 /viewer/src | |
parent | afa8a533ebb6943405cc5933167634c144e7f8c7 (diff) | |
download | ldgallery-8d889762872501eebd5edb5d7cacddfd4cd55ad4.tar.gz |
viewer: more minor architectural improvement
Diffstat (limited to 'viewer/src')
-rw-r--r-- | viewer/src/services/indexfactory.ts | 14 | ||||
-rw-r--r-- | viewer/src/store/galleryStore.ts | 2 | ||||
-rw-r--r-- | viewer/src/store/uiStore.ts | 14 | ||||
-rw-r--r-- | viewer/src/views/GalleryDirectory.vue | 2 | ||||
-rw-r--r-- | viewer/src/views/GallerySearch.vue | 6 |
5 files changed, 22 insertions, 16 deletions
diff --git a/viewer/src/services/indexfactory.ts b/viewer/src/services/indexfactory.ts index 45abcd5..a31f3ef 100644 --- a/viewer/src/services/indexfactory.ts +++ b/viewer/src/services/indexfactory.ts | |||
@@ -93,12 +93,10 @@ export default class IndexFactory { | |||
93 | category = Navigation.normalize(category); | 93 | category = Navigation.normalize(category); |
94 | disambiguation = Navigation.normalize(disambiguation); | 94 | disambiguation = Navigation.normalize(disambiguation); |
95 | return Object.values(tagsIndex) | 95 | return Object.values(tagsIndex) |
96 | .filter(node => strict || node.tagfiltered.includes(category)) | 96 | .filter(node => IndexFactory.matches(node, category, strict)) |
97 | .filter(node => !strict || node.tagfiltered === category) | ||
98 | .flatMap(node => | 97 | .flatMap(node => |
99 | Object.values(node.children) | 98 | Object.values(node.children) |
100 | .filter(child => strict || child.tagfiltered.includes(disambiguation)) | 99 | .filter(child => IndexFactory.matches(child, disambiguation, strict)) |
101 | .filter(child => !strict || child.tagfiltered === disambiguation) | ||
102 | .map(child => ({ ...child, parent: node, operation, display: `${operation}${node.tag}:${child.tag}` })) | 100 | .map(child => ({ ...child, parent: node, operation, display: `${operation}${node.tag}:${child.tag}` })) |
103 | ); | 101 | ); |
104 | } | 102 | } |
@@ -106,8 +104,12 @@ export default class IndexFactory { | |||
106 | private static searchTagsFromFilter(tagsIndex: Tag.Index, operation: Operation, filter: string, strict: boolean): Tag.Search[] { | 104 | private static searchTagsFromFilter(tagsIndex: Tag.Index, operation: Operation, filter: string, strict: boolean): Tag.Search[] { |
107 | filter = Navigation.normalize(filter); | 105 | filter = Navigation.normalize(filter); |
108 | return Object.values(tagsIndex) | 106 | return Object.values(tagsIndex) |
109 | .filter(node => strict || node.tagfiltered.includes(filter)) | 107 | .filter(node => IndexFactory.matches(node, filter, strict)) |
110 | .filter(node => !strict || node.tagfiltered === filter) | ||
111 | .map(node => ({ ...node, operation, display: `${operation}${node.tag}` })); | 108 | .map(node => ({ ...node, operation, display: `${operation}${node.tag}` })); |
112 | } | 109 | } |
110 | |||
111 | private static matches(node: Tag.Node, filter: string, strict: boolean): boolean { | ||
112 | if (strict) return node.tagfiltered === filter; | ||
113 | return node.tagfiltered.includes(filter) | ||
114 | } | ||
113 | } | 115 | } |
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 9950f5b..bc43ed2 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts | |||
@@ -36,7 +36,7 @@ export default class GalleryStore extends VuexModule { | |||
36 | 36 | ||
37 | // --- | 37 | // --- |
38 | 38 | ||
39 | @mutation setConfig(config: Gallery.Config) { | 39 | @mutation private setConfig(config: Gallery.Config) { |
40 | this.config = config; | 40 | this.config = config; |
41 | } | 41 | } |
42 | 42 | ||
diff --git a/viewer/src/store/uiStore.ts b/viewer/src/store/uiStore.ts index 1e63b3e..21f9ce9 100644 --- a/viewer/src/store/uiStore.ts +++ b/viewer/src/store/uiStore.ts | |||
@@ -21,7 +21,7 @@ import { createModule, mutation, action } from "vuex-class-component"; | |||
21 | 21 | ||
22 | const VuexModule = createModule({ | 22 | const VuexModule = createModule({ |
23 | namespaced: "uiStore", | 23 | namespaced: "uiStore", |
24 | strict: false | 24 | strict: true |
25 | }) | 25 | }) |
26 | 26 | ||
27 | export default class UIStore extends VuexModule { | 27 | export default class UIStore extends VuexModule { |
@@ -32,11 +32,15 @@ export default class UIStore extends VuexModule { | |||
32 | 32 | ||
33 | // --- | 33 | // --- |
34 | 34 | ||
35 | @mutation toggleFullscreen() { | 35 | @mutation toggleFullscreen(value?: boolean) { |
36 | this.fullscreen = !this.fullscreen; | 36 | this.fullscreen = value ?? !this.fullscreen; |
37 | } | 37 | } |
38 | 38 | ||
39 | @mutation toggleFullWidth() { | 39 | @mutation toggleFullWidth(value?: boolean) { |
40 | this.fullWidth = !this.fullWidth; | 40 | this.fullWidth = value ?? !this.fullWidth; |
41 | } | ||
42 | |||
43 | @mutation toggleSearchMode(value?: boolean) { | ||
44 | this.searchMode = value ?? !this.searchMode; | ||
41 | } | 45 | } |
42 | } | 46 | } |
diff --git a/viewer/src/views/GalleryDirectory.vue b/viewer/src/views/GalleryDirectory.vue index 6e68578..30f651c 100644 --- a/viewer/src/views/GalleryDirectory.vue +++ b/viewer/src/views/GalleryDirectory.vue | |||
@@ -30,7 +30,7 @@ export default class GalleryDirectory extends Vue { | |||
30 | @Prop({ required: true }) readonly directory!: Gallery.Directory; | 30 | @Prop({ required: true }) readonly directory!: Gallery.Directory; |
31 | 31 | ||
32 | mounted() { | 32 | mounted() { |
33 | this.$uiStore.fullscreen = false; | 33 | this.$uiStore.toggleFullscreen(false); |
34 | } | 34 | } |
35 | 35 | ||
36 | orderedItems() { | 36 | orderedItems() { |
diff --git a/viewer/src/views/GallerySearch.vue b/viewer/src/views/GallerySearch.vue index d638df2..e3369b3 100644 --- a/viewer/src/views/GallerySearch.vue +++ b/viewer/src/views/GallerySearch.vue | |||
@@ -33,12 +33,12 @@ export default class GalleryPicture extends Vue { | |||
33 | otherCount: Number = 0; | 33 | otherCount: Number = 0; |
34 | 34 | ||
35 | mounted() { | 35 | mounted() { |
36 | this.$uiStore.fullscreen = false; | 36 | this.$uiStore.toggleFullscreen(false); |
37 | this.$uiStore.searchMode = true; | 37 | this.$uiStore.toggleSearchMode(true); |
38 | } | 38 | } |
39 | 39 | ||
40 | destroyed() { | 40 | destroyed() { |
41 | this.$uiStore.searchMode = false; | 41 | this.$uiStore.toggleSearchMode(false); |
42 | } | 42 | } |
43 | 43 | ||
44 | items() { | 44 | items() { |