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

Fix searchFormat not working for DateField & TimeField #68

Merged
merged 4 commits into from
Dec 29, 2022

Conversation

ihuro
Copy link
Contributor

@ihuro ihuro commented Dec 27, 2022

Copy the model.fields list before apply the shift function to keep original values un the model object. Otherwise, other functions cannot find fields attributes. For example, the extraction of the search_format in https://github.com/jowilf/starlette-admin/blob/main/starlette_admin/statics/js/list.js#L164 does not work.

Copy the model.fields list befor apply the shift function to keep original values un the model object. Otherwise, other functions cannot find fields attributes.
@jowilf
Copy link
Owner

jowilf commented Dec 29, 2022

Hello @ihuro,
Thank you for the catch but your solution doesn't deep copy nested fields

Using `structuredClone` to deep copy `model.fields` in `list.js`
Added a simple non-performant replacement of `structuredClone` for old browsers
@ihuro
Copy link
Contributor Author

ihuro commented Dec 29, 2022

Hello @ihuro, Thank you for the catch but your solution doesn't deep copy nested fields

I've updated the PR with a new proposal.
The function structuredClone is supported in newer browsers versions https://developer.mozilla.org/en-US/docs/Web/API/structuredClone#browser_compatibility

@jowilf
Copy link
Owner

jowilf commented Dec 29, 2022

Thank you for your contribution

@codecov
Copy link

codecov bot commented Dec 29, 2022

Codecov Report

Base: 100.00% // Head: 100.00% // No change to project coverage 👍

Coverage data is based on head (fbc1ae7) compared to base (4b27bcc).
Patch has no changes to coverable lines.

❗ Current head fbc1ae7 differs from pull request most recent head 3d732c5. Consider uploading reports for the commit 3d732c5 to get more accurate results

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #68   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           54        54           
  Lines         3891      3891           
=========================================
  Hits          3891      3891           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@jowilf jowilf changed the title Avoid get an empty model.fields list Fix searchFormat not working for DateField & TimeField Dec 29, 2022
starlette_admin/statics/js/utils.js Outdated Show resolved Hide resolved
@jowilf jowilf merged commit 9a2b8c1 into jowilf:main Dec 29, 2022
@ihuro ihuro deleted the patch-1 branch December 29, 2022 15:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants