diff --git a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Document.json b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Document.json index 820f755509..e89255d976 100644 --- a/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Document.json +++ b/application/Espo/Modules/Crm/Resources/metadata/clientDefs/Document.json @@ -1,10 +1,10 @@ { "controller": "controllers/record", "views": { - "list": "Crm:Document.List" + "list": "crm:document/list" }, "modalViews": { - "select": "Crm:Document.Modals.SelectRecords" + "select": "crm:document/modals/select-records" }, "filterList": [ "active", diff --git a/frontend/client/modules/crm/src/views/document/list.js b/frontend/client/modules/crm/src/views/document/list.js index 4019bdf668..60e05ff77d 100644 --- a/frontend/client/modules/crm/src/views/document/list.js +++ b/frontend/client/modules/crm/src/views/document/list.js @@ -26,11 +26,11 @@ * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ -Espo.define('Crm:Views.Document.List', 'Views.List', function (Dep) { +Espo.define('crm:views/document/list', 'views/list', function (Dep) { return Dep.extend({ - template: 'crm:document.list', + template: 'crm:document/list', quickCreate: true, @@ -40,60 +40,82 @@ Espo.define('Crm:Views.Document.List', 'Views.List', function (Dep) { afterRender: function () { Dep.prototype.afterRender.call(this); - this.loadFolders(); + if (!this.hasView('folders')) { + this.loadFolders(); + } }, - loadFolders: function () { + getTreeCollection: function (callback) { this.getCollectionFactory().create('DocumentFolder', function (collection) { collection.url = collection.name + '/action/listTree'; + this.collection.treeCollection = collection; + this.listenToOnce(collection, 'sync', function () { - this.createView('folders', 'Record.ListTree', { - collection: collection, - el: this.options.el + ' .folders-container', - selectable: true, - createDisabled: true, - showRoot: true, - rootName: this.translate('Document', 'scopeNamesPlural'), - buttonsDisabled: true, - checkboxes: false, - showEditLink: this.getAcl().check('DocumentFolder', 'edit') - }, function (view) { - view.render(); - - this.listenTo(view, 'select', function (model) { - this.currentFolderId = null; - this.currentFolderName = ''; - - if (model && model.id) { - this.currentFolderId = model.id; - this.currentFolderName = model.get('name'); - } - this.collection.whereAdditional = null; - - if (this.currentFolderId) { - this.collection.whereAdditional = [ - { - field: 'folder', - type: 'inCategory', - value: model.id - } - ]; - } - - this.notify('Please wait...'); - this.listenToOnce(this.collection, 'sync', function () { - this.notify(false); - }, this); - this.collection.fetch(); - - }, this); - }.bind(this)); + callback.call(this, collection); }, this); collection.fetch(); + }, this); }, + loadFolders: function () { + this.getTreeCollection(function (collection) { + this.createView('folders', 'views/record/list-tree', { + collection: collection, + el: this.options.el + ' .folders-container', + selectable: true, + createDisabled: true, + showRoot: true, + rootName: this.translate('Document', 'scopeNamesPlural'), + buttonsDisabled: true, + checkboxes: false, + showEditLink: this.getAcl().check('DocumentFolder', 'edit') + }, function (view) { + view.render(); + + this.listenTo(view, 'select', function (model) { + this.currentFolderId = null; + this.currentFolderName = ''; + + if (model && model.id) { + this.currentFolderId = model.id; + this.currentFolderName = model.get('name'); + } + this.collection.whereAdditional = null; + + if (this.currentFolderId) { + this.collection.whereAdditional = [ + { + field: 'folder', + type: 'inCategory', + value: model.id + } + ]; + } + + this.notify('Please wait...'); + this.listenToOnce(this.collection, 'sync', function () { + this.notify(false); + }, this); + this.collection.fetch(); + + }, this); + }, this); + + }, this); + /*this.getCollectionFactory().create('DocumentFolder', function (collection) { + collection.url = collection.name + '/action/listTree'; + + this.collection.treeCollection = collection; + + this.listenToOnce(collection, 'sync', function () { + + }, this); + collection.fetch(); + }, this);*/ + }, + getCreateAttributes: function () { return { folderId: this.currentFolderId, diff --git a/frontend/client/src/controller.js b/frontend/client/src/controller.js index f7b0327439..7ac274a26e 100644 --- a/frontend/client/src/controller.js +++ b/frontend/client/src/controller.js @@ -241,7 +241,7 @@ Espo.define('controller', [], function () { options.el = '#main'; var process = function (main) { - if (useStored) { + if (storedKey) { this.storeMainView(storedKey, main); } main.once('render', function () {