diff --git a/client/res/templates/record/list-pagination.tpl b/client/res/templates/record/list-pagination.tpl index 6c74ef6396..f9e05bbb20 100644 --- a/client/res/templates/record/list-pagination.tpl +++ b/client/res/templates/record/list-pagination.tpl @@ -1,18 +1,22 @@
diff --git a/client/src/collection.js b/client/src/collection.js index aaf1d25bc0..645e536473 100644 --- a/client/src/collection.js +++ b/client/src/collection.js @@ -123,6 +123,10 @@ define('collection', [], function () { lastPage: function () { let offset = this.total - this.total % this.maxSize; + if (offset === this.total) { + offset = this.total - this.maxSize; + } + this.setOffset(offset); }, @@ -131,7 +135,7 @@ define('collection', [], function () { throw new RangeError('offset can not be less than 0'); } - if (offset > this.total) { + if (offset > this.total && this.total !== -1 && offset > 0) { throw new RangeError('offset can not be larger than total count'); } diff --git a/client/src/views/list.js b/client/src/views/list.js index 8d511ff185..881a5f678e 100644 --- a/client/src/views/list.js +++ b/client/src/views/list.js @@ -362,6 +362,13 @@ define('views/list', ['views/main', 'search-manager'], function (Dep, SearchMana o.keepCurrentRootUrl = true; } + if ( + this.getConfig().get('listPagination') || + this.getMetadata().get(['clientDefs', this.scope, 'listPagination']) + ) { + o.pagination = true; + } + this.prepareRecordViewOptions(o); var listViewName = this.getRecordViewName(); diff --git a/client/src/views/modals/related-list.js b/client/src/views/modals/related-list.js index 40293931d9..30d980e547 100644 --- a/client/src/views/modals/related-list.js +++ b/client/src/views/modals/related-list.js @@ -321,6 +321,9 @@ define('views/modals/related-list', ['views/modal', 'search-manager'], function rowActionsOptions: { unlinkDisabled: this.unlinkDisabled, }, + pagination: this.getConfig().get('listPagination') || + this.getMetadata().get(['clientDefs', this.scope, 'listPagination']) || + null, }, function (view) { this.listenToOnce(view, 'select', function (model) { this.trigger('select', model); diff --git a/client/src/views/record/list-pagination.js b/client/src/views/record/list-pagination.js index 04df9d1777..49fb09c1d1 100644 --- a/client/src/views/record/list-pagination.js +++ b/client/src/views/record/list-pagination.js @@ -34,7 +34,8 @@ define('views/record/list-pagination', 'view', function (Dep) { data: function () { var previous = this.collection.offset > 0; - var next = this.collection.total - this.collection.offset > this.collection.maxSize; + var next = this.collection.total - this.collection.offset > this.collection.maxSize || + this.collection.total === -1; return { total: this.collection.total, @@ -42,8 +43,9 @@ define('views/record/list-pagination', 'view', function (Dep) { to: this.collection.offset + this.collection.length, previous: previous, next: next, + noTotal: this.collection.total === -1 || this.collection.total === -2, }; - } + }, }); }); diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index 2a48b7f086..3baa5e93b5 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -420,7 +420,6 @@ define('views/record/list', 'view', function (Dep) { data: function () { var paginationTop = this.pagination === 'both' || - this.pagination === true || this.pagination === 'top'; var paginationBottom = this.pagination === 'both' || @@ -490,7 +489,10 @@ define('views/record/list', 'view', function (Dep) { this.header = false; } - this.pagination = _.isUndefined(this.options.pagination) ? this.pagination : this.options.pagination; + this.pagination = _.isUndefined(this.options.pagination) || this.options.pagination === null ? + this.pagination : + this.options.pagination; + this.checkboxes = _.isUndefined(this.options.checkboxes) ? this.checkboxes : this.options.checkboxes; this.selectable = _.isUndefined(this.options.selectable) ? this.selectable : this.options.selectable; diff --git a/client/src/views/record/search.js b/client/src/views/record/search.js index ee737bec1e..451af91073 100644 --- a/client/src/views/record/search.js +++ b/client/src/views/record/search.js @@ -787,6 +787,7 @@ define('views/record/search', 'view', function (Dep) { this.collection.abortLastFetch(); this.collection.reset(); this.collection.where = this.searchManager.getWhere(); + this.collection.offset = 0; Espo.Ui.notify(this.translate('pleaseWait', 'messages')); diff --git a/frontend/less/espo/custom.less b/frontend/less/espo/custom.less index 5725ccaf8c..5a1ffcf810 100644 --- a/frontend/less/espo/custom.less +++ b/frontend/less/espo/custom.less @@ -675,10 +675,20 @@ ul.dropdown-menu > li.checkbox:last-child { .list-container .pagination { margin: 0; + + a.pagination-btn { + width: 40px; + text-align: center; + } + + a.pagination-btn-middle { + min-width: 130px; + text-align: center; + } } .list-bottom-bar { - margin-top: 8px; + margin-top: 10px; } .radio-container {