From ac0e46669d7e2eeffa871045010a90ea4032caf9 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 9 Aug 2024 13:49:09 +0200 Subject: [PATCH] fix: spec preview fields statically on the frontend --- .../email/doctype/notification/notification.js | 11 +++++++++-- .../email/doctype/notification/notification.py | 8 -------- frappe/integrations/doctype/webhook/webhook.js | 16 ++++++++++++---- frappe/integrations/doctype/webhook/webhook.py | 9 --------- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/frappe/email/doctype/notification/notification.js b/frappe/email/doctype/notification/notification.js index 5a7c8394a2..c11a0ec3a3 100644 --- a/frappe/email/doctype/notification/notification.js +++ b/frappe/email/doctype/notification/notification.js @@ -164,7 +164,6 @@ frappe.ui.form.on("Notification", { }, }; }); - frm.preview_fields = frm.doc.__onload.preview_fields; }, refresh: function (frm) { frappe.notification.setup_fieldname_select(frm); @@ -185,7 +184,15 @@ frappe.ui.form.on("Notification", { const args = { doc: frm.doc, doctype: frm.doc.document_type, - preview_fields: frm.preview_fields, + preview_fields: [ + { + label: __("Meets Condition?"), + fieldtype: "Data", + method: "preview_meets_condition", + }, + { label: __("Subject"), fieldtype: "Data", method: "preview_subject" }, + { label: __("Message"), fieldtype: "Code", method: "preview_message" }, + ], }; let dialog = new frappe.views.RenderPreviewer(args); return dialog; diff --git a/frappe/email/doctype/notification/notification.py b/frappe/email/doctype/notification/notification.py index 0e8a7bd4c1..2e7159d47b 100644 --- a/frappe/email/doctype/notification/notification.py +++ b/frappe/email/doctype/notification/notification.py @@ -73,14 +73,6 @@ class Notification(Document): """load message""" if self.is_standard: self.message = self.get_template() - self.set_onload( - "preview_fields", - [ - {"label": _("Meets Condition?"), "fieldtype": "Data", "method": "preview_meets_condition"}, - {"label": _("Subject"), "fieldtype": "Data", "method": "preview_subject"}, - {"label": _("Message"), "fieldtype": "Code", "method": "preview_message"}, - ], - ) def autoname(self): if not self.name: diff --git a/frappe/integrations/doctype/webhook/webhook.js b/frappe/integrations/doctype/webhook/webhook.js index 168b4be446..38aed089f5 100644 --- a/frappe/integrations/doctype/webhook/webhook.js +++ b/frappe/integrations/doctype/webhook/webhook.js @@ -79,9 +79,6 @@ frappe.webhook = { }; frappe.ui.form.on("Webhook", { - onload: (frm) => { - frm.preview_fields = frm.doc.__onload.preview_fields; - }, refresh: (frm) => { frappe.webhook.set_fieldname_select(frm); frm.set_query( @@ -94,7 +91,18 @@ frappe.ui.form.on("Webhook", { const args = { doc: frm.doc, doctype: frm.doc.webhook_doctype, - preview_fields: frm.preview_fields, + preview_fields: [ + { + label: __("Meets Condition?"), + fieldtype: "Data", + method: "preview_meets_condition", + }, + { + label: __("Request Body"), + fieldtype: "Code", + method: "preview_request_body", + }, + ], }; let dialog = new frappe.views.RenderPreviewer(args); return dialog; diff --git a/frappe/integrations/doctype/webhook/webhook.py b/frappe/integrations/doctype/webhook/webhook.py index 8ee5df1a25..952d25d31f 100644 --- a/frappe/integrations/doctype/webhook/webhook.py +++ b/frappe/integrations/doctype/webhook/webhook.py @@ -56,15 +56,6 @@ class Webhook(Document): webhook_secret: DF.Password | None # end: auto-generated types - def onload(self): - self.set_onload( - "preview_fields", - [ - {"label": _("Meets Condition?"), "fieldtype": "Data", "method": "preview_meets_condition"}, - {"label": _("Request Body"), "fieldtype": "Code", "method": "preview_request_body"}, - ], - ) - def validate(self): self.validate_docevent() self.validate_condition()