#36757: Optionally ignore change event in list view
-------------------------------------+-------------------------------------
Reporter: Jacob Rief | Type:
| Cleanup/optimization
Status: new | Component:
| contrib.admin
Version: dev | Severity: Normal
Keywords: list-view, change- | Triage Stage:
event | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
I am the author of the popular 3rd party library
https://github.com/jrief
/django-admin-sortable2 used in approximately 1.5% of all Django
installations. It is used to sort the entries in the list view of the
Django-Admin. There however is a problem: Whenever one reorders entries
and immediatly afterwards attemps to delete an entry, an alert message
pops up, warning the user about unsaved changes.
Please check this issue
https://github.com/jrief/django-admin-
sortable2/issues/397 for details.
The easiest solution to fix this would be to just ignore that change. By
applying this simple patch:
{{{
--- a/django/contrib/admin/static/admin/js/actions.js
+++ b/django/contrib/admin/static/admin/js/actions.js
@@ -151,7 +151,7 @@
updateCounter(actionCheckboxes, options);
lastChecked = target;
} else {
- list_editable_changed = true;
+ list_editable_changed = !target.classList.contains
('ignore-list-changes');
}
});
});
}}}
this issue can be solved without causing any harm to other applications. I
then would apply the CSS class `ignore-list-changes` to the `<tbody>`
before dragging an entry and remove it afterwards. Btw., a few lines
above, the CSS class `action-select` is used to prevent a similar use-
case, so this patch follows the same logic.
This patch can also be used by other 3rd party libraries which change
fields inside the list view and want to prevent such a warning message.
The class name `ignore-list-changes` is of course open for debate.
If this patch is accepted, I'll create a pull request.
--
Ticket URL: <
https://code.djangoproject.com/ticket/36757>
Django <
https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.