-
Notifications
You must be signed in to change notification settings - Fork 264
Undo the reverted changes in #4714 #4737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
AllanOXDi
merged 6 commits into
learningequality:unstable
from
AllanOXDi:bulk_editting-fix
Sep 17, 2024
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
35dcb4a
modified the canSave function to enableble saving of empty booleans
AllanOXDi e45d76c
clean up isCheckboxIndeterminate
AllanOXDi 7e80cf7
unused test
AllanOXDi 5d24098
clean up and lint
AllanOXDi 5f998c1
quick restore
AllanOXDi 55432b4
quick restore again
AllanOXDi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
|
|
||
| <template> | ||
|
|
||
| <KModal | ||
| :title="title" | ||
| :submitText="$tr('saveAction')" | ||
| :submitDisabled="!canSave" | ||
| :cancelText="$tr('cancelAction')" | ||
| data-test="edit-booleanMap-modal" | ||
| @submit="handleSave" | ||
|
|
@@ -11,6 +13,9 @@ | |
| <p v-if="resourcesSelectedText.length > 0" data-test="resources-selected-message"> | ||
| {{ resourcesSelectedText }} | ||
| </p> | ||
| <p v-if="hasMixedCategories" data-test="mixed-categories-message"> | ||
| {{ hasMixedCategoriesMessage }} | ||
| </p> | ||
| <template v-if="isDescendantsUpdatable && isTopicSelected"> | ||
| <KCheckbox | ||
| :checked="updateDescendants" | ||
|
|
@@ -26,9 +31,6 @@ | |
| :inputHandler="(value) => { selectedValues = value }" | ||
| ></slot> | ||
|
|
||
| <span v-if="error" class="red--text"> | ||
| {{ error }} | ||
| </span> | ||
| </KModal> | ||
|
|
||
| </template> | ||
|
|
@@ -45,6 +47,7 @@ | |
| import { mapGetters, mapActions } from 'vuex'; | ||
| import { ContentKindsNames } from 'shared/leUtils/ContentKinds'; | ||
| import { getInvalidText } from 'shared/utils/validation'; | ||
| import commonStrings from 'shared/translator'; | ||
|
|
||
| export default { | ||
| name: 'EditBooleanMapModal', | ||
|
|
@@ -91,16 +94,27 @@ | |
| */ | ||
| selectedValues: {}, | ||
| changed: false, | ||
| hasMixedCategories: false, | ||
| }; | ||
| }, | ||
| computed: { | ||
| ...mapGetters('contentNode', ['getContentNodes']), | ||
| ...mapGetters('contentNode', ['getContentNodes', 'getContentNode']), | ||
| nodes() { | ||
| return this.getContentNodes(this.nodeIds); | ||
| }, | ||
| isTopicSelected() { | ||
| return this.nodes.some(node => node.kind === ContentKindsNames.TOPIC); | ||
| }, | ||
| canSave() { | ||
| if (this.hasMixedCategories) { | ||
| return Object.values(this.selectedValues).some(value => value.length > 0); | ||
| } | ||
| return !this.error; | ||
| }, | ||
| hasMixedCategoriesMessage() { | ||
| // eslint-disable-next-line kolibri/vue-no-undefined-string-uses | ||
| return commonStrings.$tr('addAdditionalCatgoriesDescription'); | ||
| }, | ||
| }, | ||
| watch: { | ||
| selectedValues(newValue, oldValue) { | ||
|
|
@@ -121,6 +135,9 @@ | |
| }); | ||
|
|
||
| this.selectedValues = optionsNodes; | ||
| this.hasMixedCategories = Object.values(this.selectedValues).some( | ||
| value => value.length < this.nodes.length | ||
| ); | ||
| // reset | ||
| this.$nextTick(() => { | ||
AllanOXDi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| this.changed = false; | ||
|
|
@@ -147,19 +164,20 @@ | |
| } | ||
| }, | ||
| async handleSave() { | ||
| this.validate(); | ||
| if (this.error) { | ||
| return; | ||
| } | ||
|
|
||
| await Promise.all( | ||
| this.nodes.map(node => { | ||
| this.nodes.map(async node => { | ||
| const fieldValue = {}; | ||
| Object.entries(this.selectedValues).forEach(([key, value]) => { | ||
| if (value.includes(node.id)) { | ||
| const currentNode = this.getContentNode(node.id); | ||
AllanOXDi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // If we have mixed categories remain the old ones, and | ||
| // just add new categories if there are any | ||
| if (this.hasMixedCategories) { | ||
| Object.assign(fieldValue, currentNode[this.field] || {}); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we keep the comments here for future references. // If we have mixed categories remain the old ones, and
// just add new categories if there are any |
||
| } | ||
| Object.entries(this.selectedValues) | ||
| .filter(([value]) => value.length === this.nodeIds.length) | ||
AllanOXDi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .forEach(([key]) => { | ||
| fieldValue[key] = true; | ||
| } | ||
| }); | ||
| }); | ||
| if (this.updateDescendants && node.kind === ContentKindsNames.TOPIC) { | ||
AllanOXDi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| return this.updateContentNodeDescendants({ | ||
| id: node.id, | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.