mirror of https://github.com/doccano/doccano.git
pythondatasetsactive-learningtext-annotationdatasetnatural-language-processingdata-labelingmachine-learningannotation-tool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.2 KiB
55 lines
1.2 KiB
export const state = () => ({
|
|
limit: 10,
|
|
page: 1,
|
|
projectId: null
|
|
})
|
|
|
|
export const getters = {
|
|
offset(state) {
|
|
return Math.floor((state.page - 1) / state.limit) * state.limit
|
|
},
|
|
current(state) {
|
|
return (state.page - 1) % state.limit
|
|
},
|
|
page(state) {
|
|
return state.page
|
|
},
|
|
limit(state) {
|
|
return state.limit
|
|
}
|
|
}
|
|
|
|
export const mutations = {
|
|
updatePage(state, page) {
|
|
state.page = page
|
|
},
|
|
savePage(state) {
|
|
const checkpoint = {}
|
|
checkpoint[state.projectId] = state.page
|
|
localStorage.setItem('checkpoint', JSON.stringify(checkpoint))
|
|
},
|
|
loadPage(state) {
|
|
const checkpoint = JSON.parse(localStorage.getItem('checkpoint'))
|
|
state.page = checkpoint[state.projectId] ? checkpoint[state.projectId] : 1
|
|
},
|
|
setProjectId(state, projectId) {
|
|
state.projectId = projectId
|
|
}
|
|
}
|
|
|
|
export const actions = {
|
|
prevPage({ commit, state }) {
|
|
const page = Math.max(state.page - 1, 1)
|
|
commit('updatePage', page)
|
|
commit('savePage')
|
|
},
|
|
nextPage({ commit, state }, total) {
|
|
const page = Math.min(state.page + 1, total)
|
|
commit('updatePage', page)
|
|
commit('savePage')
|
|
},
|
|
initPage({ commit }, payload) {
|
|
commit('setProjectId', payload.projectId)
|
|
commit('loadPage')
|
|
}
|
|
}
|