Skip to content

Commit 1b2fd2f

Browse files
authored
Merge pull request doccano#480 from doccano/feature-page-selector
Enable to move any page
2 parents bd9f729 + e079798 commit 1b2fd2f

File tree

2 files changed

+53
-6
lines changed

2 files changed

+53
-6
lines changed

frontend/components/containers/annotation/Paginator.vue

+49-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,27 @@
11
<template>
22
<div class="v-data-footer">
3-
<span>
4-
{{ page }} of {{ total }}
5-
</span>
3+
<v-edit-dialog
4+
large
5+
persistent
6+
@save="changePage"
7+
>
8+
<span>{{ page }} of {{ total }}</span>
9+
<template v-slot:input>
10+
<div class="mt-4 title">
11+
Move Page
12+
</div>
13+
</template>
14+
<template v-slot:input>
15+
<v-text-field
16+
v-model="newPage"
17+
:rules="rules"
18+
label="Edit"
19+
single-line
20+
counter
21+
autofocus
22+
/>
23+
</template>
24+
</v-edit-dialog>
625
<v-tooltip bottom>
726
<template v-slot:activator="{ on }">
827
<v-btn
@@ -46,9 +65,27 @@ import { mapState, mapActions, mapMutations, mapGetters } from 'vuex'
4665
Vue.use(require('vue-shortkey'))
4766
4867
export default {
68+
data() {
69+
return {
70+
editedPage: null,
71+
rules: [
72+
value => (value && parseInt(value, 10) > 0 && parseInt(value, 10) <= this.total) || 'Invalid page number!'
73+
]
74+
}
75+
},
76+
4977
computed: {
5078
...mapState('documents', ['items', 'total']),
51-
...mapGetters('pagination', ['current', 'limit', 'offset', 'page'])
79+
...mapGetters('pagination', ['current', 'limit', 'offset', 'page']),
80+
newPage: {
81+
get: function () {
82+
return this.page
83+
},
84+
set: function (newValue) {
85+
const value = parseInt(newValue, 10)
86+
this.editedPage = value
87+
}
88+
}
5289
},
5390
5491
watch: {
@@ -77,8 +114,14 @@ export default {
77114
78115
methods: {
79116
...mapActions('documents', ['getDocumentList']),
80-
...mapActions('pagination', ['prevPage', 'nextPage', 'initPage']),
81-
...mapMutations('documents', ['setCurrent', 'updateSearchOptions'])
117+
...mapActions('pagination', ['prevPage', 'nextPage', 'initPage', 'movePage']),
118+
...mapMutations('documents', ['setCurrent', 'updateSearchOptions']),
119+
changePage() {
120+
if (!this.editedPage || this.editedPage < 0 || this.editedPage > this.total) {
121+
return
122+
}
123+
this.movePage(this.editedPage)
124+
}
82125
}
83126
}
84127
</script>

frontend/store/pagination.js

+4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ export const actions = {
4848
commit('updatePage', page)
4949
commit('savePage')
5050
},
51+
movePage({ commit }, newPage) {
52+
commit('updatePage', newPage)
53+
commit('savePage')
54+
},
5155
initPage({ commit }, payload) {
5256
commit('setProjectId', payload.projectId)
5357
commit('loadPage')

0 commit comments

Comments
 (0)