Skip to content

Commit 5d12431

Browse files
committed
Enable to paginate on mobile page
1 parent 20d1272 commit 5d12431

File tree

6 files changed

+105
-32
lines changed

6 files changed

+105
-32
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<template>
2+
<v-bottom-navigation
3+
absolute
4+
hide-on-scroll
5+
background-color="transparent"
6+
class="elevation-0"
7+
>
8+
<v-btn @click="prevPage">
9+
<span>Prev</span>
10+
<v-icon>mdi-chevron-left</v-icon>
11+
</v-btn>
12+
13+
<!-- <v-btn @click="approveDocument">
14+
<span>Done</span>
15+
<v-icon v-if="approved">
16+
mdi-check
17+
</v-icon>
18+
<v-icon v-else>
19+
mdi-close
20+
</v-icon>
21+
</v-btn>
22+
23+
<v-btn value="guide">
24+
<span>Guideline</span>
25+
<v-icon>mdi-book-open-outline</v-icon>
26+
</v-btn> -->
27+
28+
<v-btn @click="nextPage">
29+
<span>Next</span>
30+
<v-icon>mdi-chevron-right</v-icon>
31+
</v-btn>
32+
</v-bottom-navigation>
33+
</template>
34+
35+
<script>
36+
import { mapState, mapActions, mapMutations } from 'vuex'
37+
38+
export default {
39+
data() {
40+
return {
41+
page: 1,
42+
limit: 10
43+
}
44+
},
45+
46+
computed: {
47+
...mapState('documents', ['items', 'total']),
48+
49+
offset() {
50+
return Math.floor((this.page - 1) / this.limit) * this.limit
51+
},
52+
53+
current() {
54+
return (this.page - 1) % this.limit
55+
}
56+
},
57+
58+
watch: {
59+
page() {
60+
const checkpoint = {}
61+
checkpoint[this.$route.params.id] = this.page
62+
localStorage.setItem('checkpoint', JSON.stringify(checkpoint))
63+
},
64+
offset() {
65+
this.updateSearchOptions({
66+
limit: this.limit,
67+
offset: this.offset
68+
})
69+
this.getDocumentList({
70+
projectId: this.$route.params.id
71+
})
72+
},
73+
current() {
74+
this.setCurrent(this.current)
75+
}
76+
},
77+
78+
created() {
79+
const checkpoint = JSON.parse(localStorage.getItem('checkpoint'))
80+
this.page = checkpoint[this.$route.params.id] ? checkpoint[this.$route.params.id] : 1
81+
this.getDocumentList({
82+
projectId: this.$route.params.id
83+
})
84+
},
85+
86+
methods: {
87+
...mapActions('documents', ['getDocumentList']),
88+
...mapMutations('documents', ['setCurrent', 'updateSearchOptions']),
89+
prevPage() {
90+
this.page = Math.max(this.page - 1, 1)
91+
},
92+
nextPage() {
93+
this.page = Math.min(this.page + 1, this.total)
94+
}
95+
}
96+
}
97+
</script>

frontend/components/organisms/annotation/BottomNavigator.vue

Lines changed: 0 additions & 28 deletions
This file was deleted.

frontend/pages/projects/_id/sequence-labeling/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ import ApproveButton from '@/components/containers/annotation/ApproveButton'
4343
import GuidelineButton from '@/components/containers/annotation/GuidelineButton'
4444
import FilterButton from '@/components/containers/annotation/FilterButton'
4545
import MetadataBox from '@/components/organisms/annotation/MetadataBox'
46-
import BottomNavigator from '@/components/organisms/annotation/BottomNavigator'
46+
import BottomNavigator from '@/components/containers/annotation/BottomNavigator'
4747
4848
export default {
4949
layout: 'annotation',

frontend/pages/projects/_id/sequence-to-sequence/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import Seq2seqContainer from '~/components/containers/annotation/Seq2seqContaine
3535
import Paginator from '~/components/containers/annotation/Paginator'
3636
import GuidelineButton from '@/components/containers/annotation/GuidelineButton'
3737
import MetadataBox from '@/components/organisms/annotation/MetadataBox'
38-
import BottomNavigator from '@/components/organisms/annotation/BottomNavigator'
38+
import BottomNavigator from '@/components/containers/annotation/BottomNavigator'
3939
4040
export default {
4141
layout: 'annotation',

frontend/pages/projects/_id/text-classification/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import TextClassification from '~/components/containers/annotation/TextClassific
3535
import Paginator from '~/components/containers/annotation/Paginator'
3636
import GuidelineButton from '@/components/containers/annotation/GuidelineButton'
3737
import MetadataBox from '@/components/organisms/annotation/MetadataBox'
38-
import BottomNavigator from '@/components/organisms/annotation/BottomNavigator'
38+
import BottomNavigator from '@/components/containers/annotation/BottomNavigator'
3939
4040
export default {
4141
layout: 'annotation',

frontend/store/documents.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export const getters = {
2121
return state.selected.length > 0
2222
},
2323
approved(state) {
24-
return state.items[state.current].annotation_approver !== null
24+
if (state.items[state.current]) {
25+
return state.items[state.current].annotation_approver !== null
26+
} else {
27+
return false
28+
}
2529
},
2630
currentDoc(state) {
2731
return state.items[state.current]

0 commit comments

Comments
 (0)