-
Notifications
You must be signed in to change notification settings - Fork 280
Description
Do you have any examples?
Current implementation example from our codebase:
"TABS": [{
"models": [{
"name": "myapp.company",
"detail": True,
}],
"items": [
{
"title": _("Company"),
"link": lambda request: f"/admin/myapp/company/{request.resolver_match.kwargs.get('object_id')}/change/",
"permission": user_is_admin,
},
{
"title": _("Products"),
"link": lambda request: f"/admin/myapp/company/{request.resolver_match.kwargs.get('object_id')}/products/",
"permission": user_is_admin,
},
],
}]
This has a few advantages, including that you could link to something, and that when you submit a single tab, it doesn't have to submit all the tabs, potentially overwriting changes others did in other tabs while you had the page open and/or forcing you to fix any validation issues in all the tabs and so on.
I wanted to do this, because I essentially wanted a tab to link to a different admin, but fieldset tabs seem to get overwritten by settings unfold tabs. That's a separate thing that could be improved (if you can combine the two tab lists or something).
This works for edit, but when you click "add" the tabs still show, which won't work since incorrectly appearing on /add/
view where object_id
is None
, making links broken.
Is it a third party application feature request?
No?
In case of third party application, when it was updated last time?
N/A
Describe your feature request
The main issue here, is that unfold supports something like this for a tab:
"models": [{
"name": "myapp.company",
"detail": True,
}],
But I'm not sure of any usecases where that's very useful, given that you probably need the ID in the URL for those tabs (since this is object detail), but there's no easy way to make those tabs not show on the add page where you don't have an object and therefore no ID to link to some related detail page.
- Make it so unfold settings defined "TABS" for a model with
"detail": True
don't show on the "Add" form for that model. Or add a way to exclude them from add
- (Optional) Or add a way for fieldset tabs to act as separate forms (clicking between them may warn to save changes).
- (Optional) Make link resolution that includes the ID easier.
- (Optional) Make it so you can have some fieldset tabs, while also supporting link tabs in some way. (It may make sense to ensure they get a warning when clicking a tab that will leave the current page loosing form progress if changes have been made).
Another think that could have helped my admittedly odd use case, would be a way to do a fieldset tab that uses a