django-jazzmin icon indicating copy to clipboard operation
django-jazzmin copied to clipboard

Support for inline/fieldsets collapse

Open doolijb opened this issue 3 years ago • 6 comments
trafficstars

There currently isn't support for collapsing inline models. i.e. classes = ['collapse'] results in the objects disappearing entirely.

doolijb avatar Feb 02 '22 06:02 doolijb

Collapse has no effect on fieldsets, i.e.

fieldsets = (
        ('General', {
            'fields': ('foo', 'bar',),
            'classes': ('collapse',),
        }),
    )

doolijb avatar Feb 04 '22 05:02 doolijb

Which changeform_format are you using within your JAZZMIN_SETTINGS ? the default one horizontal_tabs ? or one of the others ?

on a seperate note, I dont see fieldset classes coming through on all changeforms, so I've got a PR up to address that See https://github.com/farridav/django-jazzmin/pull/375

But id need to understand your use case a little bit more to know if it helps..

farridav avatar Feb 12 '22 14:02 farridav

Mostly using horizontal_tabs I'll be using collapse in several fieldsets, but primarily right now, looking to collapse some large inline models.

  class VersionInlineAdmin(admin.StackedInline):
      model = Version
      # fieldsets = (
      #     ('General', {
      #         'fields': ('foo', 'bar',),
      #         'classes': ('collapse',),
      #     }),
      # )

doolijb avatar Feb 16 '22 19:02 doolijb

Tested this manually by adding:

<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button> to the "card-header" div, like so:

<div class="card-header">
<button type="button" class="btn btn-tool" data-card-widget="collapse"><i class="fas fa-minus"></i></button>
...</div>

It appears as if the button needs to be added to the card header.

AdminLTE reference

Presumably this needs to be added to the stacked inline template, around line 13, in the <div class="card-header"> element.

RedRubicon avatar Sep 15 '22 11:09 RedRubicon

I have same observation, Setting 'classes': ('collapse',), in admin fieldsets does nothing. I'm using changeform_format set to single.

Dom4n avatar Feb 07 '23 11:02 Dom4n

similar observations about inlines model, when you set settings classes = ['collapse'], you could observe browser console logs

collapse.js:17 Uncaught TypeError: Cannot read properties of null (reading 'appendChild')
    at collapse.js:17:20
(anonymous) @ collapse.js:17
load (async)
(anonymous) @ collapse.js:4

image

mrvini avatar Feb 14 '23 05:02 mrvini