From 7297e0eb83e76ba2fedce08ea7e93e5cf329db3b Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Sun, 24 Mar 2024 16:58:26 +0200 Subject: [PATCH] pagination display top bar if out of bound --- client/res/templates/record/list.tpl | 427 +++++++++++---------- client/src/collection.js | 2 +- client/src/helpers/list/misc/sticky-bar.js | 4 + client/src/views/record/list.js | 10 +- 4 files changed, 228 insertions(+), 215 deletions(-) diff --git a/client/res/templates/record/list.tpl b/client/res/templates/record/list.tpl index bd6866abbf..19160268d4 100644 --- a/client/res/templates/record/list.tpl +++ b/client/res/templates/record/list.tpl @@ -1,232 +1,235 @@ -{{#if collection.models.length}} - {{#if topBar}} -
- {{#if displayActionsButtonGroup}} -
- {{#if massActionList}} - - {{/if}} - {{#if buttonList.length}} - {{#each buttonList}} - {{button - name - scope=../scope - label=label - style=style - hidden=hidden - class='list-action-item' - }} - {{/each}} - {{/if}} - -
- {{#if dropdownItemList.length}} - - - {{/if}} -
- - {{#if massActionList}} - - {{/if}} -
- - + + + {{/if}} {{#if hasPagination}} - {{{paginationSticky}}} + {{{pagination}}} {{/if}} -
- {{/if}} - {{#if hasPagination}} - {{{pagination}}} - {{/if}} + {{#if settings}} +
{{{settings}}}
+ {{/if}} - {{#if settings}} -
{{{settings}}}
- {{/if}} - - {{#if displayTotalCount}} -
+ {{#if displayTotalCount}} +
{{totalCountFormatted}} +
+ {{/if}}
- {{/if}} - {{/if}} -
- - {{#if header}} - - - {{#if checkboxes}} - - {{/if}} - {{#each headerDefs}} - - {{#each rowList}} - - {{{var this ../this}}} - - {{/each}} - -
- - {{#unless checkAllResultDisabled}} - - {{/unless}} - - {{#if this.isSortable}} - {{label}} - {{#if this.isSorted}} - {{#unless this.isDesc}} - - {{else}} - - {{/unless}} - {{/if}} - {{else}} - {{#if html}} - {{{html}}} - {{else}} - {{label}} - {{/if}} +{{#if collectionLength}} +
+ + {{#if header}} + + + {{#if checkboxes}} + {{/if}} - - {{/each}} - - + {{#each headerDefs}} + + {{/each}} + + + {{/if}} + + {{#each rowList}} + + {{{var this ../this}}} + + {{/each}} + +
+ + {{#unless checkAllResultDisabled}} + + {{/unless}} +
+ {{#if this.isSortable}} + {{label}} + {{#if this.isSorted}} + {{#unless this.isDesc}} + + {{else}} + + {{/unless}} + {{/if}} + {{else}} + {{#if html}} + {{{html}}} + {{else}} + {{label}} + {{/if}} + {{/if}} +
+ + {{#if showMoreEnabled}} + {{/if}} -
- - {{#if showMoreEnabled}} - - {{/if}} -
- + {{else}} {{#unless noDataDisabled}}
{{translate 'No Data'}}
diff --git a/client/src/collection.js b/client/src/collection.js index 228abe0612..d5410f45fe 100644 --- a/client/src/collection.js +++ b/client/src/collection.js @@ -666,7 +666,7 @@ class Collection { * @returns {Promise} */ previousPage() { - return this.setOffset(this.offset - this.maxSize); + return this.setOffset(Math.max(0, this.offset - this.maxSize)); } /** diff --git a/client/src/helpers/list/misc/sticky-bar.js b/client/src/helpers/list/misc/sticky-bar.js index e521b213ab..198dde70f6 100644 --- a/client/src/helpers/list/misc/sticky-bar.js +++ b/client/src/helpers/list/misc/sticky-bar.js @@ -82,6 +82,10 @@ class StickyBarHelper { const $stickedBar = this.$stickedBar = this.$el.find('.sticked-bar'); const $middle = this.$el.find('> .list'); + if (!$middle.get(0)) { + return; + } + const $window = $(window); let $scrollable = $window; diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js index 3b39de2c41..ae220e17fe 100644 --- a/client/src/views/record/list.js +++ b/client/src/views/record/list.js @@ -874,18 +874,24 @@ class ListRecordView extends View { const displayTotalCount = this.displayTotalCount && this.collection.total > 0 && !this.pagination; - const topBar = + let topBar = this.collection.length && ( this.pagination || this.checkboxes || (this.buttonList.length && !this.buttonsDisabled) || (this.dropdownItemList.length && !this.buttonsDisabled) || this.forceDisplayTopBar || - displayTotalCount; + displayTotalCount + ); + + if (!topBar && this.pagination && !this.collection.length && this.collection.offset > 0) { + topBar = true; + } const noDataDisabled = this.noDataDisabled || this._renderEmpty; return { scope: this.scope, + collectionLength: this.collection.models.length, entityType: this.entityType, header: this.header, headerDefs: this._getHeaderDefs(),