From 577f49ab6e1fd9cd8007804a13dea1471ee2fb1f Mon Sep 17 00:00:00 2001 From: Zero~Informatique Date: Fri, 3 Apr 2020 03:42:35 +0200 Subject: viewer: tag categories implementation GitHub: Resolves #29 --- viewer/src/store/galleryStore.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'viewer/src/store') 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 { config: Gallery.Config | null = null; galleryIndex: Gallery.Index | null = null; tagsIndex: Tag.Index = {}; + tagsCategories: Tag.Category[] = []; currentPath: string = "/"; currentSearch: Tag.Search[] = []; @@ -48,6 +49,10 @@ export default class GalleryStore extends VuexModule { this.tagsIndex = Object.freeze(tagsIndex); } + @mutation private setTagsCategories(tagsCategories: Tag.Category[]) { + this.tagsCategories = tagsCategories; + } + @mutation setCurrentPath(currentPath: string) { this.currentPath = currentPath; } @@ -89,7 +94,8 @@ export default class GalleryStore extends VuexModule { return fetch(`${process.env.VUE_APP_DATA_URL}${root}index.json`, { cache: "no-cache" }) .then(response => response.json()) .then(this.setGalleryIndex) - .then(this.indexTags); + .then(this.indexTags) + .then(this.indexTagCategories); } // Indexes the gallery @@ -100,6 +106,13 @@ export default class GalleryStore extends VuexModule { return index; } + // Indexes the proposed categories + @action async indexTagCategories() { + const categories = IndexFactory.generateCategories(this.tagsIndex, this.galleryIndex?.properties.tagCategories); + this.setTagsCategories(categories); + return categories; + } + // Searches for tags @action async search(filters: string[]) { const results = filters.flatMap(filter => IndexFactory.searchTags(this.tagsIndex, filter, true)); -- cgit v1.2.3