Opened 14 years ago
Last modified 9 months ago
#15220 new Cleanup/optimization
replace SelectFilter2.js with a jQuery plugin
Reported by: | Nick Sandford | Owned by: | |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | cmawebsite@…, ben@…, Ülgen Sarıkavak | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | yes |
Easy pickings: | no | UI/UX: | yes |
Description
I needed to extend the functionality of the select filter, so I rewrote it in jQuery. I noticed a discussion about replacing some of the admin javascript with jQuery, so this is a first attempt at replacing SelectFilter2.js
with jquery.selectfilter.js
.
Discussion is here: http://groups.google.com/group/django-developers/browse_thread/thread/ff460085a3bfb12e/2c4e6f5a9807c19b?lnk=gst&q=jquery#2c4e6f5a9807c19b
Attachments (3)
Change History (25)
by , 14 years ago
Attachment: | selectfilter-widget-r15403.diff added |
---|
comment:1 by , 14 years ago
Patch needs improvement: | set |
---|---|
Triage Stage: | Unreviewed → Accepted |
comment:3 by , 14 years ago
The instantiation code could probably be a bit cleaner without the anonymous function, but it won't change it too much. It was mostly to avoid typing django.jQuery(etc..) twice (once for the document.ready and a second time for invoking the plugin)..
I'll upload a patch to fix the TODO shortly. Cheers.
by , 14 years ago
Attachment: | selectfilter-widget-2-r15426.diff added |
---|
comment:4 by , 14 years ago
I think BoundField
has an auto_id
property but I'm not sure how to go about using it, so I'm hoping the approach I took was ok (using attrs.get('id', 'id_%s' % name)
).
comment:5 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → Cleanup/optimization |
comment:6 by , 14 years ago
UI/UX: | set |
---|
comment:7 by , 14 years ago
Easy pickings: | unset |
---|---|
Owner: | changed from | to
by , 14 years ago
Attachment: | 15220-selectfilter-r16355.patch added |
---|
comment:8 by , 14 years ago
Patch needs improvement: | unset |
---|
I updated the original patch so it will apply cleanly to trunk, and also made some improvements:
Improved coding-style
- moved from leading spaces to tabs
- removed trailing comma's (fixes IE support)
Usability improvements
- removed inconsistent 'wrap-around' functionality in selects
- also allow moving back from 'selected' to 'choices'
- only allow moving with right or left key when the layout is horizontal (it doesn't make sense when layout is vertical)
- fixed keyboard shortcuts (didn't work at all in the trunk version)
I tested it all in IE7, IE8, FF4, Safari, Chrome, and it works like a charm.
comment:9 by , 14 years ago
This looks good to me, but I also lack the JS-foo to vet every line of the JS.
This would be an excellent candidate for figuring out a more standardized means of testing. Could be QUnit, could be Selenium, could be both. I'd feel more comfortable with JS changes like these if I had a test suite to run on them.
comment:10 by , 13 years ago
FWIW, selenium tests have now landed in the admin, so this should be much easier to test.
comment:12 by , 13 years ago
FYI, while working on #13614, I've used the latest patch from here and brought it up to date with current trunk.
comment:13 by , 13 years ago
Patch needs improvement: | set |
---|
comment:14 by , 13 years ago
We'll do this shortly after 1.4 gets released, based on the patch in #13614.
comment:15 by , 11 years ago
I closed #3202 as a duplicate which points out the inability of the current implementation to handle large lists. We should make sure new solution improves this.
comment:16 by , 10 years ago
Cc: | added |
---|
comment:17 by , 10 years ago
Cc: | added |
---|
comment:18 by , 9 years ago
PR 4701 is the latest effort on this if someone is interested in updating it.
comment:19 by , 7 years ago
This is basically fixed now that we can use select2 for many-to-many fields. Once it's been around for a while we could try changing UserAdmin to use select2 by default instead of SelectFilter2.js.
comment:20 by , 3 years ago
Owner: | removed |
---|---|
Status: | new → assigned |
comment:21 by , 3 years ago
Status: | assigned → new |
---|
comment:22 by , 9 months ago
Cc: | added |
---|
This needs to be reviewed by someone with better JS-foo than I have, but two initial impressions: