mirror of https://github.com/doccano/doccano.git
Hironsan
5 years ago
6 changed files with 229 additions and 204 deletions
Split View
Diff Options
-
2frontend/api/routes/labels.js
-
61frontend/components/containers/LabelList.vue
-
139frontend/components/organisms/LabelList.vue
-
202frontend/pages/projects/_id/labels/index.vue
-
27frontend/services/label.service.js
-
2frontend/store/labels.js
@ -0,0 +1,61 @@ |
|||
<template> |
|||
<label-list |
|||
:headers="headers" |
|||
:labels="items" |
|||
:selected="selected" |
|||
@update-selected="updateSelected" |
|||
@update-label="handleUpdateLabel" |
|||
/> |
|||
</template> |
|||
|
|||
<script> |
|||
import { mapState, mapActions, mapMutations } from 'vuex' |
|||
import LabelList from '@/components/organisms/LabelList' |
|||
|
|||
export default { |
|||
components: { |
|||
LabelList |
|||
}, |
|||
data() { |
|||
return { |
|||
headers: [ |
|||
{ |
|||
text: 'Name', |
|||
align: 'left', |
|||
value: 'text' |
|||
}, |
|||
{ |
|||
text: 'Shortkey', |
|||
value: 'suffix_key' |
|||
}, |
|||
{ |
|||
text: 'Color', |
|||
sortable: false, |
|||
value: 'background_color' |
|||
} |
|||
] |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
...mapState('labels', ['items', 'selected']) |
|||
}, |
|||
|
|||
created() { |
|||
this.getLabelList() |
|||
}, |
|||
|
|||
methods: { |
|||
...mapActions('labels', ['getLabelList', 'updateLabel']), |
|||
...mapMutations('labels', ['updateSelected']), |
|||
|
|||
handleUpdateLabel(payload) { |
|||
const data = { |
|||
projectId: this.$route.params.id, |
|||
...payload |
|||
} |
|||
this.updateLabel(data) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,139 @@ |
|||
<template> |
|||
<v-data-table |
|||
:value="selected" |
|||
:headers="headers" |
|||
:items="labels" |
|||
item-key="id" |
|||
:search="search" |
|||
show-select |
|||
@input="update" |
|||
> |
|||
<template v-slot:top> |
|||
<v-text-field |
|||
v-model="search" |
|||
prepend-inner-icon="search" |
|||
label="Search" |
|||
single-line |
|||
hide-details |
|||
filled |
|||
/> |
|||
</template> |
|||
<template v-slot:item.text="{ item }"> |
|||
<v-edit-dialog |
|||
:return-value.sync="item.text" |
|||
> |
|||
{{ item.text }} |
|||
<template v-slot:input> |
|||
<v-text-field |
|||
v-model="item.text" |
|||
label="Edit" |
|||
single-line |
|||
/> |
|||
</template> |
|||
</v-edit-dialog> |
|||
</template> |
|||
<template v-slot:item.suffix_key="{ item }"> |
|||
<v-edit-dialog |
|||
:return-value.sync="item.suffix_key" |
|||
large |
|||
persistent |
|||
@save="updateShortcut({ id: item.id, suffix_key: newKey })" |
|||
> |
|||
<div>{{ item.suffix_key }}</div> |
|||
<template v-slot:input> |
|||
<div class="mt-4 title"> |
|||
Update key |
|||
</div> |
|||
</template> |
|||
<template v-slot:input> |
|||
<v-select |
|||
:value="item.suffix_key" |
|||
:items="keys" |
|||
label="Key" |
|||
@input="setNewKey" |
|||
/> |
|||
</template> |
|||
</v-edit-dialog> |
|||
</template> |
|||
<template v-slot:item.background_color="{ item }"> |
|||
<v-edit-dialog |
|||
:return-value.sync="item.background_color" |
|||
large |
|||
persistent |
|||
@save="updateColor({ id:item.id, background_color: newColor })" |
|||
> |
|||
<v-chip :color="item.background_color" dark> |
|||
{{ item.background_color }} |
|||
</v-chip> |
|||
<template v-slot:input> |
|||
<div class="mt-4 title"> |
|||
Update color |
|||
</div> |
|||
</template> |
|||
<template v-slot:input> |
|||
<v-color-picker |
|||
:value="item.backgroundColor" |
|||
show-swatches |
|||
hide-mode-switch |
|||
width="800" |
|||
:mode.sync="mode" |
|||
class="ma-2" |
|||
@input="setNewColor" |
|||
/> |
|||
</template> |
|||
</v-edit-dialog> |
|||
</template> |
|||
</v-data-table> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
props: { |
|||
headers: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
labels: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
selected: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
} |
|||
}, |
|||
data() { |
|||
return { |
|||
search: '', |
|||
newKey: null, |
|||
newColor: null, |
|||
keys: 'abcdefghijklmnopqrstuvwxyz'.split(''), |
|||
mode: 'hexa', |
|||
color: '#FF00FF' |
|||
} |
|||
}, |
|||
methods: { |
|||
setNewKey(value) { |
|||
this.newKey = value |
|||
}, |
|||
setNewColor(value) { |
|||
this.newColor = value |
|||
}, |
|||
update(selected) { |
|||
this.$emit('update-selected', selected) |
|||
}, |
|||
updateRole(payload) { |
|||
this.$emit('update-role', payload) |
|||
}, |
|||
updateShortcut(payload) { |
|||
this.$emit('update-label', payload) |
|||
}, |
|||
updateColor(payload) { |
|||
this.$emit('update-label', payload) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -1,32 +1,29 @@ |
|||
import ApiService from '@/services/api.service' |
|||
|
|||
class MemberService { |
|||
class LabelService { |
|||
constructor() { |
|||
this.request = new ApiService() |
|||
} |
|||
|
|||
getMemberList(projectId) { |
|||
return this.request.get(`/projects/${projectId}/users`) |
|||
getLabelList(projectId) { |
|||
return this.request.get(`/projects/${projectId}/labels`) |
|||
} |
|||
|
|||
addMember(projectId, userId, role) { |
|||
const data = { |
|||
id: userId, |
|||
role |
|||
} |
|||
return this.request.post(`/projects/${projectId}/users`, data) |
|||
addLabel(projectId, payload) { |
|||
return this.request.post(`/projects/${projectId}/labels`, payload) |
|||
} |
|||
|
|||
deleteMember(projectId, userId) { |
|||
return this.request.delete(`/projects/${projectId}/users/${userId}`) |
|||
deleteLabel(projectId, labelId) { |
|||
return this.request.delete(`/projects/${projectId}/labels/${labelId}`) |
|||
} |
|||
|
|||
updateMemberRole(projectId, userId, role) { |
|||
updateLabel(projectId, labelId, payload) { |
|||
const data = { |
|||
role |
|||
id: labelId, |
|||
...payload |
|||
} |
|||
return this.request.patch(`/projects/${projectId}/users/${userId}`, data) |
|||
return this.request.patch(`/projects/${projectId}/labels/${labelId}`, data) |
|||
} |
|||
} |
|||
|
|||
export default new MemberService() |
|||
export default new LabelService() |
Write
Preview
Loading…
Cancel
Save