-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
163f1cc
commit ff34e20
Showing
4 changed files
with
28 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
26 changes: 23 additions & 3 deletions
26
landa/water_body_management/doctype/water_body_rules/water_body_rules.js
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,28 @@ | ||
// Copyright (c) 2023, ALYF GmbH and contributors | ||
// For license information, please see license.txt | ||
|
||
frappe.ui.form.on('Water Body Rules', { | ||
// refresh: function(frm) { | ||
frappe.ui.form.on("Water Body Rules", { | ||
refresh: function (frm) { | ||
frm.add_custom_button(__("Toggle HTML"), function () { | ||
frm.trigger("toggle_html"); | ||
}); | ||
}, | ||
toggle_html: function (frm) { | ||
for (let fieldname of ["water_body_rules", "privacy_policy", "imprint"]) { | ||
let df = frm.fields_dict[fieldname].df; | ||
|
||
// } | ||
// overwrites Code formatter defined in apps/frappe/frappe/public/js/frappe/form/formatters.js | ||
df.formatter = df.read_only ? undefined : format_html; | ||
frm.set_df_property(fieldname, "fieldtype", df.read_only ? "HTML Editor" : "Code"); | ||
frm.set_df_property(fieldname, "options", df.read_only ? "" : "HTML"); | ||
frm.set_df_property(fieldname, "read_only", !df.read_only); | ||
} | ||
} | ||
}); | ||
|
||
// modifies Code formatter defined in apps/frappe/frappe/public/js/frappe/form/formatters.js | ||
// to pretty print HTML | ||
function format_html(value, df) { | ||
const _value = df.options == "HTML" ? html_beautify(value) : value; | ||
return "<pre>" + (_value == null ? "" : $("<div>").text(_value).html()) + "</pre>"; | ||
} |