mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
configurable list settings
This commit is contained in:
parent
4d9b9ecd5b
commit
dd88baaf41
@ -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'
|
||||
|
@ -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
|
||||
|
@ -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)'
|
||||
|
@ -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'
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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 `<div class="col-11">
|
||||
${list.getNameHTML(data)}
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
|
||||
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 `<div class="col-1">
|
||||
<input class="checkbox" type="checkbox" data-name="${data.name}">
|
||||
</div>` + this.getRowHTML(data);
|
||||
</div>` + this.listSettings.getRowHTML(this, data);
|
||||
}
|
||||
|
||||
getRowHTML(data) {
|
||||
return `<div class="col-11">
|
||||
${this.getNameHTML(data)}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
getNameHTML(data) {
|
||||
return `<span class="indicator ${this.meta.getIndicatorColor(data)}">${data[this.meta.titleField]}</span>`;
|
||||
|
@ -1,7 +1,7 @@
|
||||
const BaseList = require('frappejs/client/view/list');
|
||||
|
||||
module.exports = class ToDoList extends BaseList {
|
||||
getFields() {
|
||||
getFields(list) {
|
||||
return ['name', 'subject', 'status'];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user