bhch / django-jsonform

A better, user-friendly JSON editing form field for Django admin. Also supports Postgres ArrayField.
https://django-jsonform.rtfd.io
BSD 3-Clause "New" or "Revised" License
307 stars 31 forks source link

Add button to open link in URLField #156

Closed WillNilges closed 4 months ago

WillNilges commented 4 months ago

I have a bit of an unusual use case for django admin. In my project, we track the hardware for internet installs, and as part of that, we have a Building Model that posesses an array of URLs that point to panoramic photos of the roof.

image

I can display them real nice in the panel like so, but I would like to add a button to each entry to allow me to open that link in a new tab. I'm considering just editing the template, but I am also wondering if there's a more elegant way to do so?

WillNilges commented 4 months ago

Doing a bit of research (just steam-of-conciousness) it looks like this is where the TextInput is added: https://github.com/bhch/django-jsonform/blob/master/django_jsonform/forms/fields.py#L92

Is there a way to override that in this library?

WillNilges commented 4 months ago

Oh wait, oops. This is built on top of https://github.com/bhch/react-json-form/ (!!), so to make that happen in the widget itself would require editing JS...

Probably somewhere around here: https://github.com/bhch/react-json-form/blob/master/src/ui.js#L170

bhch commented 4 months ago

Yeah, seems like a good UX feature to make a clickable link from the input values. I'll try to get it out in the next release.

bhch commented 4 months ago

Hello, just following up on this feature.

In your example image, are these inputs all URLFields within an ArrayField?

bhch commented 4 months ago

Released in v2.22.0. Please upgrade and test it out.

CSS improvements may come in a future release.

Thanks.