list impr

This commit is contained in:
Yuri Kuznetsov
2023-07-27 13:15:01 +03:00
parent 73121fadf7
commit 1ae22f929d
6 changed files with 63 additions and 52 deletions
@@ -79,5 +79,7 @@
{{/if}}
{{else}}
{{#unless noDataDisabled}}
<div class="no-data">{{translate 'No Data'}}</div>
{{/unless}}
{{/if}}
+16 -17
View File
@@ -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));
});
});
}
+21 -23
View File
@@ -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
+17 -9
View File
@@ -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() {
+7 -2
View File
@@ -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() {
@@ -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);
});