From 03d5bf1ef2bbe967bbe17517d40243eaffe261c3 Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 7 Oct 2015 12:18:01 +0300 Subject: [PATCH] tree impr --- .../client/src/views/record/list-tree-item.js | 4 +++- frontend/client/src/views/record/list-tree.js | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/frontend/client/src/views/record/list-tree-item.js b/frontend/client/src/views/record/list-tree-item.js index 30fa76298b..0ebe23f6bd 100644 --- a/frontend/client/src/views/record/list-tree-item.js +++ b/frontend/client/src/views/record/list-tree-item.js @@ -29,6 +29,8 @@ Espo.define('views/record/list-tree-item', 'view', function (Dep) { level: 0, + listViewName: 'views/record/list-tree', + data: function () { return { name: this.model.get('name'), @@ -120,7 +122,7 @@ Espo.define('views/record/list-tree-item', 'view', function (Dep) { view.render(); }; } - this.createView('children', 'Record.ListTree', { + this.createView('children', this.listViewName, { collection: childCollection, el: this.options.el + ' > .children', createDisabled: this.options.createDisabled, diff --git a/frontend/client/src/views/record/list-tree.js b/frontend/client/src/views/record/list-tree.js index dcca158640..6cc793e700 100644 --- a/frontend/client/src/views/record/list-tree.js +++ b/frontend/client/src/views/record/list-tree.js @@ -188,14 +188,24 @@ Espo.define('views/record/list-tree', 'views/record/list', function (Dep) { return this.options.el + ' li[data-id="' + model.id + '"] span.cell-' + item.name; }, + getCreateAttributes: function (model) { + return {}; + }, + actionCreate: function (data, e) { e.stopPropagation(); - var parentId = null; - var parentName = null; + var attributes = this.getCreateAttributes(this.model); + + attributes.order = this.collection.length + 1; + + + attributes.parentId = null; + attributes.parentName = null; + if (this.model) { - parentId = this.model.id; - parentName = this.model.get('name'); + attributes.parentId = this.model.id; + attributes.parentName = this.model.get('name'); } var scope = this.collection.name; @@ -203,11 +213,7 @@ Espo.define('views/record/list-tree', 'views/record/list', function (Dep) { var viewName = this.getMetadata().get('clientDefs.' + scope + '.modalViews.edit') || 'Modals.Edit'; this.createView('quickCreate', viewName, { scope: scope, - attributes: { - parentId: parentId, - parentName: parentName, - order: this.collection.length + 1 - } + attributes: attributes }, function (view) { view.render(); this.listenToOnce(view, 'after:save', function (model) {