From 104df66ab4923ccd8cedfa5cde897b514d6fc69f Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Fri, 8 Jul 2016 14:33:17 +0530 Subject: [PATCH] [editable fields] now configable and customizable --- frappe/core/doctype/doctype/doctype.json | 32 ++++++++++- .../customize_form/customize_form.json | 54 ++++++++++++++++++- .../doctype/customize_form/customize_form.py | 2 + frappe/data/Framework.sql | 1 + frappe/public/css/form_grid.css | 14 +++-- frappe/public/js/frappe/form/grid.js | 15 +++--- frappe/public/js/frappe/ui/messages.js | 10 ++-- frappe/public/less/form_grid.less | 16 ++++-- 8 files changed, 120 insertions(+), 24 deletions(-) diff --git a/frappe/core/doctype/doctype/doctype.json b/frappe/core/doctype/doctype/doctype.json index ed818affb6..1aad28e920 100644 --- a/frappe/core/doctype/doctype/doctype.json +++ b/frappe/core/doctype/doctype/doctype.json @@ -90,6 +90,33 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "default": "1", + "depends_on": "istable", + "fieldname": "editable_grid", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Editable Grid", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -244,8 +271,8 @@ "allow_on_submit": 0, "bold": 0, "collapsible": 0, + "default": "0", "depends_on": "eval: doc.image_field", - "default": 0, "fieldname": "image_view", "fieldtype": "Check", "hidden": 0, @@ -1119,13 +1146,14 @@ "hide_toolbar": 0, "icon": "icon-bolt", "idx": 6, + "image_view": 0, "in_create": 0, "in_dialog": 0, "is_submittable": 0, "issingle": 0, "istable": 0, "max_attachments": 0, - "modified": "2016-06-01 12:28:01.048158", + "modified": "2016-07-08 04:38:09.088871", "modified_by": "Administrator", "module": "Core", "name": "DocType", diff --git a/frappe/custom/doctype/customize_form/customize_form.json b/frappe/custom/doctype/customize_form/customize_form.json index 38f49498f3..6b804a4e5e 100644 --- a/frappe/custom/doctype/customize_form/customize_form.json +++ b/frappe/custom/doctype/customize_form/customize_form.json @@ -9,6 +9,7 @@ "docstatus": 0, "doctype": "DocType", "document_type": "Document", + "editable_grid": 1, "fields": [ { "allow_on_submit": 0, @@ -134,6 +135,57 @@ "set_only_once": 0, "unique": 0 }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "fieldname": "istable", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Is Table", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 1, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, + { + "allow_on_submit": 0, + "bold": 0, + "collapsible": 0, + "depends_on": "istable", + "fieldname": "editable_grid", + "fieldtype": "Check", + "hidden": 0, + "ignore_user_permissions": 0, + "ignore_xss_filter": 0, + "in_filter": 0, + "in_list_view": 0, + "label": "Editable Grid", + "length": 0, + "no_copy": 0, + "permlevel": 0, + "precision": "", + "print_hide": 0, + "print_hide_if_no_value": 0, + "read_only": 0, + "report_hide": 0, + "reqd": 0, + "search_index": 0, + "set_only_once": 0, + "unique": 0 + }, { "allow_on_submit": 0, "bold": 0, @@ -448,7 +500,7 @@ "issingle": 1, "istable": 0, "max_attachments": 0, - "modified": "2016-06-01 12:29:28.272410", + "modified": "2016-07-08 04:40:57.045612", "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 3639251b3f..6d251d31df 100644 --- a/frappe/custom/doctype/customize_form/customize_form.py +++ b/frappe/custom/doctype/customize_form/customize_form.py @@ -22,7 +22,9 @@ doctype_properties = { 'default_print_format': 'Data', 'read_only_onload': 'Check', 'allow_copy': 'Check', + 'istable': 'Check', 'quick_entry': 'Check', + 'editable_grid': 'Check', 'max_attachments': 'Int', 'image_view': 'Check' } diff --git a/frappe/data/Framework.sql b/frappe/data/Framework.sql index 69ef1d6af8..baad6d7cc3 100644 --- a/frappe/data/Framework.sql +++ b/frappe/data/Framework.sql @@ -112,6 +112,7 @@ CREATE TABLE `tabDocType` ( `search_fields` varchar(255) DEFAULT NULL, `issingle` int(1) NOT NULL DEFAULT 0, `istable` int(1) NOT NULL DEFAULT 0, + `editable_grid` int(1) NOT NULL DEFAULT 1, `module` varchar(255) DEFAULT NULL, `app` varchar(255) DEFAULT NULL, `autoname` varchar(255) DEFAULT NULL, diff --git a/frappe/public/css/form_grid.css b/frappe/public/css/form_grid.css index d8f8a3deea..c296fe0cce 100644 --- a/frappe/public/css/form_grid.css +++ b/frappe/public/css/form_grid.css @@ -25,7 +25,7 @@ margin: 0px; } .data-row textarea { - height: 40px !important; + height: 40px; } .grid-body { background-color: #fff; @@ -76,10 +76,18 @@ margin-top: 7px; } .grid-body .editable-row .btn-open-row { - margin-top: 0px; - padding: 5px 17px; + margin: -10px -4px; + padding: 15px 6px; margin-right: -20px; } +.grid-body .editable-row .checkbox { + margin: 0px; + margin-right: -7px; + text-align: center; +} +.grid-body .editable-row textarea { + height: none; +} .grid-body .editable-row .field-area { margin-right: -11px; margin-top: -1px; diff --git a/frappe/public/js/frappe/form/grid.js b/frappe/public/js/frappe/form/grid.js index f76e15c0a5..4fa6958b6e 100644 --- a/frappe/public/js/frappe/form/grid.js +++ b/frappe/public/js/frappe/form/grid.js @@ -26,13 +26,6 @@ frappe.ui.form.Grid = Class.extend({ this.template = this.frm.meta.__form_grid_templates[this.df.fieldname]; } - // set rows editable if less that 4 fields and no text, image, button, html field - if(this.meta.fields.length < 4 && !has_common(['Text', 'Small Text', 'Image', - 'Text Editor', 'HTML', 'Section Break', 'Column Break'], - $.map(this.meta.fields, function(f) { return f.fieldtype }))) { - this.on_grid_editing = true; - } - this.is_grid = true; }, @@ -42,7 +35,7 @@ frappe.ui.form.Grid = Class.extend({ } else if(this.editable_fields) { return true; } else { - return this.on_grid_editing; + return this.meta.editable_grid; } }, make: function() { @@ -620,9 +613,13 @@ frappe.ui.form.GridRow = Class.extend({ // remove row if(!this.remove_row) { this.remove_row = $('\ - ') + ') .appendTo(this.row) .on('click', function() { me.toggle_view(); return false; }); + + if(this.row.width() < 400) { + this.remove_row.css({'padding-right': '3px'}); + } } } } diff --git a/frappe/public/js/frappe/ui/messages.js b/frappe/public/js/frappe/ui/messages.js index 3e07fae8a0..93126d52d3 100644 --- a/frappe/public/js/frappe/ui/messages.js +++ b/frappe/public/js/frappe/ui/messages.js @@ -88,14 +88,12 @@ frappe.msgprint = function(msg, title) { } } + if(!data.indicator) { + data.indicator = 'blue'; + } if(data.message instanceof Array) { - $.each(data.message, function(i,v) { - if(v) { - msgprint(v); - } - }) - return; + data.message = $.map(data.message, function(m) { return '

' + m + '

'}).join(''); } if(data.alert) { diff --git a/frappe/public/less/form_grid.less b/frappe/public/less/form_grid.less index 413638a8be..dff94b84e1 100644 --- a/frappe/public/less/form_grid.less +++ b/frappe/public/less/form_grid.less @@ -30,7 +30,7 @@ } .data-row textarea { - height: 40px !important; + height: 40px; } .grid-body { @@ -95,11 +95,21 @@ } .btn-open-row { - margin-top: 0px; - padding: 5px 17px; + margin: -10px -4px; + padding: 15px 6px; margin-right: -20px; } + .checkbox { + margin: 0px; + margin-right: -7px; + text-align: center; + } + + textarea { + height: none; + } + .field-area { margin-right: -11px; margin-top: -1px;