fix(minor): dynamically changing grid propertiesversion-14
@@ -15,8 +15,9 @@ frappe.ui.form.on('Document Naming Rule', { | |||||
}).map((d) => { | }).map((d) => { | ||||
return {label: `${d.label} (${d.fieldname})`, value: d.fieldname}; | return {label: `${d.label} (${d.fieldname})`, value: d.fieldname}; | ||||
}); | }); | ||||
frappe.meta.get_docfield('Document Naming Rule Condition', 'field', frm.doc.name).options = fieldnames; | |||||
frm.refresh_field('conditions'); | |||||
frm.fields_dict.conditions.grid.update_docfield_property( | |||||
'field', 'options', fieldnames | |||||
); | |||||
}); | }); | ||||
} | } | ||||
} | } | ||||
@@ -85,14 +85,11 @@ frappe.notification = { | |||||
} | } | ||||
// set email recipient options | // set email recipient options | ||||
frappe.meta.get_docfield( | |||||
'Notification Recipient', | |||||
frm.fields_dict.recipients.grid.update_docfield_property( | |||||
'receiver_by_document_field', | 'receiver_by_document_field', | ||||
// set first option as blank to allow notification not to be defaulted to the owner | |||||
frm.doc.name | |||||
).options = [''].concat(["owner"]).concat(receiver_fields); | |||||
frm.fields_dict.recipients.grid.refresh(); | |||||
'options', | |||||
[''].concat(["owner"]).concat(receiver_fields) | |||||
); | |||||
}); | }); | ||||
}, | }, | ||||
setup_example_message: function(frm) { | setup_example_message: function(frm) { | ||||
@@ -25,7 +25,9 @@ frappe.webhook = { | |||||
} | } | ||||
} | } | ||||
frappe.meta.get_docfield("Webhook Data", "fieldname", frm.doc.name).options = [""].concat(fields); | |||||
frm.fields_dict.webhook_data.grid.update_docfield_property( | |||||
'fieldname', 'options', [""].concat(fields) | |||||
); | |||||
}); | }); | ||||
} | } | ||||
}, | }, | ||||
@@ -34,7 +34,6 @@ frappe.ui.form.Form = class FrappeForm { | |||||
this.grids = []; | this.grids = []; | ||||
this.cscript = new frappe.ui.form.Controller({ frm: this }); | this.cscript = new frappe.ui.form.Controller({ frm: this }); | ||||
this.events = {}; | this.events = {}; | ||||
this.pformat = {}; | |||||
this.fetch_dict = {}; | this.fetch_dict = {}; | ||||
this.parent = parent; | this.parent = parent; | ||||
this.doctype_layout = frappe.get_doc('DocType Layout', doctype_layout_name); | this.doctype_layout = frappe.get_doc('DocType Layout', doctype_layout_name); | ||||
@@ -1144,10 +1143,6 @@ frappe.ui.form.Form = class FrappeForm { | |||||
this.page.remove_inner_button(label, group); | this.page.remove_inner_button(label, group); | ||||
} | } | ||||
set_print_heading(txt) { | |||||
this.pformat[this.docname] = txt; | |||||
} | |||||
scroll_to_element() { | scroll_to_element() { | ||||
if (frappe.route_options && frappe.route_options.scroll_to) { | if (frappe.route_options && frappe.route_options.scroll_to) { | ||||
var scroll_to = frappe.route_options.scroll_to; | var scroll_to = frappe.route_options.scroll_to; | ||||
@@ -901,4 +901,21 @@ export default class Grid { | |||||
// hide all custom buttons | // hide all custom buttons | ||||
this.grid_buttons.find('.btn-custom').addClass('hidden'); | this.grid_buttons.find('.btn-custom').addClass('hidden'); | ||||
} | } | ||||
update_docfield_property(fieldname, property, value) { | |||||
// update the docfield of each row | |||||
for (let row of this.grid_rows) { | |||||
let docfield = row.docfields.find(d => d.fieldname === fieldname); | |||||
if (docfield) { | |||||
docfield[property] = value; | |||||
} else { | |||||
throw `field ${fieldname} not found`; | |||||
} | |||||
} | |||||
// update the parent too (for new rows) | |||||
this.docfields.find(d => d.fieldname === fieldname)[property] = value; | |||||
this.refresh(); | |||||
} | |||||
} | } |
@@ -20,7 +20,10 @@ frappe.web_form = { | |||||
return null; | return null; | ||||
} | } | ||||
}); | }); | ||||
frappe.meta.get_docfield("Web Form Field", "fieldname", frm.doc.name).options = [""].concat(fields); | |||||
frm.fields_dict.web_form_fields.grid.update_docfield_property( | |||||
'fieldname', 'options', fields | |||||
); | |||||
frappe.meta.get_docfield("Web Form", "amount_field", frm.doc.name).options = [""].concat(currency_fields); | frappe.meta.get_docfield("Web Form", "amount_field", frm.doc.name).options = [""].concat(currency_fields); | ||||
frm.refresh_field("amount_field"); | frm.refresh_field("amount_field"); | ||||
resolve(); | resolve(); | ||||
@@ -86,14 +86,14 @@ | |||||
"width": "50%" | "width": "50%" | ||||
}, | }, | ||||
{ | { | ||||
"default": "0", | |||||
"default": "1", | |||||
"fieldname": "published", | "fieldname": "published", | ||||
"fieldtype": "Check", | "fieldtype": "Check", | ||||
"in_standard_filter": 1, | "in_standard_filter": 1, | ||||
"label": "Published" | "label": "Published" | ||||
}, | }, | ||||
{ | { | ||||
"default": "1", | |||||
"default": "0", | |||||
"fieldname": "show_title", | "fieldname": "show_title", | ||||
"fieldtype": "Check", | "fieldtype": "Check", | ||||
"label": "Show Title" | "label": "Show Title" | ||||
@@ -114,7 +114,7 @@ | |||||
"label": "Content" | "label": "Content" | ||||
}, | }, | ||||
{ | { | ||||
"default": "Rich Text", | |||||
"default": "Page Builder", | |||||
"fieldname": "content_type", | "fieldname": "content_type", | ||||
"fieldtype": "Select", | "fieldtype": "Select", | ||||
"label": "Content Type", | "label": "Content Type", | ||||
@@ -259,7 +259,7 @@ | |||||
"options": "Web Page Block" | "options": "Web Page Block" | ||||
}, | }, | ||||
{ | { | ||||
"default": "0", | |||||
"default": "1", | |||||
"fieldname": "full_width", | "fieldname": "full_width", | ||||
"fieldtype": "Check", | "fieldtype": "Check", | ||||
"label": "Full Width" | "label": "Full Width" | ||||
@@ -314,7 +314,7 @@ | |||||
"is_published_field": "published", | "is_published_field": "published", | ||||
"links": [], | "links": [], | ||||
"max_attachments": 20, | "max_attachments": 20, | ||||
"modified": "2020-09-21 16:32:53.568573", | |||||
"modified": "2021-04-13 10:23:28.681197", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Website", | "module": "Website", | ||||
"name": "Web Page", | "name": "Web Page", | ||||
@@ -30,8 +30,9 @@ frappe.ui.form.on('Website Settings', { | |||||
}, | }, | ||||
set_parent_label_options: function(frm) { | set_parent_label_options: function(frm) { | ||||
frappe.meta.get_docfield("Top Bar Item", "parent_label", frm.docname).options = | |||||
frm.events.get_parent_options(frm, "top_bar_items"); | |||||
frm.fields_dict.top_bar_items.grid.update_docfield_property( | |||||
'parent_label', 'options', frm.events.get_parent_options(frm, "top_bar_items") | |||||
); | |||||
if ($(frm.fields_dict.top_bar_items.grid.wrapper).find(".grid-row-open")) { | if ($(frm.fields_dict.top_bar_items.grid.wrapper).find(".grid-row-open")) { | ||||
frm.fields_dict.top_bar_items.grid.refresh(); | frm.fields_dict.top_bar_items.grid.refresh(); | ||||
@@ -39,8 +40,9 @@ frappe.ui.form.on('Website Settings', { | |||||
}, | }, | ||||
set_parent_label_options_footer: function(frm) { | set_parent_label_options_footer: function(frm) { | ||||
frappe.meta.get_docfield("Top Bar Item", "parent_label", frm.docname).options = | |||||
frm.events.get_parent_options(frm, "footer_items"); | |||||
frm.fields_dict.footer_items.grid.update_docfield_property( | |||||
'parent_label', 'options', frm.events.get_parent_options(frm, "top_bar_items") | |||||
); | |||||
if ($(frm.fields_dict.footer_items.grid.wrapper).find(".grid-row-open")) { | if ($(frm.fields_dict.footer_items.grid.wrapper).find(".grid-row-open")) { | ||||
frm.fields_dict.footer_items.grid.refresh(); | frm.fields_dict.footer_items.grid.refresh(); | ||||
@@ -142,6 +142,7 @@ | |||||
}, | }, | ||||
{ | { | ||||
"collapsible": 1, | "collapsible": 1, | ||||
"collapsible_depends_on": "top_bar_items", | |||||
"fieldname": "top_bar", | "fieldname": "top_bar", | ||||
"fieldtype": "Section Break", | "fieldtype": "Section Break", | ||||
"label": "Navbar" | "label": "Navbar" | ||||
@@ -160,6 +161,7 @@ | |||||
}, | }, | ||||
{ | { | ||||
"collapsible": 1, | "collapsible": 1, | ||||
"collapsible_depends_on": "banner_html", | |||||
"fieldname": "banner", | "fieldname": "banner", | ||||
"fieldtype": "Section Break", | "fieldtype": "Section Break", | ||||
"label": "Banner" | "label": "Banner" | ||||
@@ -173,6 +175,7 @@ | |||||
}, | }, | ||||
{ | { | ||||
"collapsible": 1, | "collapsible": 1, | ||||
"collapsible_depends_on": "footer_items", | |||||
"fieldname": "footer", | "fieldname": "footer", | ||||
"fieldtype": "Section Break", | "fieldtype": "Section Break", | ||||
"label": "Footer" | "label": "Footer" | ||||
@@ -415,7 +418,7 @@ | |||||
"issingle": 1, | "issingle": 1, | ||||
"links": [], | "links": [], | ||||
"max_attachments": 10, | "max_attachments": 10, | ||||
"modified": "2020-09-28 18:47:18.506700", | |||||
"modified": "2021-04-13 10:22:51.888788", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Website", | "module": "Website", | ||||
"name": "Website Settings", | "name": "Website Settings", | ||||
@@ -44,7 +44,9 @@ frappe.ui.form.on("Workflow", { | |||||
const get_field_method = 'frappe.workflow.doctype.workflow.workflow.get_fieldnames_for'; | const get_field_method = 'frappe.workflow.doctype.workflow.workflow.get_fieldnames_for'; | ||||
frappe.xcall(get_field_method, { doctype: doc.document_type }) | frappe.xcall(get_field_method, { doctype: doc.document_type }) | ||||
.then(resp => { | .then(resp => { | ||||
frappe.meta.get_docfield("Workflow Document State", "update_field", frm.doc.name).options = [""].concat(resp); | |||||
frm.fields_dict.states.grid.update_docfield_property( | |||||
'update_field', 'options', [""].concat(resp) | |||||
); | |||||
}) | }) | ||||
} | } | ||||
}, | }, | ||||