Opened 7 years ago

Closed 4 years ago

#7009 closed Bug (fixed)

Fix for hide/collapse of fieldsets in admin when fieldsets are added dynamically

Reported by: punteney Owned by: nobody
Component: contrib.admin Version: master
Severity: Normal Keywords: javascript collapsing fieldsets
Cc: punteney@…, email@… Triage Stage: Design decision needed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

Currently in CollapsedFieldsets.js when it's initialized it gets gets an array of the fieldsets on the pages and then for the ones that are expand/contract it passes the the index number of that array to the onclick function to determine what fieldset should be displayed or hidden. Then in the show and hide function it queries the document again for all the fieldsets and selects the appropriate one based on the fieldset_index that was passed on to it. This breaks if a fieldset is dynamically added or removed from the page after the initialization as the array of fieldsets is now a different length (in my case it's an option to toggle the YUI rich text editor on or off that causes the problem to occur).

The attached patch changes it so an id is created for the fieldset if it doesn't have one and then the id is passed along with the fieldset_index to the show and hide functions. The correct fieldset is then found through the document.getElementById so as to be always be the correct one even if fieldsets are added or removed.

Attachments (1)

collapsedFieldsets_by_id.diff (3.6 KB) - added by punteney 7 years ago.
Updated patch for the nfa (changing "berror" to "berrors")

Download all attachments as: .zip

Change History (9)

comment:1 Changed 7 years ago by punteney

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Updated patch to include passing the fieldset id to the show function from within the uncollapse_all function as well.

comment:2 Changed 7 years ago by flosch

  • Cc email@… added

comment:3 Changed 7 years ago by ericholscher

  • milestone set to 1.0 maybe
  • Triage Stage changed from Unreviewed to Design decision needed

Changed 7 years ago by punteney

Updated patch for the nfa (changing "berror" to "berrors")

comment:4 Changed 7 years ago by jacob

  • milestone changed from 1.0 maybe to post-1.0

comment:5 Changed 6 years ago by anonymous

  • milestone post-1.0 deleted

Milestone post-1.0 deleted

comment:3 Changed 4 years ago by julien

  • Severity set to Normal
  • Type set to Bug

comment:4 Changed 4 years ago by julien

  • UI/UX set

comment:5 Changed 4 years ago by Alex

  • Easy pickings unset
  • Resolution set to fixed
  • Status changed from new to closed

I dont' think any of this is valid, following Zain's GSOC to add dynamic fieldsets to django's admin directly.

Note: See TracTickets for help on using tickets.
Back to Top