feat(UI): ability to manually insert page number in DATA tabs, closes #65

This commit is contained in:
Fabio Di Stasio 2021-06-19 12:13:09 +02:00
parent e579f37438
commit e2ebb04a90
2 changed files with 48 additions and 8 deletions

View File

@ -41,8 +41,23 @@
> >
<i class="mdi mdi-24px mdi-skip-previous" /> <i class="mdi mdi-24px mdi-skip-previous" />
</button> </button>
<div class="btn btn-dark btn-sm mr-0 text-bold c-auto px-2"> <div class="dropdown" :class="{'active': isPageMenu}">
{{ page }} <div class="btn-group" @click="openPageMenu">
<div class="btn btn-dark btn-sm mr-0 dropdown-toggle text-bold px-3">
{{ page }}
</div>
<div class="menu px-3">
<span>{{ $t('message.pageNumber') }}</span>
<input
ref="pageSelect"
v-model="pageProxy"
type="number"
min="1"
class="form-input"
@blur="setPageNumber"
>
</div>
</div>
</div> </div>
<button <button
class="btn btn-dark btn-sm mr-0" class="btn btn-dark btn-sm mr-0"
@ -172,6 +187,7 @@ export default {
return { return {
tabUid: 'data', tabUid: 'data',
isQuering: false, isQuering: false,
isPageMenu: false,
results: [], results: [],
lastTable: null, lastTable: null,
isAddModal: false, isAddModal: false,
@ -179,7 +195,8 @@ export default {
autorefreshTimer: 0, autorefreshTimer: 0,
refreshInterval: null, refreshInterval: null,
sortParams: {}, sortParams: {},
page: 1 page: 1,
pageProxy: 1
}; };
}, },
computed: { computed: {
@ -229,8 +246,11 @@ export default {
this.$refs.queryTable.resetSort(); this.$refs.queryTable.resetSort();
} }
}, },
page () { page (val, oldVal) {
this.getTableData(); if (val && val > 0 && val !== oldVal) {
this.pageProxy = this.page;
this.getTableData();
}
}, },
isSelected (val) { isSelected (val) {
if (val && this.lastTable !== this.table) { if (val && this.lastTable !== this.table) {
@ -292,11 +312,30 @@ export default {
this.sortParams = sortParams; this.sortParams = sortParams;
this.getTableData(sortParams); this.getTableData(sortParams);
}, },
openPageMenu () {
if (this.isQuering) return;
this.isPageMenu = true;
if (this.isPageMenu)
setTimeout(() => this.$refs.pageSelect.focus(), 20);
},
setPageNumber () {
this.isPageMenu = false;
if (this.pageProxy > 0)
this.page = this.pageProxy;
else
this.pageProxy = this.page;
},
pageChange (direction) { pageChange (direction) {
if (this.isQuering) return; if (this.isQuering) return;
if (direction === 'next' && (this.results.length && this.results[0].rows.length === this.limit)) if (direction === 'next' && (this.results.length && this.results[0].rows.length === this.limit)) {
this.page++; if (!this.page)
this.page = 2;
else
this.page++;
}
else if (direction === 'prev' && this.page > 1) else if (direction === 'prev' && this.page > 1)
this.page--; this.page--;
}, },

View File

@ -215,7 +215,8 @@ module.exports = {
deleteSchema: 'Delete schema', deleteSchema: 'Delete schema',
markdownSupported: 'Markdown supported', markdownSupported: 'Markdown supported',
plantATree: 'Plant a Tree', plantATree: 'Plant a Tree',
dataTabPageSize: 'DATA tab page size' dataTabPageSize: 'DATA tab page size',
pageNumber: 'Page number'
}, },
faker: { faker: {
address: 'Address', address: 'Address',