EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
store list tree
Yuri Kuznetsov2deb34cb3af6
diff --git a/client/src/controllers/record-tree.js b/client/src/controllers/record-tree.jsindex 010f413e6c..f2043ae833 100644--- a/client/src/controllers/record-tree.js+++ b/client/src/controllers/record-tree.js@@ -54,6 +54,7 @@ class RecordTreeController extends RecordController {** @param {{* currentId?: string,+ * isReturn?: boolean,* }} options*/async actionListTree(options) {@@ -68,10 +69,12 @@ class RecordTreeController extends RecordController {collection.url = `${collection.entityType}/action/listTree`;collection.currentId = currentId ?? null;+ const isReturn = options.isReturn || this.getRouter().backProcessed;+this.main(this.getViewName('listTree'), {scope: this.name,collection: collection,- });+ }, undefined, {key: 'listTree', useStored: isReturn});}async create(options = {}) {diff --git a/client/src/views/record/list-tree-item.js b/client/src/views/record/list-tree-item.jsindex b22200c6fb..81c5ab1914 100644--- a/client/src/views/record/list-tree-item.js+++ b/client/src/views/record/list-tree-item.js@@ -180,6 +180,9 @@ class ListTreeRecordItemView extends View {return /** @type module:views/record/list-tree */this.getParentView();}+ /**+ * @private+ */createChildren() {const childCollection = this.model.get('childCollection');@@ -208,9 +211,12 @@ class ListTreeRecordItemView extends View {}, callback);}+ /**+ * @private+ */checkLastChildren() {Espo.Ajax- .getRequest(this.collection.entityType + '/action/lastChildrenIdList', {parentId: this.model.id})+ .getRequest(`${this.collection.entityType}/action/lastChildrenIdList`, {parentId: this.model.id}).then(idList => {const childrenView = this.getChildrenView();@@ -256,7 +262,7 @@ class ListTreeRecordItemView extends View {const childCollection = this.model.get('childCollection');- if (childCollection !== null) {+ if (childCollection != null) {this.createChildren();this.isUnfolded = true;this.afterUnfold();@@ -331,12 +337,18 @@ class ListTreeRecordItemView extends View {}}+ /**+ * @private+ */afterFold() {this.$el.find('a[data-action="fold"][data-id="'+this.model.id+'"]').addClass('hidden');this.$el.find('a[data-action="unfold"][data-id="'+this.model.id+'"]').removeClass('hidden');this.$el.find(' > .children').addClass('hidden');}+ /**+ * @private+ */afterUnfold() {this.$el.find('a[data-action="unfold"][data-id="'+this.model.id+'"]').addClass('hidden');this.$el.find('a[data-action="fold"][data-id="'+this.model.id+'"]').removeClass('hidden');@@ -367,15 +379,18 @@ class ListTreeRecordItemView extends View {return path;}*/- actionRemove() {- this.confirm({+ /**+ * @private+ */+ async actionRemove() {+ await this.confirm({message: this.translate('removeRecordConfirmation', 'messages', this.scope),confirmText: this.translate('Remove'),- }, () => {- this.model.destroy({wait: true})- .then(() => this.remove());-});++ await this.model.destroy({wait: true});++ this.remove();}/**diff --git a/client/src/views/record/list-tree.js b/client/src/views/record/list-tree.jsindex 4ed3cb28c5..07bb950b37 100644--- a/client/src/views/record/list-tree.js+++ b/client/src/views/record/list-tree.js@@ -209,6 +209,16 @@ class ListTreeRecordView extends ListRecordView {}});}++ this.listenTo(this.collection, 'model-sync', (/** import('model').default */m, /** Record */o) => {+ if (o.action === 'destroy') {+ const index = this.rowList.findIndex(it => it === m.id);++ if (index > -1) {+ this.rowList.splice(index, 1);+ }+ }+ });}onRemove() {@@ -242,8 +252,7 @@ class ListTreeRecordView extends ListRecordView {if (view.model.id === id) {view.setIsSelected();- }- else {+ } else {view.isSelected = false;}