From c424c7e263bdf893a421560e7d1346e910cca165 Mon Sep 17 00:00:00 2001 From: prssanna Date: Fri, 10 Apr 2020 12:43:55 +0530 Subject: [PATCH 1/2] feat: Add show preview popup to Customize Form --- frappe/boot.py | 8 +++++++- frappe/custom/doctype/custom_field/custom_field.json | 9 ++++++++- frappe/custom/doctype/customize_form/customize_form.json | 9 ++++++++- frappe/custom/doctype/customize_form/customize_form.py | 2 ++ .../customize_form_field/customize_form_field.json | 9 ++++++++- 5 files changed, 33 insertions(+), 4 deletions(-) diff --git a/frappe/boot.py b/frappe/boot.py index e6d1199b19..8b9668430c 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -268,4 +268,10 @@ def get_success_action(): return frappe.get_all("Success Action", fields=["*"]) def get_link_preview_doctypes(): - return [d.name for d in frappe.db.get_all('DocType', {'show_preview_popup': 1})] \ No newline at end of file + link_preview_doctypes = [d.name for d in frappe.db.get_all('DocType', {'show_preview_popup': 1})] + customizations = frappe.get_all("Property Setter", + fields=['doc_type'], + filters={'property': 'show_preview_popup', 'value': "1" + }) + link_preview_doctypes += [custom.doc_type for custom in customizations] + return link_preview_doctypes diff --git a/frappe/custom/doctype/custom_field/custom_field.json b/frappe/custom/doctype/custom_field/custom_field.json index b274033f80..394f38b56c 100644 --- a/frappe/custom/doctype/custom_field/custom_field.json +++ b/frappe/custom/doctype/custom_field/custom_field.json @@ -41,6 +41,7 @@ "in_list_view", "in_standard_filter", "in_global_search", + "in_preview", "bold", "report_hide", "search_index", @@ -371,12 +372,18 @@ "fieldname": "allow_in_quick_entry", "fieldtype": "Check", "label": "Allow in Quick Entry" + }, + { + "default": "0", + "fieldname": "in_preview", + "fieldtype": "Check", + "label": "In Preview" } ], "icon": "fa fa-glass", "idx": 1, "links": [], - "modified": "2020-03-16 14:52:43.954709", + "modified": "2020-04-10 11:57:10.392218", "modified_by": "Administrator", "module": "Custom", "name": "Custom Field", diff --git a/frappe/custom/doctype/customize_form/customize_form.json b/frappe/custom/doctype/customize_form/customize_form.json index 51a5c0b85f..cd57aa23fe 100644 --- a/frappe/custom/doctype/customize_form/customize_form.json +++ b/frappe/custom/doctype/customize_form/customize_form.json @@ -20,6 +20,7 @@ "track_views", "allow_auto_repeat", "allow_import", + "show_preview_popup", "image_view", "column_break_5", "title_field", @@ -203,6 +204,12 @@ "depends_on": "doc_type", "fieldname": "section_break_23", "fieldtype": "Section Break" + }, + { + "default": "0", + "fieldname": "show_preview_popup", + "fieldtype": "Check", + "label": "Show Preview Popup" } ], "hide_toolbar": 1, @@ -210,7 +217,7 @@ "idx": 1, "issingle": 1, "links": [], - "modified": "2020-03-27 15:06:35.443861", + "modified": "2020-04-10 12:16:01.320411", "modified_by": "Administrator", "module": "Custom", "name": "Customize Form", diff --git a/frappe/custom/doctype/customize_form/customize_form.py b/frappe/custom/doctype/customize_form/customize_form.py index 7d081953dd..9efa555152 100644 --- a/frappe/custom/doctype/customize_form/customize_form.py +++ b/frappe/custom/doctype/customize_form/customize_form.py @@ -32,6 +32,7 @@ doctype_properties = { 'track_views': 'Check', 'allow_auto_repeat': 'Check', 'allow_import': 'Check', + 'show_preview_popup': 'Check', 'email_append_to': 'Check', 'subject_field': 'Data', 'sender_field': 'Data' @@ -53,6 +54,7 @@ docfield_properties = { 'in_list_view': 'Check', 'in_standard_filter': 'Check', 'in_global_search': 'Check', + 'in_preview': 'Check', 'bold': 'Check', 'hidden': 'Check', 'collapsible': 'Check', diff --git a/frappe/custom/doctype/customize_form_field/customize_form_field.json b/frappe/custom/doctype/customize_form_field/customize_form_field.json index 350d159541..d7887cf8bd 100644 --- a/frappe/custom/doctype/customize_form_field/customize_form_field.json +++ b/frappe/custom/doctype/customize_form_field/customize_form_field.json @@ -16,6 +16,7 @@ "in_list_view", "in_standard_filter", "in_global_search", + "in_preview", "bold", "allow_in_quick_entry", "translatable", @@ -381,12 +382,18 @@ "fieldtype": "Code", "label": "Read Only Depends On", "options": "JS" + }, + { + "default": "0", + "fieldname": "in_preview", + "fieldtype": "Check", + "label": "In Preview" } ], "idx": 1, "istable": 1, "links": [], - "modified": "2020-04-15 02:26:59.673750", + "modified": "2020-04-10 11:58:44.573537", "modified_by": "Administrator", "module": "Custom", "name": "Customize Form Field", From 685df9b1f16e9a03a93df36fec978ba908fe2f4f Mon Sep 17 00:00:00 2001 From: prssanna Date: Sun, 19 Apr 2020 14:33:52 +0530 Subject: [PATCH 2/2] fix: remove doctype from link_preview_doctypes if custom value is 0 --- frappe/boot.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/frappe/boot.py b/frappe/boot.py index 8b9668430c..eed434f870 100644 --- a/frappe/boot.py +++ b/frappe/boot.py @@ -268,10 +268,18 @@ def get_success_action(): return frappe.get_all("Success Action", fields=["*"]) def get_link_preview_doctypes(): + from frappe.utils import cint + link_preview_doctypes = [d.name for d in frappe.db.get_all('DocType', {'show_preview_popup': 1})] customizations = frappe.get_all("Property Setter", - fields=['doc_type'], - filters={'property': 'show_preview_popup', 'value': "1" - }) - link_preview_doctypes += [custom.doc_type for custom in customizations] + fields=['doc_type', 'value'], + filters={'property': 'show_preview_popup'} + ) + + for custom in customizations: + if not cint(custom.value) and custom.doc_type in link_preview_doctypes: + link_preview_doctypes.remove(custom.doc_type) + else: + link_preview_doctypes.append(custom.doc_type) + return link_preview_doctypes