django-admin-interface icon indicating copy to clipboard operation
django-admin-interface copied to clipboard

Add option for remember fieldsets.collapse state (visible/hidden).

Open fabiocaccamo opened this issue 2 years ago • 8 comments

Fund with Polar

fabiocaccamo avatar May 06 '22 12:05 fabiocaccamo

Hello, I can help with a PR for this issue, is that ok or is it already assigned?

luciano-im avatar Jul 18 '23 12:07 luciano-im

@luciano-im this issue is not assigned, any contribution is appreciated!

fabiocaccamo avatar Jul 18 '23 13:07 fabiocaccamo

Hi Fabio, to identify each fieldset with a name to handle its state, one option is to add a data attribute to each fieldset with the name suggested in issue #173: {app_name}-{model_name}-{fieldset_name}. To achieve this, I need to include a copy of templates/admin/includes/fieldset.html to override it. Is this a good idea? I'm thinking if this could be a problem if Django changes this file in future releases?

If it's possible to override fieldset.html file, then in static/admin/js/collapse.js I could get and set the state of each rendered fieldset.

What do you think?

luciano-im avatar Jul 19 '23 20:07 luciano-im

Hi @luciano-im, I understand the problem, an alternative could be to add the data attribute dynamically using js without overriding the default admin template. What do you think about this solution and its pro and cons?

Actually there are already some admin templates that gets overridden and frankly I'm a bit worried about potential problems in future releases, but once #301 will be done, this will be no more a big problem.

fabiocaccamo avatar Jul 20 '23 08:07 fabiocaccamo

I understand clearly. Let me see if I can find a javascript solution so that the default template doesn't need to be overridden.

luciano-im avatar Jul 20 '23 18:07 luciano-im

@luciano-im any update?

fabiocaccamo avatar Aug 29 '23 07:08 fabiocaccamo

Hi @fabiocaccamo, I'm sorry but I've been busy and I couldn't finish the pull request. Next week I will be working on this again.

luciano-im avatar Aug 30 '23 11:08 luciano-im

@luciano-im no problem, thank you for the update!

fabiocaccamo avatar Aug 30 '23 11:08 fabiocaccamo

@luciano-im I close this as it is stale, I will be glad to re-open it if needed.

fabiocaccamo avatar Feb 19 '24 17:02 fabiocaccamo