Browse Source

Enable to load search options

pull/897/head
Hironsan 4 years ago
parent
commit
2cf27e0099
3 changed files with 32 additions and 4 deletions
  1. 14
      frontend/components/organisms/layout/TheSideBar.vue
  2. 13
      frontend/layouts/annotation.vue
  3. 9
      frontend/store/projects.js

14
frontend/components/organisms/layout/TheSideBar.vue

@ -1,9 +1,9 @@
<template>
<v-list dense>
<v-btn
:to="to"
color="ms-4 my-1 mb-2 primary text-capitalize"
nuxt
@click="toLabeling"
>
<v-icon left>
mdi-play-circle-outline
@ -32,6 +32,8 @@
</template>
<script>
import { mapGetters } from 'vuex'
export default {
props: {
link: {
@ -60,14 +62,18 @@ export default {
},
computed: {
to() {
return `/projects/${this.$route.params.id}/${this.link}`
}
...mapGetters('projects', ['loadSearchOptions'])
},
methods: {
isVisible(item) {
return !item.adminOnly || this.role.is_project_admin
},
toLabeling() {
this.$router.push({
path: `/projects/${this.$route.params.id}/${this.link}`,
query: this.loadSearchOptions
})
}
}
}

13
frontend/layouts/annotation.vue

@ -121,6 +121,15 @@ export default {
},
current() {
return (this.page - 1) % this.limit
},
searchOptions() {
// a bit tricky.
// see https://github.com/vuejs/vue/issues/844#issuecomment-265315349
return JSON.stringify({
page: this.page,
q: this.q,
isChecked: this.filterOption
})
}
},
@ -140,6 +149,9 @@ export default {
this.setCurrent(this.current)
},
immediate: true
},
searchOptions() {
this.saveSearchOptions(JSON.parse(this.searchOptions))
}
},
@ -151,6 +163,7 @@ export default {
...mapActions('projects', ['setCurrentProject']),
...mapActions('documents', ['getDocumentList']),
...mapMutations('documents', ['setCurrent']),
...mapMutations('projects', ['saveSearchOptions']),
search() {
this.getDocumentList({
projectId: this.$route.params.id,

9
frontend/store/projects.js

@ -209,6 +209,10 @@ export const getters = {
} else {
return []
}
},
loadSearchOptions(state) {
const checkpoint = JSON.parse(localStorage.getItem('checkpoint')) || {}
return checkpoint[state.current.id] ? checkpoint[state.current.id] : { page: 1 }
}
}
@ -237,6 +241,11 @@ export const mutations = {
},
setCurrent(state, payload) {
state.current = payload
},
saveSearchOptions(state, options) {
const checkpoint = {}
checkpoint[state.current.id] = options
localStorage.setItem('checkpoint', JSON.stringify(checkpoint))
}
}

Loading…
Cancel
Save