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

Update WithHeadingFinder.php to fix heading fields for lens exports #155

Merged
merged 1 commit into from
Oct 26, 2023
Merged

Conversation

puzzledmonkey
Copy link
Contributor

@puzzledmonkey puzzledmonkey commented Nov 4, 2022

NOTE - This pull request is for the 1.2 branch because I am stuck on Nova 3 in the project I'm working on. The fix should be identical for 1.3 and 2.0 though.

When exporting from a lens, the WithHeaderFinder still uses a normal resource's index fields, instead of the lens fields. Therefore if you have any fields in the lens that are not in the index fields for the normal resource, the heading finder cannot locate them and falls back to the attribute name (eg field_name instead of Field Name)

This pull request simply uses the resourceFields (which are used for the export) to lookup the headings. This doesn't adversely affect a normal resource export because ExportResourceActionRequest uses indexFields in its resourceFields method, and it fixes ExportLensActionRequest to correctly locate the header names.

@patrickbrouwers
Copy link
Member

Can you provide a super simple User resource (based on default users_table in Laravel) and lens example for me to test with?

@puzzledmonkey
Copy link
Contributor Author

sure:

https://github.com/puzzledmonkey/lens-example

it should be self-explanatory (if highly contrived), but basically the issue is that, on the user lens, when downloading excel, the 'Is An Admin' column will have the header 'is_admin' instead of 'Is An Admin'. this is the issue that my patch fixes.

@puzzledmonkey
Copy link
Contributor Author

p.s. same issue and fix for v1.3 is here: #156

@puzzledmonkey
Copy link
Contributor Author

Can you provide a super simple User resource (based on default users_table in Laravel) and lens example for me to test with?

hey just checking if there's anything else you need from me here? thanks! :)

@patrickbrouwers patrickbrouwers merged commit aab5fdd into SpartnerNL:1.2 Oct 26, 2023
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.

2 participants