Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Suggestion: horizontal Tabs for inline (TabularInline, StackedInline) #295

Open
omargawdat opened this issue Feb 16, 2024 · 5 comments

Comments

@omargawdat
Copy link

first thanks for this awesome work, but it would be great if you consider enabling to display the inline admin as horizontal tabs instead of making it display vertically as when we have several inline models the data is got messed and be hard for navigation.

Current View:
image

Target View(as you can see there is bookings tab section so i can see all the user bookings)
image

@AlanL-django
Copy link

+1 for this.

I'm currently looking for a replacement for Suit in an old app that I'm modernising, and this for me is the #1 missing feature that prevents me choosing Unfold over Baton.

@omargawdat
Copy link
Author

+1 for this.

I'm currently looking for a replacement for Suit in an old app that I'm modernising, and this for me is the #1 missing feature that prevents me choosing Unfold over Baton.

Unfold stands out as the superior choice for Django admin panels, offering an extensive array of options alongside a visually attractive interface. The integration of this essential feature, pivotal for managing complex applications, would significantly enhance its utility and effectiveness, so hope they consider it.

@linuxipho
Copy link

Hi, and thanks for the great job already accomplished !
It would be nice to be able to only display Inline fieldset in a specific tab.
For now, I do it by playing with Alpine.js and template override, but a simple declaration like tab class in admin fieldsets would be wonderful !

@dacodekid
Copy link

Hi, and thanks for the great job already accomplished ! It would be nice to be able to only display Inline fieldset in a specific tab. For now, I do it by playing with Alpine.js and template override, but a simple declaration like tab class in admin fieldsets would be wonderful !

@linuxipho Would you plz share an example how you doing it?

@dacodekid
Copy link

The below idea works for me.

  1. Create an empty fieldset
class MODELAdmin(BaseAdminMixin):
    change_form_template = "admin/APP/MODEL/change_form.html"

    inlines = [SubModelInline]

    fieldsets = (
        ...
        ...
        
        (
            "INLINE TAB NAME",
            {
                "classes": ["tab"],
                "fields": (),
            },
        ),
    )

Add this JS that targets your SubModelInline's CSS class in your overridden template

{% extends "admin/change_form.html" %}
{% load i18n admin_urls admin_modify unfold static %}

{% block extrahead %}
    {{ block.super }}
    
    <script type="text/javascript">
    window.onload = function() {
        var inlineTab = document.querySelector('.tab-wrapper.fieldset-TAB_CLASS .aligned');
        var modelInline = document.getElementById('APP_NAME_MODELNAME-group');
        inlineTab appendChild(modelInline);
    };
    </script>
    
{% endblock %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants