From e6ebd6ec15f0208fc566b2381790c35e43878c7f Mon Sep 17 00:00:00 2001 From: Pugazhendhi Velu Date: Tue, 11 Nov 2025 20:30:41 +0000 Subject: [PATCH] feat: add color property to button field --- frappe/core/doctype/docfield/docfield.json | 8 ++++++++ frappe/core/doctype/docfield/docfield.py | 1 + .../doctype/custom_field/custom_field.json | 10 +++++++++- .../doctype/custom_field/custom_field.py | 1 + .../doctype/customize_form/customize_form.py | 1 + .../customize_form_field.json | 10 +++++++++- .../customize_form_field.py | 1 + .../components/controls/ButtonControl.vue | 18 +++++++++++++++++- .../public/js/frappe/form/controls/button.js | 16 +++++++++++++++- 9 files changed, 62 insertions(+), 4 deletions(-) diff --git a/frappe/core/doctype/docfield/docfield.json b/frappe/core/doctype/docfield/docfield.json index 92df52d0aa..4e8cb320c4 100644 --- a/frappe/core/doctype/docfield/docfield.json +++ b/frappe/core/doctype/docfield/docfield.json @@ -32,6 +32,7 @@ "fetch_from", "fetch_if_empty", "visibility_section", + "button_color", "hidden", "show_on_timeline", "bold", @@ -617,6 +618,13 @@ "fieldname": "mask", "fieldtype": "Check", "label": "Mask" + }, + { + "depends_on": "eval:doc.fieldtype===\"Button\"", + "fieldname": "button_color", + "fieldtype": "Select", + "label": "Button Color", + "options": "\nDefault\nPrimary\nInfo\nSuccess\nWarning\nDanger" } ], "grid_page_length": 50, diff --git a/frappe/core/doctype/docfield/docfield.py b/frappe/core/doctype/docfield/docfield.py index 3f6d642e55..6f90b81ce9 100644 --- a/frappe/core/doctype/docfield/docfield.py +++ b/frappe/core/doctype/docfield/docfield.py @@ -18,6 +18,7 @@ class DocField(Document): allow_in_quick_entry: DF.Check allow_on_submit: DF.Check bold: DF.Check + button_color: DF.Literal["", "Default", "Primary", "Info", "Success", "Warning", "Danger"] collapsible: DF.Check collapsible_depends_on: DF.Code | None columns: DF.Int diff --git a/frappe/custom/doctype/custom_field/custom_field.json b/frappe/custom/doctype/custom_field/custom_field.json index 0a97a65c4b..cd0cc57f56 100644 --- a/frappe/custom/doctype/custom_field/custom_field.json +++ b/frappe/custom/doctype/custom_field/custom_field.json @@ -19,6 +19,7 @@ "link_filters", "column_break_6", "fieldtype", + "button_color", "precision", "hide_seconds", "hide_days", @@ -467,6 +468,13 @@ "fieldname": "placeholder", "fieldtype": "Data", "label": "Placeholder" + }, + { + "depends_on": "eval:doc.fieldtype===\"Button\"", + "fieldname": "button_color", + "fieldtype": "Select", + "label": "Button Color", + "options": "\nDefault\nPrimary\nInfo\nSuccess\nWarning\nDanger" } ], "grid_page_length": 50, @@ -474,7 +482,7 @@ "idx": 1, "index_web_pages_for_search": 1, "links": [], - "modified": "2025-10-10 11:10:23.862393", + "modified": "2025-11-12 01:14:24.753774", "modified_by": "Administrator", "module": "Custom", "name": "Custom Field", diff --git a/frappe/custom/doctype/custom_field/custom_field.py b/frappe/custom/doctype/custom_field/custom_field.py index f75dfbd58f..e90a6caf53 100644 --- a/frappe/custom/doctype/custom_field/custom_field.py +++ b/frappe/custom/doctype/custom_field/custom_field.py @@ -25,6 +25,7 @@ class CustomField(Document): allow_in_quick_entry: DF.Check allow_on_submit: DF.Check bold: DF.Check + button_color: DF.Literal["", "Default", "Primary", "Info", "Success", "Warning", "Danger"] collapsible: DF.Check collapsible_depends_on: DF.Code | None columns: DF.Int diff --git a/frappe/custom/doctype/customize_form/customize_form.py b/frappe/custom/doctype/customize_form/customize_form.py index 1fa7a1c4aa..295182f6f2 100644 --- a/frappe/custom/doctype/customize_form/customize_form.py +++ b/frappe/custom/doctype/customize_form/customize_form.py @@ -806,6 +806,7 @@ docfield_properties = { "is_virtual": "Check", "link_filters": "JSON", "placeholder": "Data", + "button_color": "Select", } doctype_link_properties = { 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 69b22eaf60..499e9f4b18 100644 --- a/frappe/custom/doctype/customize_form_field/customize_form_field.json +++ b/frappe/custom/doctype/customize_form_field/customize_form_field.json @@ -54,6 +54,7 @@ "column_break_33", "read_only_depends_on", "display", + "button_color", "in_filter", "hide_seconds", "hide_days", @@ -485,6 +486,13 @@ "fieldname": "placeholder", "fieldtype": "Data", "label": "Placeholder" + }, + { + "depends_on": "eval:doc.fieldtype===\"Button\"", + "fieldname": "button_color", + "fieldtype": "Select", + "label": "Button Color", + "options": "\nDefault\nPrimary\nInfo\nSuccess\nWarning\nDanger" } ], "grid_page_length": 50, @@ -492,7 +500,7 @@ "index_web_pages_for_search": 1, "istable": 1, "links": [], - "modified": "2025-10-14 13:56:58.033573", + "modified": "2025-11-12 01:13:53.053888", "modified_by": "Administrator", "module": "Custom", "name": "Customize Form Field", diff --git a/frappe/custom/doctype/customize_form_field/customize_form_field.py b/frappe/custom/doctype/customize_form_field/customize_form_field.py index 34328ae585..6d30862c4b 100644 --- a/frappe/custom/doctype/customize_form_field/customize_form_field.py +++ b/frappe/custom/doctype/customize_form_field/customize_form_field.py @@ -17,6 +17,7 @@ class CustomizeFormField(Document): allow_in_quick_entry: DF.Check allow_on_submit: DF.Check bold: DF.Check + button_color: DF.Literal["", "Default", "Primary", "Info", "Success", "Warning", "Danger"] collapsible: DF.Check collapsible_depends_on: DF.Code | None columns: DF.Int diff --git a/frappe/public/js/form_builder/components/controls/ButtonControl.vue b/frappe/public/js/form_builder/components/controls/ButtonControl.vue index 6642d5dc49..460ead3055 100644 --- a/frappe/public/js/form_builder/components/controls/ButtonControl.vue +++ b/frappe/public/js/form_builder/components/controls/ButtonControl.vue @@ -1,6 +1,22 @@