Merge pull request #13023 from frappe/mergify/bp/version-13-pre-release/pr-12999

feat(DX): sourceURL for injected javascript (backport #12999)
This commit is contained in:
Suraj Shetty 2021-04-28 18:37:30 +05:30 committed by GitHub
commit 20943d463d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -109,8 +109,9 @@ class FormMeta(Meta):
def _add_code(self, path, fieldname):
js = get_js(path)
if js:
self.set(fieldname, (self.get(fieldname) or "")
+ "\n\n/* Adding {0} */\n\n".format(path) + js)
comment = f"\n\n/* Adding {path} */\n\n"
sourceURL = f"\n\n//# sourceURL={scrub(self.name) + fieldname}"
self.set(fieldname, (self.get(fieldname) or "") + comment + js + sourceURL)
def add_html_templates(self, path):
if self.custom:
@ -145,6 +146,10 @@ class FormMeta(Meta):
if script.view == 'Form':
form_script += script.script
file = scrub(self.name)
form_script += f"\n\n//# sourceURL={file}__custom_js"
list_script += f"\n\n//# sourceURL={file}__custom_list_js"
self.set("__custom_js", form_script)
self.set("__custom_list_js", list_script)