From 769c9e86bd2c28a10de1a760e13b1d5d28a8d13b Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Wed, 18 Apr 2018 12:18:24 +0530 Subject: [PATCH] nested set wip --- client/view/form.js | 2 +- common/print.js | 2 -- model/index.js | 10 +++++++++- model/meta.js | 9 +++++++++ model/nestedset.js | 0 5 files changed, 19 insertions(+), 4 deletions(-) create mode 100644 model/nestedset.js diff --git a/client/view/form.js b/client/view/form.js index 24785afc..9326d8ae 100644 --- a/client/view/form.js +++ b/client/view/form.js @@ -206,7 +206,7 @@ module.exports = class BaseForm extends Observable { } refreshLinks(links) { - if (!this.container) return; + if (!(this.container && this.container.clearLinks)) return; this.container.clearLinks(); for(let link of links) { diff --git a/common/print.js b/common/print.js index c56f32fc..faa5a3fa 100644 --- a/common/print.js +++ b/common/print.js @@ -7,8 +7,6 @@ async function getHTML(doctype, name) { let doc = await frappe.getDoc(doctype, name); let context = {doc: doc, frappe: frappe}; - console.log(context); - let html; try { html = nunjucks.renderString(printFormat.template, context); diff --git a/model/index.js b/model/index.js index cfbd05d6..f32fc6e4 100644 --- a/model/index.js +++ b/model/index.js @@ -34,5 +34,13 @@ module.exports = { { fieldname: 'parentfield', fieldtype: 'Data', required: 1 } + ], + treeFields: [ + { + fieldname: 'lft', fieldtype: 'Int', required: 1 + }, + { + fieldname: 'rgt', fieldtype: 'Int', required: 1 + } ] -}; \ No newline at end of file +}; diff --git a/model/meta.js b/model/meta.js index 6cfc4a79..38d6a4ac 100644 --- a/model/meta.js +++ b/model/meta.js @@ -112,6 +112,15 @@ module.exports = class BaseMeta extends BaseDocument { } } + if (this.isTree) { + // tree fields + for (let field of model.treeFields) { + if (frappe.db.typeMap[field.fieldtype] && !doctype_fields.includes(field.fieldname)) { + _add(field); + } + } + } + // doctype fields for (let field of this.fields) { let include = frappe.db.typeMap[field.fieldtype]; diff --git a/model/nestedset.js b/model/nestedset.js new file mode 100644 index 00000000..e69de29b