Alerts
2 years ago
BoxActions
2 years ago
PaymentsPage
2 years ago
TableColumns
2 years ago
VuiBoxes
2 years ago
ActionsWithFilters.vue
2 years ago
ChooseAction.vue
2 years ago
ClearFiltersButton.vue
2 years ago
DetailsTableWithStore.vue
2 years ago
EntriesList.vue
2 years ago
EntriesTable.vue
2 years ago
EntriesTableSkeleton.vue
2 years ago
EntryColumnList.vue
2 years ago
EntryColumnsTable.vue
2 years ago
FormBuilderPage.vue
2 years ago
PageActions.vue
2 years ago
PostBoxContainer.vue
2 years ago
PostBoxGrid.vue
2 years ago
PostBoxSimple.vue
2 years ago
PostBoxSkeleton.vue
2 years ago
PostBoxTable.vue
2 years ago
SideBarBoxes.vue
2 years ago
TablePagination.vue
2 years ago
TablePagination.vue
116 lines
| 1 | <template> |
| 2 | <div class="jfb-pagination"> |
| 3 | <span class="jfb-pagination--results"> |
| 4 | {{ |
| 5 | __s( |
| 6 | `Showing %d - %d of %d results.`, |
| 7 | 'jet-form-builder', |
| 8 | queryState.itemsFrom, |
| 9 | queryState.itemsTo, |
| 10 | queryState.total, |
| 11 | ) |
| 12 | }} |
| 13 | </span> |
| 14 | <cx-vui-pagination |
| 15 | v-if="queryState.limit < queryState.total" |
| 16 | :total="queryState.total" |
| 17 | :page-size="queryState.limit" |
| 18 | :current="queryState.currentPage" |
| 19 | :disabled="isLoading" |
| 20 | @on-change="changePage" |
| 21 | ></cx-vui-pagination> |
| 22 | <div class="jfb-pagination--sort"> |
| 23 | <cx-vui-input |
| 24 | :label="__( 'Results per page', 'jet-form-builder' )" |
| 25 | @on-input-change="changeLimit" |
| 26 | :value="queryState.limit" |
| 27 | type="number" |
| 28 | :min="1" |
| 29 | :max="queryState.total" |
| 30 | :disabled="isLoading" |
| 31 | ></cx-vui-input> |
| 32 | </div> |
| 33 | </div> |
| 34 | </template> |
| 35 | |
| 36 | <script> |
| 37 | import ScopeStoreMixin from '../mixins/ScopeStoreMixin'; |
| 38 | |
| 39 | const { i18n, GetIncoming } = JetFBMixins; |
| 40 | |
| 41 | const { mapState, mapGetters } = Vuex; |
| 42 | |
| 43 | export default { |
| 44 | name: 'TablePagination', |
| 45 | mixins: [ i18n, GetIncoming, ScopeStoreMixin ], |
| 46 | computed: { |
| 47 | queryState() { |
| 48 | return this.getter( 'queryState' ); |
| 49 | }, |
| 50 | isLoading() { |
| 51 | return this.getter( 'isLoading', 'page' ) |
| 52 | } |
| 53 | }, |
| 54 | methods: { |
| 55 | changeLimit( { target: { value } } ) { |
| 56 | if ( this.isLoading ) { |
| 57 | return; |
| 58 | } |
| 59 | if ( this.queryState.total < value || ! value ) { |
| 60 | value = this.queryState.total; |
| 61 | } |
| 62 | this.commit( 'setLimit', value ); |
| 63 | this.commit( 'setCurrentPage', 1 ); |
| 64 | this.dispatch( 'fetchPage' ); |
| 65 | }, |
| 66 | changePage( pageNum ) { |
| 67 | if ( this.isLoading ) { |
| 68 | return; |
| 69 | } |
| 70 | this.commit( 'setCurrentPage', pageNum ); |
| 71 | this.dispatch( 'fetchPage' ); |
| 72 | }, |
| 73 | }, |
| 74 | }; |
| 75 | </script> |
| 76 | |
| 77 | <style lang="scss"> |
| 78 | |
| 79 | .jfb-pagination { |
| 80 | display: flex; |
| 81 | justify-content: space-between; |
| 82 | align-items: center; |
| 83 | padding: 1.5em; |
| 84 | margin-bottom: unset; |
| 85 | |
| 86 | &--sort { |
| 87 | .cx-vui-component { |
| 88 | column-gap: 1em; |
| 89 | justify-content: center; |
| 90 | align-items: center; |
| 91 | padding: unset; |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | .cx-vui-input { |
| 96 | background-color: white; |
| 97 | } |
| 98 | |
| 99 | li.cx-vui-pagination-item { |
| 100 | width: 1.2em; |
| 101 | height: 1.5em; |
| 102 | border-radius: 5px; |
| 103 | font-size: 1.15em; |
| 104 | transition: all 0.3s ease-in-out; |
| 105 | |
| 106 | &-active, &:hover { |
| 107 | box-shadow: 0 5px 5px -1px #bdbdbd; |
| 108 | background-color: #007cba; |
| 109 | color: #f5f5f5; |
| 110 | border-color: #007cba; |
| 111 | } |
| 112 | } |
| 113 | |
| 114 | } |
| 115 | |
| 116 | </style> |