Skip to content

Commit

Permalink
feat(UI): ability to manually insert page number in DATA tabs, closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fabio286 committed Jun 19, 2021
1 parent e579f37 commit e2ebb04
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 8 deletions.
53 changes: 46 additions & 7 deletions src/renderer/components/WorkspaceTableTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,23 @@
>
<i class="mdi mdi-24px mdi-skip-previous" />
</button>
<div class="btn btn-dark btn-sm mr-0 text-bold c-auto px-2">
{{ page }}
<div class="dropdown" :class="{'active': isPageMenu}">
<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>
<button
class="btn btn-dark btn-sm mr-0"
Expand Down Expand Up @@ -172,14 +187,16 @@ export default {
return {
tabUid: 'data',
isQuering: false,
isPageMenu: false,
results: [],
lastTable: null,
isAddModal: false,
isFakerModal: false,
autorefreshTimer: 0,
refreshInterval: null,
sortParams: {},
page: 1
page: 1,
pageProxy: 1
};
},
computed: {
Expand Down Expand Up @@ -229,8 +246,11 @@ export default {
this.$refs.queryTable.resetSort();
}
},
page () {
this.getTableData();
page (val, oldVal) {
if (val && val > 0 && val !== oldVal) {
this.pageProxy = this.page;
this.getTableData();
}
},
isSelected (val) {
if (val && this.lastTable !== this.table) {
Expand Down Expand Up @@ -292,11 +312,30 @@ export default {
this.sortParams = 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) {
if (this.isQuering) return;
if (direction === 'next' && (this.results.length && this.results[0].rows.length === this.limit))
this.page++;
if (direction === 'next' && (this.results.length && this.results[0].rows.length === this.limit)) {
if (!this.page)
this.page = 2;
else
this.page++;
}
else if (direction === 'prev' && this.page > 1)
this.page--;
},
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/i18n/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ module.exports = {
deleteSchema: 'Delete schema',
markdownSupported: 'Markdown supported',
plantATree: 'Plant a Tree',
dataTabPageSize: 'DATA tab page size'
dataTabPageSize: 'DATA tab page size',
pageNumber: 'Page number'
},
faker: {
address: 'Address',
Expand Down

0 comments on commit e2ebb04

Please sign in to comment.