fix(settings): render Attach field name when value is a dict#2470
Open
walidsaleh wants to merge 2 commits into
Open
fix(settings): render Attach field name when value is a dict#2470walidsaleh wants to merge 2 commits into
walidsaleh wants to merge 2 commits into
Conversation
The template assumed data[field.name] was a string and called .split on it. But frappe.get_doc().as_dict() serializes Attach / AttachImage fields as objects with file_url, file_name, etc. So the first time a user opened a settings modal that had a previously-saved Attach field, the template threw "TypeError: ... .split is not a function" and broke the entire modal (no save possible, no field editable). Guard against the non-string case by checking typeof first. If the value is a string, split and pop as before. If it is a dict (the as_dict round-trip case), use file_name. Falls back to empty string in the unlikely case neither shape matches. Fixes frappe#2417
Contributor
|
Hey, could you lint the code as per contribution guidelines: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix the generic
SettingFields.vuetemplate so it renders the file name of an Attach / AttachImage field even when the value is a dict (as returned byfrappe.get_doc().as_dict()), not just a string.This unblocks editing for any settings modal that uses
SettingFieldsand has a previously-saved Attach field, e.g.Payment Gateway.header_img,Website Settings.banner_image.Fixes #2417
Changes
One-line guard in
frontend/src/components/Settings/SettingFields.vue:63:Why
frappe.get_doc(...).as_dict()(used bylms.lms.api.get_payment_gateway_detailsand similar endpoints) serializes Attach / AttachImage fields as objects withfile_url,file_name,file_size, etc. The template was assuming a string and calling.splitunconditionally, which threw on the first open of any settings modal that had a saved Attach field, breaking the entire modal.Test plan