From abea70192120823467d8c5fe847442f469a49765 Mon Sep 17 00:00:00 2001 From: Prashant-thakur77 Date: Mon, 17 Aug 2026 01:30:25 +0530 Subject: [PATCH 1/5] Refactor CategoryOptions dropdown to KMultiSelect, keeping expanded mode unchanged --- .../contentNodeFields/CategoryOptions.vue | 84 ++++++++++++++++++- 1 file changed, 80 insertions(+), 4 deletions(-) diff --git a/contentcuration/contentcuration/frontend/shared/views/contentNodeFields/CategoryOptions.vue b/contentcuration/contentcuration/frontend/shared/views/contentNodeFields/CategoryOptions.vue index cc81b17e5e..f5913a5a8c 100644 --- a/contentcuration/contentcuration/frontend/shared/views/contentNodeFields/CategoryOptions.vue +++ b/contentcuration/contentcuration/frontend/shared/views/contentNodeFields/CategoryOptions.vue @@ -1,7 +1,38 @@ @@ -139,6 +112,7 @@ import KChip from 'kolibri-design-system/lib/candidate/multiselect/KChip'; import { getSortedCategories } from 'shared/utils/helpers'; import { commonStrings } from 'shared/strings/commonStrings'; + import { communityChannelsStrings } from 'shared/strings/communityChannelsStrings'; import DropdownWrapper from 'shared/views/form/DropdownWrapper'; import { constantsTranslationMixin, metadataTranslationMixin } from 'shared/mixins'; @@ -146,33 +120,6 @@ name: 'CategoryOptions', components: { KMultiSelect, KChip, DropdownWrapper }, mixins: [constantsTranslationMixin, metadataTranslationMixin], - setup() { - const { - clearAllAction$, - openMenuAction$, - closeMenuAction$, - optionsClickableLabel$, - allOptionsSelectedLabel$, - allOptionsDeselectedLabel$, - optionDeselectedLabel$, - partiallySelectedLabel$, - optionSelectedLabel$, - optionRemovedLabel$, - } = commonStrings; - - return { - clearAllAction$, - openMenuAction$, - closeMenuAction$, - optionsClickableLabel$, - allOptionsSelectedLabel$, - allOptionsDeselectedLabel$, - optionDeselectedLabel$, - partiallySelectedLabel$, - optionSelectedLabel$, - optionRemovedLabel$, - }; - }, props: { /** * This prop receives an object with the following structure: @@ -239,18 +186,30 @@ ); }, messages() { + const { + openMenuAction$, + closeMenuAction$, + optionsClickableLabel$, + allOptionsSelectedLabel$, + allOptionsDeselectedLabel$, + optionDeselectedLabel$, + partiallySelectedLabel$, + optionSelectedLabel$, + optionRemovedLabel$, + } = commonStrings; + const { clearAllAction$ } = communityChannelsStrings; return { - clearText: this.clearAllAction$, - open: this.openMenuAction$, - close: this.closeMenuAction$, - clickable: this.optionsClickableLabel$, - allOptionsSelected: this.allOptionsSelectedLabel$, - allOptionsDeselected: this.allOptionsDeselectedLabel$, - optionDeselected: this.optionDeselectedLabel$, - partiallySelected: this.partiallySelectedLabel$, + clearText: clearAllAction$, + open: openMenuAction$, + close: closeMenuAction$, + clickable: optionsClickableLabel$, + allOptionsSelected: allOptionsSelectedLabel$, + allOptionsDeselected: allOptionsDeselectedLabel$, + optionDeselected: optionDeselectedLabel$, + partiallySelected: partiallySelectedLabel$, itemsSelected: ({ count }) => this.$tr('itemsSelected', { count }), - selected: this.optionSelectedLabel$, - removed: this.optionRemovedLabel$, + selected: optionSelectedLabel$, + removed: optionRemovedLabel$, cleared: () => this.$tr('allCategoriesCleared'), }; }, @@ -278,20 +237,10 @@ removeAll() { this.selected = {}; }, - // Rebuilds the { category: [nodeIds] } object from KMultiSelect's flat - // array. Categories not applied to every edited node are invisible to - // KMultiSelect (see autocompleteValues), so they are carried over untouched. + // Dropdown mode is only rendered when a single node is edited, so every + // selected category simply applies to all of nodeIds. onKMultiSelectInput(newValues) { - const newSelected = {}; - Object.entries(this.selected).forEach(([category, ids]) => { - if (ids.length !== this.nodeIds.length) { - newSelected[category] = ids; - } - }); - newValues.forEach(value => { - newSelected[value] = this.nodeIds; - }); - this.selected = newSelected; + this.selected = Object.fromEntries(newValues.map(value => [value, this.nodeIds])); }, tooltipText(optionId) { const option = this.categoriesList.find(option => option.value === optionId); @@ -369,6 +318,7 @@ noCategoryFoundText: 'Category not found', itemsSelected: '{count, plural, one {# category selected} other {# categories selected}}', allCategoriesCleared: 'All categories cleared', + removeCategory: 'Remove {label}', }, }; @@ -377,10 +327,6 @@