diff --git a/client/res/templates/record/list-expanded.tpl b/client/res/templates/record/list-expanded.tpl index 6138f54451..d8ac1d39f3 100644 --- a/client/res/templates/record/list-expanded.tpl +++ b/client/res/templates/record/list-expanded.tpl @@ -79,5 +79,7 @@ {{/if}} {{else}} + {{#unless noDataDisabled}}
{{translate 'No Data'}}
+ {{/unless}} {{/if}} diff --git a/client/src/views/list.js b/client/src/views/list.js index 0912aeeb8a..61ef74c19b 100644 --- a/client/src/views/list.js +++ b/client/src/views/list.js @@ -646,27 +646,26 @@ class ListView extends MainView { }); } - if (fetch) { - view.getSelectAttributeList(selectAttributeList => { - if (this.options.mediator && this.options.mediator.abort) { - return; - } - - if (selectAttributeList) { - this.collection.data.select = selectAttributeList.join(','); - } - - Espo.Ui.notify(' ... '); - - this.collection.fetch({main: true}) - .then(() => Espo.Ui.notify(false)); - - }); + if (!fetch) { + view.render(); return; } - view.render(); + view.getSelectAttributeList(selectAttributeList => { + if (this.options.mediator && this.options.mediator.abort) { + return; + } + + if (selectAttributeList) { + this.collection.data.select = selectAttributeList.join(','); + } + + Espo.Ui.notify(' ... '); + + this.collection.fetch({main: true}) + .then(() => Espo.Ui.notify(false)); + }); }); } diff --git a/client/src/views/modals/related-list.js b/client/src/views/modals/related-list.js index e6fbf7200b..f0f4e456d3 100644 --- a/client/src/views/modals/related-list.js +++ b/client/src/views/modals/related-list.js @@ -299,9 +299,6 @@ class RelatedListModalView extends ModalView { } this.setupSearch(); - - this.wait(true); - this.setupList(); }); } @@ -376,13 +373,13 @@ class RelatedListModalView extends ModalView { } setupList() { - let viewName = + const viewName = this.listViewName || this.getMetadata().get(['clientDefs', this.scope, 'recordViews', 'listRelated']) || this.getMetadata().get(['clientDefs', this.scope, 'recordViews', 'list']) || 'views/record/list'; - this.createView('list', viewName, { + const promise = this.createView('list', viewName, { collection: this.collection, fullSelector: this.containerSelector + ' .list-container', rowActionsView: this.rowActionsView, @@ -402,6 +399,7 @@ class RelatedListModalView extends ModalView { this.getMetadata().get(['clientDefs', this.scope, 'listPagination']) || null, }, view => { + this.listenToOnce(view, 'select', model => { this.trigger('select', model); @@ -410,24 +408,26 @@ class RelatedListModalView extends ModalView { if (this.multiple) { this.listenTo(view, 'check', () => { - if (view.checkedList.length) { - this.enableButton('select'); - } else { + view.checkedList.length ? + this.enableButton('select') : this.disableButton('select'); - } }); - this.listenTo(view, 'select-all-results', () => { - this.enableButton('select'); - }); + this.listenTo(view, 'select-all-results', () => this.enableButton('select')); } - if (this.options.forceSelectAllAttributes || this.forceSelectAllAttributes) { - this.listenToOnce(view, 'after:build-rows', () => { - this.wait(false); - }); + const fetch = () => { + // Timeout to make notify work. + setTimeout(() => { + Espo.Ui.notify(' ... '); - this.collection.fetch(); + this.collection.fetch() + .then(() => Espo.Ui.notify(false)); + }, 1); + }; + + if (this.options.forceSelectAllAttributes || this.forceSelectAllAttributes) { + fetch(); return; } @@ -437,7 +437,7 @@ class RelatedListModalView extends ModalView { selectAttributeList.push('name'); } - let mandatorySelectAttributeList = this.options.mandatorySelectAttributeList || + const mandatorySelectAttributeList = this.options.mandatorySelectAttributeList || this.mandatorySelectAttributeList || []; mandatorySelectAttributeList.forEach(attribute => { @@ -450,13 +450,11 @@ class RelatedListModalView extends ModalView { this.collection.data.select = selectAttributeList.join(','); } - this.listenToOnce(view, 'after:build-rows', () => { - this.wait(false); - }); - - this.collection.fetch(); + fetch(); }); }); + + this.wait(promise); } // noinspection JSUnusedGlobalSymbols diff --git a/client/src/views/modals/select-records.js b/client/src/views/modals/select-records.js index df174cb438..a10db72673 100644 --- a/client/src/views/modals/select-records.js +++ b/client/src/views/modals/select-records.js @@ -183,7 +183,6 @@ class SelectRecordsModalView extends ModalView { } this.setupSearch(); - this.wait(true); this.setupList(); }); } @@ -234,11 +233,11 @@ class SelectRecordsModalView extends ModalView { } setupList() { - let viewName = this.getMetadata().get('clientDefs.' + this.scope + '.recordViews.listSelect') || + const viewName = this.getMetadata().get('clientDefs.' + this.scope + '.recordViews.listSelect') || this.getMetadata().get('clientDefs.' + this.scope + '.recordViews.list') || 'views/record/list'; - this.createView('list', viewName, { + const promise = this.createView('list', viewName, { collection: this.collection, fullSelector: this.containerSelector + ' .list-container', selectable: true, @@ -252,6 +251,7 @@ class SelectRecordsModalView extends ModalView { skipBuildRows: true, pagination: this.getMetadata().get(['clientDefs', this.scope, 'listPagination']) || null, }, view => { + this.listenToOnce(view, 'select', model => { this.trigger('select', model); @@ -273,10 +273,18 @@ class SelectRecordsModalView extends ModalView { }); } - if (this.options.forceSelectAllAttributes || this.forceSelectAllAttributes) { - this.listenToOnce(view, 'after:build-rows', () => this.wait(false)); + const fetch = () => { + // Timeout to make notify work. + setTimeout(() => { + Espo.Ui.notify(' ... '); - this.collection.fetch(); + this.collection.fetch() + .then(() => Espo.Ui.notify(false)); + }, 1); + }; + + if (this.options.forceSelectAllAttributes || this.forceSelectAllAttributes) { + fetch(); return; } @@ -299,11 +307,11 @@ class SelectRecordsModalView extends ModalView { this.collection.data.select = selectAttributeList.join(','); } - this.listenToOnce(view, 'after:build-rows', () => this.wait(false)); - - this.collection.fetch(); + fetch(); }); }); + + this.wait(promise); } create() { diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index 0f6f720b90..cc4f6a9eb9 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -946,6 +946,8 @@ class ListRecordView extends View { this.forceDisplayTopBar || displayTotalCount; + let noDataDisabled = this.noDataDisabled || this._renderEmpty; + return { scope: this.scope, entityType: this.entityType, @@ -972,7 +974,7 @@ class ListRecordView extends View { totalCountFormatted: this.getNumberUtil().formatInt(this.collection.total), moreCountFormatted: this.getNumberUtil().formatInt(moreCount), checkboxColumnWidth: this.checkboxColumnWidth, - noDataDisabled: this.noDataDisabled, + noDataDisabled: noDataDisabled, }; } @@ -1978,6 +1980,8 @@ class ListRecordView extends View { ); this.listenTo(this.collection, 'sync', (c, r, options) => { + this._renderEmpty = false; + if (this.hasView('modal') && this.getView('modal').isRendered()) { return; } @@ -2007,7 +2011,6 @@ class ListRecordView extends View { } this.checkedList = []; - this.allResultIsChecked = false; this.buildRows(() => { @@ -2020,6 +2023,8 @@ class ListRecordView extends View { if (!this.options.skipBuildRows) { this.buildRows(); } + + this._renderEmpty = this.options.skipBuildRows; } afterRender() { diff --git a/client/src/views/record/panels/relationship.js b/client/src/views/record/panels/relationship.js index d2246f640b..93b4b784a8 100644 --- a/client/src/views/record/panels/relationship.js +++ b/client/src/views/record/panels/relationship.js @@ -580,7 +580,6 @@ class RelationshipPanelView extends BottomPanelView { view.render(); this.listenTo(view, 'action', (event, element) => { - console.log(event, element); Espo.Utils.handleAction(this, event, element); });