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

Enhancement: MapField (from lat/long fields) #282

Open
sglebs opened this issue Aug 31, 2023 · 4 comments
Open

Enhancement: MapField (from lat/long fields) #282

sglebs opened this issue Aug 31, 2023 · 4 comments
Labels
enhancement New feature or request Fund

Comments

@sglebs
Copy link

sglebs commented Aug 31, 2023

I have an entity which has 2 float fields: latitude and longitude. I would like to render this as a map. Does it make sense / is it possible to use a synthetic MapField to CREATE/UPDATE/DELETE the 2 concrete fields containing latitude/longitude? Just like Dates get a nice Date Picker instead of text string, it would be cool if lat/long field pairs could get a map a la Google Maps. By dragging the map etc the lat/long would be updated.

Thanks for listening.

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • We receive the funding once the issue is completed & confirmed by you.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@sglebs sglebs added the enhancement New feature or request label Aug 31, 2023
@jowilf
Copy link
Owner

jowilf commented Sep 1, 2023

Thank for your suggestion. Feel free to submit a PR. You can check the JSONField implementation for reference

@sglebs
Copy link
Author

sglebs commented Sep 4, 2023

I am studying https://jowilf.github.io/starlette-admin/advanced/custom-field/#detail-page and it seems to take only 1 field:

field: Your field instance
data: value to display

In my case, I want to build a "composite field": given N fields, show as one. lat/long as Map is an obvious one. Another obvious one is to have a single "full address" field from N columns (country/state/city,street name and number).

So, I guess the more general issue is: how can "composite fields" be added to starlet-admin?

Maybe field could potentially be a collection of fields?

@sglebs
Copy link
Author

sglebs commented Sep 4, 2023

In reality we are talking about a synthetic field, computed from N fields from the entity. I may want to show raw lat&long as floats AND ALSO an interactive map widget, computed from these 2 values. I guess I want a field where I pass the whole row/entity, and not just 1 attributes. Is that supported?

@jowilf
Copy link
Owner

jowilf commented Sep 5, 2023

You can override the BaseField.parse_obj function to handle it

@polar-sh polar-sh bot added the Fund label Oct 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Fund
Projects
None yet
Development

No branches or pull requests

2 participants