diff options
author | OzoneGrif | 2020-04-04 02:36:03 +0200 |
---|---|---|
committer | GitHub | 2020-04-04 02:36:03 +0200 |
commit | c26ab69997d1d552fda72b8fd88d5910fc91b779 (patch) | |
tree | aea8a7801c1445e71d966ca3a0532200abf2c724 /viewer/src/store | |
parent | 332b208d3fdc91d29181c8f42ef5ff9b1fd1f09a (diff) | |
parent | 84090e0f534cfa8bf601ae6df21e5df695fd149a (diff) | |
download | ldgallery-c26ab69997d1d552fda72b8fd88d5910fc91b779.tar.gz |
Merge pull request #172 from pacien/tag-categories
Feature: tag categories
Diffstat (limited to 'viewer/src/store')
-rw-r--r-- | viewer/src/store/galleryStore.ts | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/viewer/src/store/galleryStore.ts b/viewer/src/store/galleryStore.ts index 4a5de0f..352a266 100644 --- a/viewer/src/store/galleryStore.ts +++ b/viewer/src/store/galleryStore.ts | |||
@@ -31,6 +31,7 @@ export default class GalleryStore extends VuexModule { | |||
31 | config: Gallery.Config | null = null; | 31 | config: Gallery.Config | null = null; |
32 | galleryIndex: Gallery.Index | null = null; | 32 | galleryIndex: Gallery.Index | null = null; |
33 | tagsIndex: Tag.Index = {}; | 33 | tagsIndex: Tag.Index = {}; |
34 | tagsCategories: Tag.Category[] = []; | ||
34 | currentPath: string = "/"; | 35 | currentPath: string = "/"; |
35 | currentSearch: Tag.Search[] = []; | 36 | currentSearch: Tag.Search[] = []; |
36 | 37 | ||
@@ -48,6 +49,10 @@ export default class GalleryStore extends VuexModule { | |||
48 | this.tagsIndex = Object.freeze(tagsIndex); | 49 | this.tagsIndex = Object.freeze(tagsIndex); |
49 | } | 50 | } |
50 | 51 | ||
52 | @mutation private setTagsCategories(tagsCategories: Tag.Category[]) { | ||
53 | this.tagsCategories = tagsCategories; | ||
54 | } | ||
55 | |||
51 | @mutation setCurrentPath(currentPath: string) { | 56 | @mutation setCurrentPath(currentPath: string) { |
52 | this.currentPath = currentPath; | 57 | this.currentPath = currentPath; |
53 | } | 58 | } |
@@ -89,7 +94,8 @@ export default class GalleryStore extends VuexModule { | |||
89 | return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) | 94 | return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) |
90 | .then(response => response.json()) | 95 | .then(response => response.json()) |
91 | .then(this.setGalleryIndex) | 96 | .then(this.setGalleryIndex) |
92 | .then(this.indexTags); | 97 | .then(this.indexTags) |
98 | .then(this.indexTagCategories); | ||
93 | } | 99 | } |
94 | 100 | ||
95 | // Indexes the gallery | 101 | // Indexes the gallery |
@@ -100,6 +106,13 @@ export default class GalleryStore extends VuexModule { | |||
100 | return index; | 106 | return index; |
101 | } | 107 | } |
102 | 108 | ||
109 | // Indexes the proposed categories | ||
110 | @action async indexTagCategories() { | ||
111 | const categories = IndexFactory.generateCategories(this.tagsIndex, this.galleryIndex?.properties.tagCategories); | ||
112 | this.setTagsCategories(categories); | ||
113 | return categories; | ||
114 | } | ||
115 | |||
103 | // Searches for tags | 116 | // Searches for tags |
104 | @action async search(filters: string[]) { | 117 | @action async search(filters: string[]) { |
105 | const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); | 118 | const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); |