|
1 | 1 | <template>
|
2 | 2 | <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> |
6 | 25 | <v-tooltip bottom>
|
7 | 26 | <template v-slot:activator="{ on }">
|
8 | 27 | <v-btn
|
@@ -46,9 +65,27 @@ import { mapState, mapActions, mapMutations, mapGetters } from 'vuex'
|
46 | 65 | Vue.use(require('vue-shortkey'))
|
47 | 66 |
|
48 | 67 | 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 | +
|
49 | 77 | computed: {
|
50 | 78 | ...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 | + } |
52 | 89 | },
|
53 | 90 |
|
54 | 91 | watch: {
|
@@ -77,8 +114,14 @@ export default {
|
77 | 114 |
|
78 | 115 | methods: {
|
79 | 116 | ...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 | + } |
82 | 125 | }
|
83 | 126 | }
|
84 | 127 | </script>
|
0 commit comments