-
Notifications
You must be signed in to change notification settings - Fork 699
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
number of resources updates on selection #11825
number of resources updates on selection #11825
Conversation
Build Artifacts
|
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.
Key changes that are needed for merge:
- The first number of the "x of y resources selected" string needs to be updated per my comments
- Clean up unused commented code
- Remove side-effects code from the
isSelectAllChecked
computed property
One thing that is not asked for in the original issue but that I've noted below which would be helpful here is:
- Update the behavior when the user is unselecting-all so that instead of wiping the user's changes, we just remove the selectable items in the content list from the working resource pool
// }, | ||
selectionMetadata(content) { | ||
if (content.kind === ContentNodeKinds.TOPIC) { | ||
const count = this.workingResourcePool.length; |
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.
This is making it so that every card shows the same # of resources selected out of however many children there are. For example, the QA Channel's QTI folder has 3 resources in it, but when I select 4 resources from the CK12 folder the QTI card says "4 of 3 resources selected"
This should instead be using the ancestor(s)
property on the items in the workingResourcePool where basically count
should be "the number of items in the working resource pool who has this topic as an ancestor".
// selectionMetadata(content) { | ||
// console.log(content); |
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.
All of this commented out stuff can be removed
if (this.contentList.every(content => workingResourceIds.includes(content.id))) { | ||
this.contentList.forEach(resource => { | ||
if (resource.kind === ContentNodeKinds.TOPIC) { | ||
this.addToWorkingResourcePool(resource.children.results); | ||
} | ||
}); | ||
return true; | ||
} else { | ||
return false; | ||
} |
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.
Lines 278-282 here seem out of place. Since isSelectAllChecked
is supposed to just be a Boolean computed property, it can get really hairy if we introduce a side effect here like adding items to the resource pool.
This logic probably belongs below in the method we're passing as the handler function for the @changeselectall
event on the ContentCardList
. I'll add some more thoughts there.
|
||
if (this.contentList.every(content => workingResourceIds.includes(content.id))) { | ||
this.contentList.forEach(resource => { | ||
if (resource.kind === ContentNodeKinds.TOPIC) { |
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.
I think that maybe this logic is altogether not necessary here. It seems like you're aiming to handle the user's "select all" click while also including all of the folders' children in that "Select all".
The logic for "selecting folders" can be handled in a separate issue, so this should be reverted to the return this.contentList.every(...)
.
One thing to bear in mind is that even when we do allow users to select folders, the only time we'll place all of the topic's children into the working resource list is if that folder meets the criteria for having a checkbox in the first place as defined in #11790
this.addToWorkingResourcePool(this.contentList); | ||
} else { | ||
this.isSelectAllChecked = false; |
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.
Removing the setting of isSelectAllChecked
here is good as it's a computed property.
In my note on that isSelectAllChecked
property I mentioned that the side-effects of manipulating the working resource pool should probably be moved here.
In the else
block here, however, rather than resetWorkingResourcePool
this should instead remove all items in the content list from the working resource pool. resetWorkingResourcePool
just undoes all changes the user has made since opening the panel, which is not desired here.
In this case, you'd need to do a this.contentList.forEach(content => this.removeFromWorkingResourcePool(content))
(or something along those lines -- you'll probably also want to be sure to filter out Topics as we aren't permitting full topic selection until #11790 is implemented)
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.
Changes here look good thanks @AllanOXDi - let's find a time to jump on a call to clean up the conflicts so we can get it merged!
72feca2
to
9e9cc2b
Compare
b0865cb
to
ffee918
Compare
Summary
closes Quiz Creation Select Resources - Display proper count & ancestor counts on the card. #11784
References
#11784
Reviewer guidance
Testing checklist
PR process
Reviewer checklist
yarn
andpip
)