From 30436ef256b28ab7b14bd5f13e49f4f6b76b0473 Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Thu, 26 Apr 2018 15:50:20 +0530 Subject: [PATCH] setValue method in formLayout --- client/desk/reportpage.js | 5 +++++ client/view/form.js | 1 + client/view/formLayout.js | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/client/desk/reportpage.js b/client/desk/reportpage.js index 040d4ec0..021e15d0 100644 --- a/client/desk/reportpage.js +++ b/client/desk/reportpage.js @@ -24,6 +24,7 @@ module.exports = class ReportPage extends Page { }); this.makeFilters(); + this.setDefaultFilterValues(); } getColumns() { @@ -45,6 +46,10 @@ module.exports = class ReportPage extends Page { this.filterWrapper.appendChild(this.filters.form); } + setDefaultFilterValues() { + + } + getFilterValues() { const values = {}; for (let control of this.filters.controlList) { diff --git a/client/view/form.js b/client/view/form.js index 9326d8ae..e5875e8f 100644 --- a/client/view/form.js +++ b/client/view/form.js @@ -317,6 +317,7 @@ module.exports = class BaseForm extends Observable { this.refresh(); this.trigger('change'); } catch (e) { + console.error(e); frappe.ui.showAlert({message: frappe._('Failed'), color: 'red'}); return; } diff --git a/client/view/formLayout.js b/client/view/formLayout.js index c5e551bb..b021c8f0 100644 --- a/client/view/formLayout.js +++ b/client/view/formLayout.js @@ -80,9 +80,19 @@ module.exports = class FormLayout extends Observable { this.controlList.forEach(control => { control.bind(this.doc); }); + + this.doc.on('change', ({doc, fieldname}) => { + this.controls[fieldname].refresh(); + }); + this.refresh(); } + setValue(key, value) { + if (!this.doc) return; + this.doc.set(key, value); + } + refresh() { this.controlList.forEach(control => { control.refresh();