documents navigation fix

This commit is contained in:
yuri
2015-11-16 12:22:05 +02:00
parent b64c897f33
commit 2aaec4ea99
3 changed files with 70 additions and 48 deletions
@@ -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",
@@ -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,
+1 -1
View File
@@ -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 () {