-
Notifications
You must be signed in to change notification settings - Fork 163
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
Fix save quick edit modals #4742
Merged
AllanOXDi
merged 3 commits into
learningequality:unstable
from
AlexVelezLl:fix-save-quick-edit-modal
Sep 19, 2024
Merged
Changes from all commits
Commits
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 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 |
---|---|---|
|
@@ -107,7 +107,9 @@ | |
}, | ||
canSave() { | ||
if (this.hasMixedCategories) { | ||
return Object.values(this.selectedValues).some(value => value.length > 0); | ||
return Object.values(this.selectedValues).some( | ||
value => value.length === this.nodes.length | ||
); | ||
} | ||
return !this.error; | ||
}, | ||
|
@@ -174,7 +176,7 @@ | |
Object.assign(fieldValue, currentNode[this.field] || {}); | ||
} | ||
Object.entries(this.selectedValues) | ||
.filter(([value]) => value.length === this.nodeIds.length) | ||
.filter(entry => entry[1].length === this.nodeIds.length) | ||
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. Great catch! On correcting the filter. Changing the check to |
||
.forEach(([key]) => { | ||
fieldValue[key] = true; | ||
}); | ||
|
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The updated condition now ensures saving is only allowed when the selected values cover all nodes , which makes validation more robust. What would happen if partial selections are ever needed in other scenarios? maybe we might want to consider making this condition more flexible?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey! The thing is that "partial selections" just only serve to determine if we have mixedCategories, but the user doesnt see nor interact with any of these partial selections. For them they dont exists, so thats why we cant depend on them, and rather depend on what they are seeing which is selected options, and we have selected options when we have that
value.length === this.nodes.length
.If we keep the condition of
value.length > 0
then we will be taking these mixed options as valid values. So if I have for example 2 nodes:Node 1:
Node 2:
Then when we open the modal, we will see the mixed options comment, but we wont see any of the options selected, because we dont have any option selected across all nodes, and we wont see any indeterminate state as they dont exist anymore, the only the user will se will be all checkboxes unchecked. But the user will still see the save button enabled, because
canSave = true
because all category A and B havevalue.length > 0
, and this is an error, as we are not meeting the 4th acceptance criteria mentioned in #4651:So, no, we cant have a more flexible condition as this condition does not met the requirements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for explaining the reasoning behind the stricter condition.