From f5ee42dcf9355d1cb39f438c3bb929a81e39192b Mon Sep 17 00:00:00 2001
From: Allan Otodi Opeto <103313919+AllanOXDi@users.noreply.github.com>
Date: Fri, 6 Sep 2024 13:09:02 +0300
Subject: [PATCH 1/7] remove mixed tag as a category
---
.../QuickEditModal/EditBooleanMapModal.vue | 6 +++---
.../views/contentNodeFields/CategoryOptions.vue | 12 ------------
2 files changed, 3 insertions(+), 15 deletions(-)
diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue
index ad3ffbac7d..4f597b0036 100644
--- a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue
+++ b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue
@@ -2,7 +2,7 @@
+ {{ $tr('addAdditionalCategoriesDescription') }} +
+- {{ $tr('addAdditionalCategoriesDescription') }} +
+ {{ hasMixedCategoriesMessage }}
-+ {{ $tr('addAdditionalCategoriesDescription') }} +
- {{ $tr('addAdditionalCategoriesDescription') }} -
entry[1].length === this.nodeIds.length) .map(([key]) => key); - if ( - this.expanded && - Object.values(this.selected).some(value => value.length < this.nodeIds.length) - ) { - selectedValues.push(MIXED); - } return selectedValues; }, nested() { @@ -187,22 +170,6 @@ option.text.toLowerCase().includes(searchQuery) ); }, - hasMixedCategories() { - // Fetch the selected categories for the given nodeIds - const selectedNodes = this.nodeIds.map(nodeId => { - // Find the category ID in the selected values - const categoryForNode = Object.entries(this.selected).find(([nodes]) => - nodes.includes(nodeId) - ); - return categoryForNode ? categoryForNode[0] : null; // Return the categoryId or null - }); - - const uniqueCategories = new Set(selectedNodes); - console.log('Selected Nodes:', selectedNodes); // Log selected nodes - console.log('Unique Categories:', uniqueCategories); // Log unique categories - - return uniqueCategories.size > 1; - }, }, methods: { treeItemStyle(item) { @@ -291,15 +258,6 @@ }); return nodeIds.size === this.nodeIds.length; }, - isCheckboxIndeterminate(optionId) { - if (this.selected[optionId] && this.selected[optionId].length < this.nodeIds.length) { - return true; - } - return ( - Object.keys(this.selected).some(selectedValue => selectedValue.startsWith(optionId)) && - !this.isSelected(optionId) - ); - }, onChange(optionId) { if (this.isSelected(optionId)) { this.remove(optionId); @@ -310,8 +268,6 @@ }, $trs: { noCategoryFoundText: 'Category not found', - addAdditionalCategoriesDescription: - 'You selected resources that have different categories. The categories you choose below will be added to all selected resources. This will not remove existing categories.', }, }; diff --git a/contentcuration/contentcuration/frontend/shared/views/form/ExpandableSelect.vue b/contentcuration/contentcuration/frontend/shared/views/form/ExpandableSelect.vue index 127eeabd7a..cdeea8ee22 100644 --- a/contentcuration/contentcuration/frontend/shared/views/form/ExpandableSelect.vue +++ b/contentcuration/contentcuration/frontend/shared/views/form/ExpandableSelect.vue @@ -50,7 +50,6 @@ :key="option.value" :label="option.text" :checked="isSelected(option.value)" - :indeterminate="isIndeterminate(option.value)" data-test="option-checkbox" @change="value => setOption(option.value, value)" /> @@ -188,12 +187,6 @@ } return this.valueModel[value].length === this.availableItems.length; }, - isIndeterminate(value) { - if (!this.valueModel[value]) { - return false; - } - return this.valueModel[value].length < this.availableItems.length; - }, setOption(optionId, value) { if (value) { this.valueModel = { @@ -216,4 +209,4 @@ pointer-events: none; opacity: 0.5; } - \ No newline at end of file + From a57b9f11e2cbf3641addba20e4b6d8925aed01e0 Mon Sep 17 00:00:00 2001 From: Allan Otodi Opeto <103313919+AllanOXDi@users.noreply.github.com> Date: Fri, 13 Sep 2024 00:23:22 +0300 Subject: [PATCH 6/7] fixes failing test --- .../QuickEditModal/EditBooleanMapModal.vue | 6 +++-- .../__tests__/EditBooleanMapModal.spec.js | 27 ++----------------- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue index 0fec536372..79c123c4ca 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue @@ -162,13 +162,15 @@ }, async handleSave() { await Promise.all( - this.nodes.map(node => { + this.nodes.map(async node => { const fieldValue = {}; const currentNode = this.getContentNode(node.id); + Object.entries(this.selectedValues).forEach(([key, value]) => { - const existingValue = currentNode[this.field][key] || false; + const existingValue = currentNode[this.field]?.[key] || false; fieldValue[key] = existingValue || value.includes(node.id); }); + if (this.updateDescendants && node.kind === ContentKindsNames.TOPIC) { return this.updateContentNodeDescendants({ id: node.id, diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/__tests__/EditBooleanMapModal.spec.js b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/__tests__/EditBooleanMapModal.spec.js index e8a48355e1..428d41cad1 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/__tests__/EditBooleanMapModal.spec.js +++ b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/__tests__/EditBooleanMapModal.spec.js @@ -16,7 +16,6 @@ let generalActions; const CheckboxValue = { UNCHECKED: 'UNCHECKED', CHECKED: 'CHECKED', - INDETERMINATE: 'INDETERMINATE', }; const { translateMetadataString } = metadataTranslationMixin.methods; @@ -31,11 +30,9 @@ const getOptionsValues = wrapper => { const categories = {}; const checkboxes = wrapper.findAll('[data-test="option-checkbox"]'); checkboxes.wrappers.forEach(checkbox => { - const { label, checked, indeterminate } = checkbox.vm.$props || {}; + const { label, checked } = checkbox.vm.$props || {}; let value; - if (indeterminate) { - value = CheckboxValue.INDETERMINATE; - } else if (checked) { + if (checked) { value = CheckboxValue.CHECKED; } else { value = CheckboxValue.UNCHECKED; @@ -182,26 +179,6 @@ describe('EditBooleanMapModal', () => { expect(dailyLifeValue).toBe(CheckboxValue.CHECKED); expect(foundationsValue).toBe(CheckboxValue.CHECKED); }); - - test('checkbox option should be indeterminate if not all nodes have the same options set', () => { - nodes['node1'].categories = { - [Categories.DAILY_LIFE]: true, - [Categories.FOUNDATIONS]: true, - }; - nodes['node2'].categories = { - [Categories.DAILY_LIFE]: true, - }; - - const wrapper = makeWrapper({ nodeIds: ['node1', 'node2'] }); - - const optionsValues = getOptionsValues(wrapper); - const { - [Categories.DAILY_LIFE]: dailyLifeValue, - [Categories.FOUNDATIONS]: foundationsValue, - } = optionsValues; - expect(dailyLifeValue).toBe(CheckboxValue.CHECKED); - expect(foundationsValue).toBe(CheckboxValue.INDETERMINATE); - }); }); }); From b208530da2797d1d7ad1df23c91b8b39e4179b0b Mon Sep 17 00:00:00 2001 From: Allan Otodi Opeto <103313919+AllanOXDi@users.noreply.github.com> Date: Fri, 13 Sep 2024 17:01:39 +0300 Subject: [PATCH 7/7] minor clean up --- .../components/QuickEditModal/EditBooleanMapModal.vue | 3 --- 1 file changed, 3 deletions(-) diff --git a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue index 79c123c4ca..8738fdc71f 100644 --- a/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue +++ b/contentcuration/contentcuration/frontend/channelEdit/components/QuickEditModal/EditBooleanMapModal.vue @@ -31,9 +31,6 @@ :inputHandler="(value) => { selectedValues = value }" >