-
Notifications
You must be signed in to change notification settings - Fork 14
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
Only update affected media list when updating destination in HTMX frontend #1121
Conversation
a4325bf
to
fdfda05
Compare
f66e72e
to
5d0426b
Compare
Test results 10 files 1 060 suites 38m 23s ⏱️ Results for commit 34dd036. ♻️ This comment has been updated with latest results. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1121 +/- ##
==========================================
- Coverage 79.67% 79.62% -0.05%
==========================================
Files 141 141
Lines 5288 5292 +4
==========================================
+ Hits 4213 4214 +1
- Misses 1075 1078 +3 ☔ View full report in Codecov by Sentry. |
5d0426b
to
fe961ed
Compare
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.
Should also have a news fragment (could also be one for #1120 and this PR together), otherwise good
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.
Nice! See a RFC below
@@ -1,6 +1,7 @@ | |||
<form hx-post="{% url 'htmx:htmx-update' form.instance.id %}" | |||
hx-trigger="submit" | |||
hx-target="#form-list" | |||
hx-target="closest #update-delete-forms" |
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.
Having same id
on several HTML tags is a bad practice. We could either make an id of each form unique with something like update-delete-form-{{ media.name }}-{{ forloop.counter }}
, or put a class f.e. update-delete-form
on each form and target it as closest .update-delete-form
. The latter is easiest
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.
If prefix
is set when instantiating the form, it is available via {{form.prefix}}
. This can then be used to give the form itself an id. However, this also adds the prefix to every field-id (must be unique per page) and field-name, so that every form dealing with the same data must have the same prefix set. See #1118 for prefix-wrangling.
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 was changed to not rely on ID anymore, now it uses "closest detail", finding the closest collapse element
There will never be many destinations, a refresh of the entire page is also fine and will greatly simplify matters I suspect. |
1cccf5e
to
4e46505
Compare
31dcbda
to
02d7157
Compare
Changed PR to focus on updating the entire list and not just the row |
02d7157
to
5eded9e
Compare
5eded9e
to
34dd036
Compare
|
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.
Works nicely!
The only UX issue I see is that the error message on destination delete is shown not by the destination in question, but at the top of the media list which is confusing. But this issue was likely introduced in #1120 and not in this PR.
Fixes #1136
Makes it so only the related list for the destination you try to delete is updated with HTMX.