diff --git a/backends/database.js b/backends/database.js index cf445585..e0c14c17 100644 --- a/backends/database.js +++ b/backends/database.js @@ -444,7 +444,7 @@ module.exports = class Database extends Observable { , 'Text': 'text' , 'Data': 'text' , 'Link': 'text' - , 'Dynamic Link': 'text' + , 'DynamicLink': 'text' , 'Password': 'text' , 'Select': 'text' , 'Read Only': 'text' diff --git a/backends/http.js b/backends/http.js index 785993e8..c859fd71 100644 --- a/backends/http.js +++ b/backends/http.js @@ -131,7 +131,7 @@ module.exports = class HTTPClient extends Observable { , 'Text': true , 'Data': true , 'Link': true - , 'Dynamic Link': true + , 'DynamicLink': true , 'Password': true , 'Select': true , 'Read Only': true diff --git a/backends/mysql.js b/backends/mysql.js index 8a77f16f..c33f021a 100644 --- a/backends/mysql.js +++ b/backends/mysql.js @@ -193,7 +193,7 @@ module.exports = class mysqlDatabase extends Database{ , 'Text': 'text' , 'Data': 'VARCHAR(140)' , 'Link': ' varchar(140)' - , 'Dynamic Link': 'text' + , 'DynamicLink': 'text' , 'Password': 'varchar(140)' , 'Select': 'VARCHAR(140)' , 'Read Only': 'varchar(140)' diff --git a/backends/sqlite.js b/backends/sqlite.js index 110ed25f..83afb1f9 100644 --- a/backends/sqlite.js +++ b/backends/sqlite.js @@ -232,7 +232,7 @@ module.exports = class sqliteDatabase extends Database { , 'Text': 'text' , 'Data': 'text' , 'Link': 'text' - , 'Dynamic Link': 'text' + , 'DynamicLink': 'text' , 'Password': 'text' , 'Select': 'text' , 'Read Only': 'text' diff --git a/client/desk/reportpage.js b/client/desk/reportpage.js index 7a4d9145..7a9a1499 100644 --- a/client/desk/reportpage.js +++ b/client/desk/reportpage.js @@ -29,7 +29,7 @@ module.exports = class ReportPage extends Page { } addFilter(field) { - if (field.fieldname) { + if (!field.fieldname) { field.fieldname = frappe.slug(field.label); } @@ -50,6 +50,7 @@ module.exports = class ReportPage extends Page { return false; } } + console.log(values); return values; } diff --git a/client/view/controls/base.js b/client/view/controls/base.js index 6f1a3a31..6e4c02e1 100644 --- a/client/view/controls/base.js +++ b/client/view/controls/base.js @@ -41,7 +41,7 @@ class BaseControl { } renderTemplate() { - if (this.form.doc) { + if (this.form && this.form.doc) { this.wrapper.innerHTML = this.template(this.form.doc, this.doc); } else { this.wrapper.innerHTML = ''; @@ -173,6 +173,7 @@ class BaseControl { } async updateDocValue(value) { + if (!this.doc) return; if (this.doc[this.fieldname] !== value) { if (this.parentControl) { // its a child diff --git a/client/view/list.js b/client/view/list.js index 31a5944d..c5e93605 100644 --- a/client/view/list.js +++ b/client/view/list.js @@ -3,7 +3,7 @@ const keyboard = require('frappejs/client/ui/keyboard'); const Observable = require('frappejs/utils/observable'); module.exports = class BaseList extends Observable { - constructor({doctype, parent, fields, page}) { + constructor({doctype, parent, fields=[], page}) { super(); Object.assign(this, arguments[0]); @@ -17,11 +17,29 @@ module.exports = class BaseList extends Observable { this.rows = []; this.data = []; + this.setupListSettings(); + frappe.db.on(`change:${this.doctype}`, (params) => { this.refresh(); }); } + setupListSettings() { + // list settings that can be overridden by meta + this.listSettings = { + getFields: list => list.fields, + getRowHTML: (list, data) => { + return `
+ ${list.getNameHTML(data)} +
`; + } + } + + if (this.meta.listSettings) { + Object.assign(this.listSettings, this.meta.listSettings); + } + } + makeBody() { if (!this.body) { this.makeToolbar(); @@ -62,7 +80,7 @@ module.exports = class BaseList extends Observable { } async getData() { - let fields = this.getFields(); + let fields = this.listSettings.getFields(this) || []; this.updateStandardFields(fields); return await frappe.db.getAll({ doctype: this.doctype, @@ -73,10 +91,6 @@ module.exports = class BaseList extends Observable { }); } - getFields() { - return []; - } - updateStandardFields(fields) { if (!fields.includes('name')) fields.push('name'); if (!fields.includes('modified')) fields.push('modified'); @@ -105,14 +119,9 @@ module.exports = class BaseList extends Observable { getRowBodyHTML(data) { return `
-
` + this.getRowHTML(data); + ` + this.listSettings.getRowHTML(this, data); } - getRowHTML(data) { - return `
- ${this.getNameHTML(data)} -
`; - } getNameHTML(data) { return `${data[this.meta.titleField]}`; diff --git a/models/doctype/ToDo/ToDoList.js b/models/doctype/ToDo/ToDoList.js index 1a41a7fe..9611ab78 100644 --- a/models/doctype/ToDo/ToDoList.js +++ b/models/doctype/ToDo/ToDoList.js @@ -1,7 +1,7 @@ const BaseList = require('frappejs/client/view/list'); module.exports = class ToDoList extends BaseList { - getFields() { + getFields(list) { return ['name', 'subject', 'status']; } }