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.
61 lines
1.4 KiB
61 lines
1.4 KiB
import ProjectService from '@/services/project.service'
|
|
|
|
export default {
|
|
namespaced: true,
|
|
|
|
state: () => ({
|
|
projects: [],
|
|
selected: []
|
|
}),
|
|
|
|
mutations: {
|
|
setProjectList(state, payload) {
|
|
state.projects = payload
|
|
},
|
|
createProject(state, project) {
|
|
state.projects.unshift(project)
|
|
},
|
|
deleteProject(state, projectId) {
|
|
state.projects = state.projects.filter(item => item.id !== projectId)
|
|
},
|
|
updateSelected(state, selected) {
|
|
state.selected = selected
|
|
},
|
|
resetSelected(state) {
|
|
state.selected = []
|
|
}
|
|
},
|
|
|
|
actions: {
|
|
getProjectList(context, config) {
|
|
return ProjectService.getProjectList()
|
|
.then((response) => {
|
|
context.commit('setProjectList', response)
|
|
})
|
|
.catch((error) => {
|
|
alert(error)
|
|
})
|
|
},
|
|
createProject({ commit }, project) {
|
|
ProjectService.createProject(project)
|
|
.then((response) => {
|
|
commit('createProject', response)
|
|
})
|
|
.catch((error) => {
|
|
alert(error)
|
|
})
|
|
},
|
|
deleteProject({ commit, state }, config) {
|
|
for (const project of state.selected) {
|
|
ProjectService.deleteProject(project.id)
|
|
.then((response) => {
|
|
commit('deleteProject', project.id)
|
|
})
|
|
.catch((error) => {
|
|
alert(error)
|
|
})
|
|
}
|
|
commit('resetSelected')
|
|
}
|
|
}
|
|
}
|