piccolo-orm / piccolo_admin

A powerful web admin for your database.
https://piccolo-orm.com/ecosystem/
MIT License
316 stars 37 forks source link

When the id field is hidden in TableConfig, there is no way to edit a record #266

Closed metakot closed 1 year ago

metakot commented 1 year ago

So we have an UUID primary keys and want to hide them in admin, but that's happens:

image

It would be cool if the record link field was parameterized in TableConfig

dantownsend commented 1 year ago

Ah, yes - that's a good idea. Like you say, we could add something to TableConfig.

sinisaos commented 1 year ago

@metakot Even if you hide the primary key in TableConfig, you can edit and delete a record from the record dropdown menu. edit

dantownsend commented 1 year ago

@sinisaos That's a good point - I didn't think of that.

I think it would be cool if the user could specify which column is the link. Depends how tricky it is.

sinisaos commented 1 year ago

@dantownsend We already have a nice edit and delete dropdown (even for a hidden field) and I think that's enough. Honestly, I don't know how to provide a link for a field that we don't render in template. https://github.com/piccolo-orm/piccolo_admin/blob/a90ccf1f784696f3bc94a743ca38976542015b2c/admin_ui/src/views/RowListing.vue#L426-L430

dantownsend commented 1 year ago

@sinisaos I think what we'd do is imagine it's a User table. They can hide the id column, and make the name column the link (the name would have to be visible, otherwise it wouldn't work).

sinisaos commented 1 year ago

@dantownsend But crud operations are based on the primary key of the record and you need to provide that primary key (as hidden field) to the column you want to make as link. As you wish, but I think what we had now is enough.

dantownsend commented 1 year ago

@sinisaos Ah, good point.

metakot commented 1 year ago

Well, django has that. If the field is hidden it doesn't mean that it isn't involved in crud operations. The UUID primary key is just ugly but a lot of people using it.

sinisaos commented 1 year ago

@metakot Yes, you are right about Django. We could try to do something similar so that the first visible column is always a crud link, whether it's the primary key or some other column. I will try to do something during the day.

sinisaos commented 1 year ago

Actually, in order to achieve this, we need a small code change so that if the primary key is hidden, we use the first visible column as crud link.

https://user-images.githubusercontent.com/30960668/209439334-f6fc7f59-4c60-4196-8892-74ea50315be9.mp4

@dantownsend and @metakot if you agree with this I can make a PR.

metakot commented 1 year ago

Yeah, the first visible one is alright!

dantownsend commented 1 year ago

This is fixed in v0.43.0

https://github.com/piccolo-orm/piccolo_admin/releases/tag/0.43.0