mirror of https://github.com/doccano/doccano.git
Hironsan
5 years ago
2 changed files with 108 additions and 0 deletions
Unified View
Diff Options
@ -0,0 +1,32 @@ |
|||||
|
import ApiService from '@/services/api.service' |
||||
|
|
||||
|
class MemberService { |
||||
|
constructor() { |
||||
|
this.request = new ApiService() |
||||
|
} |
||||
|
|
||||
|
getMemberList(projectId) { |
||||
|
return this.request.get(`/projects/${projectId}/users`) |
||||
|
} |
||||
|
|
||||
|
addMember(projectId, userId, role) { |
||||
|
const data = { |
||||
|
id: userId, |
||||
|
role |
||||
|
} |
||||
|
return this.request.post(`/projects/${projectId}/users`, data) |
||||
|
} |
||||
|
|
||||
|
deleteMember(projectId, userId) { |
||||
|
return this.request.delete(`/projects/${projectId}/users/${userId}`) |
||||
|
} |
||||
|
|
||||
|
updateMemberRole(projectId, userId, role) { |
||||
|
const data = { |
||||
|
role |
||||
|
} |
||||
|
return this.request.patch(`/projects/${projectId}/users/${userId}`, data) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export default new MemberService() |
@ -0,0 +1,76 @@ |
|||||
|
import LabelService from '@/services/label.service' |
||||
|
|
||||
|
export const state = () => ({ |
||||
|
items: [], |
||||
|
selected: [] |
||||
|
}) |
||||
|
|
||||
|
export const getters = { |
||||
|
isLabelSelected(state) { |
||||
|
return state.selected.length > 0 |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export const mutations = { |
||||
|
setLabelList(state, payload) { |
||||
|
state.items = payload |
||||
|
}, |
||||
|
addLabel(state, label) { |
||||
|
state.items.unshift(label) |
||||
|
}, |
||||
|
deleteLabel(state, labelId) { |
||||
|
state.items = state.items.filter(item => item.id !== labelId) |
||||
|
}, |
||||
|
updateSelected(state, selected) { |
||||
|
state.selected = selected |
||||
|
}, |
||||
|
updateLabel(state, label) { |
||||
|
const item = state.items.find(item => item.id === label.id) |
||||
|
Object.assign(item, label) |
||||
|
}, |
||||
|
resetSelected(state) { |
||||
|
state.selected = [] |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export const actions = { |
||||
|
getLabelList(context, config) { |
||||
|
return LabelService.getLabelList() |
||||
|
.then((response) => { |
||||
|
context.commit('setLabelList', response) |
||||
|
}) |
||||
|
.catch((error) => { |
||||
|
alert(error) |
||||
|
}) |
||||
|
}, |
||||
|
addMember({ commit }, data) { |
||||
|
LabelService.addLabel(data.projectId, data.labelId, data) |
||||
|
.then((response) => { |
||||
|
commit('addLabel', response) |
||||
|
}) |
||||
|
.catch((error) => { |
||||
|
alert(error) |
||||
|
}) |
||||
|
}, |
||||
|
updateLabel({ commit }, data) { |
||||
|
LabelService.updateLabel(data.projectId, data.labelId, data) |
||||
|
.then((response) => { |
||||
|
commit('updateLabel', response) |
||||
|
}) |
||||
|
.catch((error) => { |
||||
|
alert(error) |
||||
|
}) |
||||
|
}, |
||||
|
removeLabel({ commit, state }, projectId) { |
||||
|
for (const label of state.selected) { |
||||
|
LabelService.deleteLabel(projectId, label.id) |
||||
|
.then((response) => { |
||||
|
commit('deleteLabel', label.id) |
||||
|
}) |
||||
|
.catch((error) => { |
||||
|
alert(error) |
||||
|
}) |
||||
|
} |
||||
|
commit('resetSelected') |
||||
|
} |
||||
|
} |
Write
Preview
Loading…
Cancel
Save