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

TabularInline: use one row per object (instead of two) to facilitate sorting #683

Open
marcpicaud opened this issue Aug 15, 2024 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@marcpicaud
Copy link
Contributor

marcpicaud commented Aug 15, 2024

Is it a third party application feature request?

No

Describe your feature request

Unfold's TabularInline template creates 2 rows per object (1 for the name, 1 for the fields) :

image

Django's TabularInline creates 1 row per object

image

This is not really a bug per se, but all 3rd party plugins offering a sortable functionality are expecting 1 row per object, and thus they are not compatible with Unfold. Wouldn't it be better to stick with native Django's structure ?

Possible solutions

  • Refactor Unfold TabularInline's template so that the object name is included in the same row as the fields
  • Implement a sortable feature in Unfold ?

Let me know what you think, I could draft a PR for either

@lukasvinclav
Copy link
Contributor

lukasvinclav commented Aug 19, 2024

The reason why I put title to separate line was because of long titles. Sometimes when the title is really long it completely expanded the size of first column. Which third party plugin are you using for sorting?

@marcpicaud
Copy link
Contributor Author

For example, this plugin: https://github.com/matthiask/django-admin-ordering

I just tried native Django and a very long title. The approach Django uses to handle this is:

  • The title is placed inside a table cell (<td>).
  • The cell's width is set to 0.
  • The title itself is wrapped in a child paragraph (<p>), which is styled with position: absolute
  • The rest of the row is displayed with a padding-top to offset the title's height.
Screenshot 2024-08-19 at 21 22 41

@marcpicaud marcpicaud changed the title TabularInline: use one row per object (instead of two) to facilitable sorting TabularInline: use one row per object (instead of two) to facilitate sorting Aug 19, 2024
@lukasvinclav
Copy link
Contributor

Yeah, I see it now. If you can draft a PR, I will be happy to review it.

Regarding sorting functionality, I will try to take a look and prepare built-in MVP directly in Unfold without any third party dependencies.

@lukasvinclav
Copy link
Contributor

@marcpicaud are you willing to take a look on it and draft a PR fixing multiple rows per one record?

@marcpicaud
Copy link
Contributor Author

@lukasvinclav
Yes, sir ! Apologies for the delay, I've been quite busy lately. Will keep you posted by next week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants