Ver código fonte

Added columns field to grid (#1998)

version-14
KanchanChauhan 9 anos atrás
committed by Rushabh Mehta
pai
commit
9590ec546f
5 arquivos alterados com 146 adições e 20 exclusões
  1. +68
    -2
      frappe/core/doctype/docfield/docfield.json
  2. +2
    -1
      frappe/custom/doctype/customize_form/customize_form.py
  3. +62
    -1
      frappe/custom/doctype/customize_form_field/customize_form_field.json
  4. +1
    -0
      frappe/data/Framework.sql
  5. +13
    -16
      frappe/public/js/frappe/form/grid.js

+ 68
- 2
frappe/core/doctype/docfield/docfield.json Ver arquivo

@@ -15,6 +15,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "label_and_type",
"fieldtype": "Section Break",
"hidden": 0,
@@ -39,6 +40,7 @@
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "label",
"fieldtype": "Data",
"hidden": 0,
@@ -67,6 +69,7 @@
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"default": "Data",
"fieldname": "fieldtype",
"fieldtype": "Select",
@@ -95,6 +98,7 @@
"allow_on_submit": 0,
"bold": 1,
"collapsible": 0,
"columns": 0,
"fieldname": "fieldname",
"fieldtype": "Data",
"hidden": 0,
@@ -121,6 +125,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "reqd",
"fieldtype": "Check",
"hidden": 0,
@@ -149,6 +154,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:in_list([\"Float\", \"Currency\", \"Percent\"], doc.fieldtype)",
"description": "Set non-standard precision for a Float or Currency field",
"fieldname": "precision",
@@ -176,6 +182,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image'], doc.fieldtype)",
"fieldname": "length",
"fieldtype": "Int",
@@ -202,6 +209,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "search_index",
"fieldtype": "Check",
"hidden": 0,
@@ -230,6 +238,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "in_list_view",
"fieldtype": "Check",
"hidden": 0,
@@ -256,6 +265,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "bold",
"fieldtype": "Check",
"hidden": 0,
@@ -281,6 +291,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.fieldtype===\"Section Break\"",
"fieldname": "collapsible",
"fieldtype": "Check",
@@ -307,6 +318,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.fieldtype==\"Section Break\"",
"fieldname": "collapsible_depends_on",
"fieldtype": "Code",
@@ -333,6 +345,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_6",
"fieldtype": "Column Break",
"hidden": 0,
@@ -356,6 +369,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "For Links, enter the DocType as range.\nFor Select, enter list of Options, each on a new line.",
"fieldname": "options",
"fieldtype": "Text",
@@ -383,6 +397,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "default",
"fieldtype": "Small Text",
"hidden": 0,
@@ -409,6 +424,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "permissions",
"fieldtype": "Section Break",
"hidden": 0,
@@ -433,6 +449,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "depends_on",
"fieldtype": "Code",
"hidden": 0,
@@ -459,6 +476,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "hidden",
"fieldtype": "Check",
"hidden": 0,
@@ -487,6 +505,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "read_only",
"fieldtype": "Check",
"hidden": 0,
@@ -513,6 +532,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "unique",
"fieldtype": "Check",
"hidden": 0,
@@ -538,6 +558,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Do not allow user to change after set the first time",
"fieldname": "set_only_once",
"fieldtype": "Check",
@@ -563,6 +584,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_13",
"fieldtype": "Column Break",
"hidden": 0,
@@ -586,6 +608,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0",
"fieldname": "permlevel",
"fieldtype": "Int",
@@ -615,6 +638,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "User permissions should not apply for this Link",
"fieldname": "ignore_user_permissions",
"fieldtype": "Check",
@@ -640,6 +664,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "allow_on_submit",
"fieldtype": "Check",
"hidden": 0,
@@ -668,6 +693,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "report_hide",
"fieldtype": "Check",
"hidden": 0,
@@ -696,6 +722,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Don't HTML Encode HTML tags like <script> or just characters like < or >, as they could be intentionally used in this field",
"fieldname": "ignore_xss_filter",
"fieldtype": "Check",
@@ -722,6 +749,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "display",
"fieldtype": "Section Break",
"hidden": 0,
@@ -746,6 +774,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "in_filter",
"fieldtype": "Check",
"hidden": 0,
@@ -774,6 +803,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "no_copy",
"fieldtype": "Check",
"hidden": 0,
@@ -802,6 +832,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "print_hide",
"fieldtype": "Check",
"hidden": 0,
@@ -830,6 +861,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:[\"Int\", \"Float\", \"Currency\", \"Percent\"].indexOf(doc.fieldtype)!==-1",
"fieldname": "print_hide_if_no_value",
"fieldtype": "Check",
@@ -856,6 +888,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "print_width",
"fieldtype": "Data",
"hidden": 0,
@@ -880,6 +913,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "width",
"fieldtype": "Data",
"hidden": 0,
@@ -908,6 +942,35 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:cur_frm.doc.istable",
"description": "Number of columns for a field in a Grid (Total Columns in a grid should be less than 11)",
"fieldname": "columns",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Columns",
"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,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_22",
"fieldtype": "Column Break",
"hidden": 0,
@@ -931,6 +994,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "description",
"fieldtype": "Small Text",
"hidden": 0,
@@ -959,6 +1023,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "oldfieldname",
"fieldtype": "Data",
"hidden": 1,
@@ -984,6 +1049,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "oldfieldtype",
"fieldtype": "Data",
"hidden": 1,
@@ -1016,7 +1082,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-07-11 03:25:57.882851",
"modified": "2016-08-23 11:59:07.036627",
"modified_by": "Administrator",
"module": "Core",
"name": "DocField",
@@ -1026,5 +1092,5 @@
"read_only": 0,
"read_only_onload": 0,
"sort_order": "ASC",
"track_seen": 0
"track_seen": 0
}

+ 2
- 1
frappe/custom/doctype/customize_form/customize_form.py Ver arquivo

@@ -54,7 +54,8 @@ docfield_properties = {
'default': 'Text',
'precision': 'Select',
'read_only': 'Check',
'length': 'Int'
'length': 'Int',
'columns': 'Int'
}

allowed_fieldtype_change = (('Currency', 'Float', 'Percent'), ('Small Text', 'Data'),


+ 62
- 1
frappe/custom/doctype/customize_form_field/customize_form_field.json Ver arquivo

@@ -15,6 +15,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "label_and_type",
"fieldtype": "Section Break",
"hidden": 0,
@@ -40,6 +41,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "label",
"fieldtype": "Data",
"hidden": 0,
@@ -66,6 +68,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "Data",
"fieldname": "fieldtype",
"fieldtype": "Select",
@@ -94,6 +97,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "fieldname",
"fieldtype": "Data",
"hidden": 0,
@@ -120,6 +124,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "reqd",
"fieldtype": "Check",
"hidden": 0,
@@ -148,6 +153,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "unique",
"fieldtype": "Check",
"hidden": 0,
@@ -173,6 +179,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "in_list_view",
"fieldtype": "Check",
"hidden": 0,
@@ -197,6 +204,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_7",
"fieldtype": "Column Break",
"hidden": 0,
@@ -221,6 +229,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:in_list([\"Float\", \"Currency\", \"Percent\"], doc.fieldtype)",
"description": "Set non-standard precision for a Float or Currency field",
"fieldname": "precision",
@@ -249,6 +258,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:in_list(['Data', 'Link', 'Dynamic Link', 'Password', 'Select', 'Read Only', 'Attach', 'Attach Image'], doc.fieldtype)",
"fieldname": "length",
"fieldtype": "Int",
@@ -275,6 +285,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "For Links, enter the DocType as range.\nFor Select, enter list of Options, each on a new line.",
"fieldname": "options",
"fieldtype": "Text",
@@ -302,6 +313,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "permissions",
"fieldtype": "Section Break",
"hidden": 0,
@@ -327,6 +339,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "This field will appear only if the fieldname defined here has value OR the rules are true (examples): \nmyfield\neval:doc.myfield=='My Value'\neval:doc.age>18",
"fieldname": "depends_on",
"fieldtype": "Code",
@@ -354,6 +367,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"default": "0",
"fieldname": "permlevel",
"fieldtype": "Int",
@@ -381,6 +395,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "hidden",
"fieldtype": "Check",
"hidden": 0,
@@ -409,6 +424,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "read_only",
"fieldtype": "Check",
"hidden": 0,
@@ -434,6 +450,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.fieldtype==\"Section Break\"",
"fieldname": "collapsible",
"fieldtype": "Check",
@@ -460,6 +477,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:doc.fieldtype==\"Section Break\"",
"fieldname": "collapsible_depends_on",
"fieldtype": "Code",
@@ -486,6 +504,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_14",
"fieldtype": "Column Break",
"hidden": 0,
@@ -510,6 +529,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "ignore_user_permissions",
"fieldtype": "Check",
"hidden": 0,
@@ -534,6 +554,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "allow_on_submit",
"fieldtype": "Check",
"hidden": 0,
@@ -560,6 +581,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "report_hide",
"fieldtype": "Check",
"hidden": 0,
@@ -586,6 +608,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "display",
"fieldtype": "Section Break",
"hidden": 0,
@@ -611,6 +634,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "default",
"fieldtype": "Text",
"hidden": 0,
@@ -637,6 +661,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "in_filter",
"fieldtype": "Check",
"hidden": 0,
@@ -665,6 +690,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "column_break_21",
"fieldtype": "Column Break",
"hidden": 0,
@@ -689,6 +715,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "description",
"fieldtype": "Text",
"hidden": 0,
@@ -717,6 +744,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "print_hide",
"fieldtype": "Check",
"hidden": 0,
@@ -743,6 +771,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:[\"Int\", \"Float\", \"Currency\", \"Percent\"].indexOf(doc.fieldtype)!==-1",
"fieldname": "print_hide_if_no_value",
"fieldtype": "Check",
@@ -769,6 +798,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Print Width of the field, if the field is a column in a table",
"fieldname": "print_width",
"fieldtype": "Data",
@@ -796,6 +826,35 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "eval:cur_frm.doc.istable",
"description": "Number of columns for a field in a Grid (Total Columns in a grid should be less than 11)",
"fieldname": "columns",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_list_view": 0,
"label": "Columns",
"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,
"collapsible": 0,
"columns": 0,
"fieldname": "width",
"fieldtype": "Data",
"hidden": 0,
@@ -824,6 +883,7 @@
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "is_custom_field",
"fieldtype": "Check",
"hidden": 1,
@@ -856,7 +916,7 @@
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2016-07-11 03:27:58.928043",
"modified": "2016-08-23 12:03:07.126339",
"modified_by": "Administrator",
"module": "Custom",
"name": "Customize Form Field",
@@ -865,5 +925,6 @@
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"sort_order": "ASC",
"track_seen": 0
}

+ 1
- 0
frappe/data/Framework.sql Ver arquivo

@@ -42,6 +42,7 @@ CREATE TABLE `tabDocField` (
`ignore_user_permissions` int(1) NOT NULL DEFAULT 0,
`width` varchar(255) DEFAULT NULL,
`print_width` varchar(255) DEFAULT NULL,
`columns` int(11) NOT NULL DEFAULT 0,
`default` text,
`description` text,
`in_filter` int(1) NOT NULL DEFAULT 0,


+ 13
- 16
frappe/public/js/frappe/form/grid.js Ver arquivo

@@ -338,27 +338,24 @@ frappe.ui.form.Grid = Class.extend({
throw 'field not found: ' + _df.fieldname;
}

// map columns
if(_df.columns) {
df.colsize = _df.columns;
}

if(!df.hidden
&& (this.editable_fields || df.in_list_view)
&& this.frm.get_perm(df.permlevel, "read")
&& !in_list(frappe.model.layout_fields, df.fieldtype)) {
if(!df.colsize) {
var colsize = 2;
switch(df.fieldtype) {
case "Text":
case "Small Text":
colsize = 3;
if(df.columns) {
df.colsize=df.columns;
}
else {
var colsize=2;
switch(df.fieldtype){
case"Text":
case"Small Text":
colsize=3;
break;
case "Check":
colsize = 1;
break;
}
df.colsize = colsize;
case"Check":
colsize=1
}
df.colsize=colsize
}

total_colsize += df.colsize


Carregando…
Cancelar
Salvar