-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add label reordering #1130
Add label reordering #1130
Conversation
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.
Looks good!
I wonder though if it would be a good idea to add both a "Before" and "After" field, with validation that you can only provide one or the other. Technically you could do everything using "After", but if you want a fresh tag to be at the top you'd have to move all the other tags to be after it, so a tag list with 10 tags would require 9 operations to move a fresh tag to the top. This may be something we can wait on user feedback about to see if its really necessary.
# Conflicts: # hawc/apps/assessment/templates/assessment/fragments/label_edit_row.html # hawc/apps/assessment/templates/assessment/label_list.html
# Conflicts: # hawc/apps/assessment/templates/assessment/fragments/label_row.html
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.
Looks great. I really like the hx-retarget trick where we design the html templates for the happy case but fallback to form replacement on error, really nice work.
I learned something new today!
hawc/apps/assessment/views.py
Outdated
context = self.get_context_data(form=form, **kwargs) | ||
response = render(request, template, context) | ||
if retarget_form: | ||
response["HX-Retarget"] = "#label-edit-row-" |
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.
didn't know about this, thanks, so basically on success it uses the target in the template, but if there's a form validation error it retargets and replaces itself.
a CSS selector that updates the target of the content update to a different element on the page
I tried switching to after and it worked, but then I had a hard time with the wording for the form, I felt like the current approach was clearer to the user, even it it make require more edits. That's ok, I'd imagine that sorting is done rarely. |
Add the ability to optionally reorder labels "after" other sibling labels.