Skip to content

Add unassign confirmation to UserDetail page. - #3231

Open
somiaj wants to merge 1 commit into
openwebwork:developfrom
somiaj:user-detail-unassign-confirm
Open

somiaj wants to merge 1 commit into
openwebwork:developfrom
somiaj:user-detail-unassign-confirm

Conversation

@somiaj

@somiaj somiaj commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Update the displayed information on the user detail page.

  • State how many sets a user is assigned to out of the total number.
  • Change the "edit class list data" link to a button.
  • Only show the "Assign All sets to Current User" button if the user isn't assigned to all sets, and state the user's name instead of "Current User".
  • Remove all the warnings from the page. Add a statement that unchecking the "Assigned" checkbox will unassign a set and cannot be undone.
  • Call the table "Available Sets", as it contains more sets than the ones assigned to the user.

Add a confirmation modal that appears whenever a set is unchecked to require confirmation. This also adds a hidden field so the unassign on the server side will only unassign if that hidden field had been updated to true.

Add a check to see if any of the dates were actually changed, and only update the database entry in the case a change was made to avoid unneeded database calls.

There was some logic which I believe was trying to allow a set date to be "0", but it wasn't working, param('x') && param('x') ne '' was being used, which I think was meant to allow "0", so the logic should have been defined param('x') && param('x') ne '', but the method checkDates was already explicitly disallowing a "0" date. Except for the checkDates method, the logic was all simplified to just checking for the truth of param('x'), since "0" was being disallowed in the checkDates check anyways.

Add a hidden save submit button first (if showing the assign all button), so pressing enter in the form will be a save and not an assign all action.

@somiaj
somiaj force-pushed the user-detail-unassign-confirm branch 2 times, most recently from 29568ef to cb5d53c Compare October 6, 2026 18:10

@drgrice1 drgrice1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Just a couple of suggestions.

Could you fix the help file for this page. There is an ending parenthesis with no starting parenthesis on line 22 in the help text.

Comment thread htdocs/js/UserDetail/userdetail.js Outdated
// Check or uncheck assignment checkboxes for versioned sets and their template to make it clear to the user what
// the backend will do with their selections.
document.querySelectorAll('input[type="checkbox"][name^="set."][name$=".assignment"]').forEach((checkbox) => {
allCheckboxes.forEach((checkbox) => {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a clean up step that I have been trying to handle as the javascript files are modified. I want to eliminate most forEach usage. The only case where this is really beneficial is for a one liner such as the instance on line 23 in this file. The other cases should use a for (const ... of ...) { ... } loop instead. This is something that many style guides recommend because it is more readable.

You don't have to do this, but if you could it would be nice, and it isn't hard to do! So here this would become

Suggested change
allCheckboxes.forEach((checkbox) => {
for (const checkbox of allCheckboxes) {

and then remove the ); on line 27.

I would make the same change for the forEach calls added lines 45 and 51.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about line 45, should that be made a one liner or not (since you said it was an acceptable use)? I am guessing not because we are using the predefined allCheckboxes constant, and not appending that method to a query.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was going to say that line 45 could also be made a one liner instead of converting to a for .. of loop.

@somiaj
somiaj force-pushed the user-detail-unassign-confirm branch from cb5d53c to decf4b9 Compare October 13, 2026 18:40
Update the displayed information on the user detail page.
+ State how many sets a user is assigned to out of the total number.
+ Change the "edit class list data" link to a button.
+ Only show the "Assign All sets to Current User" button if the
  user isn't assigned to all sets, and state the user's name
  instead of "Current User".
+ Remove all the warnings from the page. Add a statement that
  unchecking the "Assigned" checkbox will unassign a set and
  cannot be undone.
+ Call the table "Available Sets", as it contains more sets
  than the ones assigned to the user.

Add a confirmation modal that appears whenever a set is unchecked
to require confirmation. This also adds a hidden field so the
unassign on the server side will only unassign if that hidden
field had been updated to true.

Add a check to see if any of the dates were actually changed, and
only update the database entry in the case a change was made to
avoid unneeded database calls.

There was some logic which I believe was trying to allow a set date
to be "0", but it wasn't working, `param('x') && param('x') ne ''`
was being used, which I think was meant to allow "0", so the logic
should have been `defined param('x') && param('x') ne ''`, but
the method `checkDates` was already explicitly disallowing a "0"
date. Except for the `checkDates` method, the logic was all
simplified to just checking for the truth of `param('x')`, since
"0" was being disallowed in the `checkDates` check anyways.

Add a hidden save submit button first (if showing the assign all
button), so pressing enter in the form will be a save and  not an
assign all action.
@somiaj

somiaj commented Oct 17, 2026

Copy link
Copy Markdown
Contributor Author

@drgrice1 Do we need to worry about escaping the username here? Or I assume all of Mojolicious helpers already do that? Just wanted to make sure the PRs that I've been using that print the user's first and last name didn't need additional escaping that was overlooked.

@somiaj
somiaj force-pushed the user-detail-unassign-confirm branch from decf4b9 to 26b6dba Compare October 17, 2026 14:36
@drgrice1

Copy link
Copy Markdown
Member

Where specifically are you referring to for escaping the username? If it is inside a <%= ... %> then it is escaped. If it is inside a <%== ... %> then it is not. So for the former case it is good, and for the latter it is not.

@drgrice1

Copy link
Copy Markdown
Member

From what I can see here, all are in <%= ... %>, so we are good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants