From 398ec827a6425455d5386d426c0b8327c22fc96e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Rosenstr=C3=B6m?= Date: Wed, 8 Nov 2023 10:12:22 +0100 Subject: [PATCH] Allow only one set of change categories for all library codes --- .../usersettings/change-categories.vue | 84 ++++++++++++------- .../components/usersettings/user-settings.vue | 4 +- vue-client/src/resources/json/i18n.json | 4 +- vue-client/src/store.js | 54 +++++++++--- 4 files changed, 103 insertions(+), 43 deletions(-) diff --git a/vue-client/src/components/usersettings/change-categories.vue b/vue-client/src/components/usersettings/change-categories.vue index e68ad39c69..f090dc56c0 100644 --- a/vue-client/src/components/usersettings/change-categories.vue +++ b/vue-client/src/components/usersettings/change-categories.vue @@ -8,71 +8,99 @@ export default { mixins: [LensMixin], data() { return { - expanded: false, + categoriesIsExpanded: false, + sigelIsExpanded: false, }; }, props: { sigel: Object, availableCategories: [], + availableSigels: [], }, methods: { - updateChangeCategories(e, sigel, categoryId) { - this.$store.dispatch('updateSubscribedChangeCategories', { libraryId: this.sigelUri, categoryId: categoryId, checked: e.target.checked }); + updateSigel(e, sigel) { + console.log('available sigels', JSON.stringify(this.availableSigels)); + console.log('sigelCode', sigel); + this.$store.dispatch('updateSubscribedSigel', { libraryId: this.sigelUri(sigel), checked: e.target.checked }); }, - toggleExpanded() { - this.expanded = !this.expanded; + updateCategory(e, categoryId) { + this.$store.dispatch('updateSubscribedChangeCategory', { categoryId: categoryId, checked: e.target.checked }); + }, + toggleSigelExpanded() { + this.sigelIsExpanded = !this.sigelIsExpanded; + }, + toggleCategoriesExpanded() { + this.categoriesIsExpanded = !this.categoriesIsExpanded; }, isActiveCategory(categoryId) { - const obj = this.userChangeCategories.find(c => c.heldBy === this.sigelUri); + const obj = this.userChangeCategories[0]; return obj ? obj.triggers.includes(categoryId) : false; }, + isActiveSigel(sigel) { + console.log('this.userChangeCategories', JSON.stringify(this.userChangeCategories)); + const obj = this.userChangeCategories.find(c => c.heldBy === this.sigelUri(sigel)); + return !!obj; + }, label(obj) { return this.getLabel(obj); }, + sigelLabel(sigel) { + return StringUtil.getSigelLabel(sigel); + }, + sigelUri(sigel) { + return StringUtil.getLibraryUri(sigel.code); + }, }, computed: { ...mapGetters([ 'userChangeCategories', ]), - isExpanded() { - return this.expanded; - }, - sigelLabel() { - return StringUtil.getSigelLabel(this.sigel); - }, - sigelUri() { - return StringUtil.getLibraryUri(this.sigel.code); - }, }, mounted() { - this.$nextTick(() => { - }); }, }; -