mirror of https://github.com/doccano/doccano.git
Browse Source
Merge pull request #1263 from doccano/enhancement/#1219
Merge pull request #1263 from doccano/enhancement/#1219
[Enhancement] display shortcut keyspull/1273/head
Hiroki Nakayama
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 273 additions and 16 deletions
Split View
Diff Options
-
46frontend/components/tasks/textClassification/LabelGroup.vue
-
46frontend/components/tasks/textClassification/LabelSelect.vue
-
74frontend/components/tasks/textClassification/multiLabel/LabelGroup.vue
-
5frontend/components/tasks/textClassification/multiLabel/LabelSelect.vue
-
69frontend/components/tasks/textClassification/singleLabel/LabelGroup.vue
-
5frontend/components/tasks/textClassification/singleLabel/LabelSelect.vue
-
1frontend/components/tasks/toolbar/ToolbarLaptop.vue
-
8frontend/pages/demo/sentiment-analysis/index.vue
-
35frontend/pages/projects/_id/text-classification/index.vue
@ -0,0 +1,46 @@ |
|||
<template> |
|||
<label-group-single |
|||
v-if="singleLabel" |
|||
:annotations="annotations" |
|||
:labels="labels" |
|||
@add="$emit('add', $event)" |
|||
@remove="$emit('remove', $event)" |
|||
/> |
|||
<label-group-multi |
|||
v-else |
|||
:annotations="annotations" |
|||
:labels="labels" |
|||
@add="$emit('add', $event)" |
|||
@remove="$emit('remove', $event)" |
|||
/> |
|||
</template> |
|||
|
|||
<script> |
|||
import LabelGroupSingle from './singleLabel/LabelGroup.vue' |
|||
import LabelGroupMulti from './multiLabel/LabelGroup.vue' |
|||
|
|||
export default { |
|||
components: { |
|||
LabelGroupSingle, |
|||
LabelGroupMulti |
|||
}, |
|||
|
|||
props: { |
|||
labels: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
annotations: { |
|||
type: Array, |
|||
default: () => ([]), |
|||
required: true |
|||
}, |
|||
singleLabel: { |
|||
type: Boolean, |
|||
default: false, |
|||
required: true |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,46 @@ |
|||
<template> |
|||
<label-select-single |
|||
v-if="singleLabel" |
|||
:annotations="annotations" |
|||
:labels="labels" |
|||
@add="$emit('add', $event)" |
|||
@remove="$emit('remove', $event)" |
|||
/> |
|||
<label-select-multi |
|||
v-else |
|||
:annotations="annotations" |
|||
:labels="labels" |
|||
@add="$emit('add', $event)" |
|||
@remove="$emit('remove', $event)" |
|||
/> |
|||
</template> |
|||
|
|||
<script> |
|||
import LabelSelectSingle from './singleLabel/LabelSelect.vue' |
|||
import LabelSelectMulti from './multiLabel/LabelSelect.vue' |
|||
|
|||
export default { |
|||
components: { |
|||
LabelSelectSingle, |
|||
LabelSelectMulti |
|||
}, |
|||
|
|||
props: { |
|||
labels: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
annotations: { |
|||
type: Array, |
|||
default: () => ([]), |
|||
required: true |
|||
}, |
|||
singleLabel: { |
|||
type: Boolean, |
|||
default: false, |
|||
required: true |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -0,0 +1,74 @@ |
|||
<template> |
|||
<v-chip-group |
|||
:value="annotatedLabel" |
|||
column |
|||
multiple |
|||
@change="addOrRemove" |
|||
> |
|||
<v-chip |
|||
v-for="item in labels" |
|||
:key="item.id" |
|||
:color="item.backgroundColor" |
|||
filter |
|||
:text-color="$contrastColor(item.backgroundColor)" |
|||
> |
|||
{{ item.text }} |
|||
<v-avatar |
|||
right |
|||
color="white" |
|||
class="black--text font-weight-bold" |
|||
> |
|||
{{ item.suffixKey }} |
|||
</v-avatar> |
|||
</v-chip> |
|||
</v-chip-group> |
|||
</template> |
|||
|
|||
<script> |
|||
import _ from 'lodash' |
|||
|
|||
export default { |
|||
props: { |
|||
labels: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
annotations: { |
|||
type: Array, |
|||
default: () => ([]), |
|||
required: true |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
annotatedLabel() { |
|||
const labelIds = this.annotations.map(item => item.label) |
|||
return labelIds.map(id => this.labels.findIndex(item => item.id === id)) |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
addOrRemove(indexes) { |
|||
if (indexes.length > this.annotatedLabel.length) { |
|||
const index = _.difference(indexes, this.annotatedLabel) |
|||
const label = this.labels[index] |
|||
this.add(label) |
|||
} else { |
|||
const index = _.difference(this.annotatedLabel, indexes) |
|||
const label = this.labels[index] |
|||
this.remove(label) |
|||
} |
|||
}, |
|||
|
|||
add(label) { |
|||
this.$emit('add', label.id) |
|||
}, |
|||
|
|||
remove(label) { |
|||
const annotation = this.annotations.find(item => item.label === label.id) |
|||
this.$emit('remove', annotation.id) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -1,12 +1,13 @@ |
|||
<template> |
|||
<v-combobox |
|||
v-model="annotatedLabels" |
|||
chips |
|||
:items="labels" |
|||
item-text="text" |
|||
:label="$t('labels.labels')" |
|||
hide-details |
|||
hide-selected |
|||
chips |
|||
multiple |
|||
class="pt-0" |
|||
:search-input.sync="search" |
|||
@change="search=''" |
|||
> |
@ -0,0 +1,69 @@ |
|||
<template> |
|||
<v-chip-group |
|||
:value="annotatedLabel" |
|||
column |
|||
@change="addOrRemove" |
|||
> |
|||
<v-chip |
|||
v-for="item in labels" |
|||
:key="item.id" |
|||
:color="item.backgroundColor" |
|||
filter |
|||
:text-color="$contrastColor(item.backgroundColor)" |
|||
> |
|||
{{ item.text }} |
|||
<v-avatar |
|||
right |
|||
color="white" |
|||
class="black--text font-weight-bold" |
|||
> |
|||
{{ item.suffixKey }} |
|||
</v-avatar> |
|||
</v-chip> |
|||
</v-chip-group> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
props: { |
|||
labels: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
annotations: { |
|||
type: Array, |
|||
default: () => ([]), |
|||
required: true |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
annotatedLabel() { |
|||
const labelIds = this.annotations.map(item => item.label) |
|||
return this.labels.findIndex(item => labelIds.includes(item.id)) |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
addOrRemove(index) { |
|||
if (index === undefined) { |
|||
const label = this.labels[this.annotatedLabel] |
|||
this.remove(label) |
|||
} else { |
|||
const label = this.labels[index] |
|||
this.add(label) |
|||
} |
|||
}, |
|||
|
|||
add(label) { |
|||
this.$emit('add', label.id) |
|||
}, |
|||
|
|||
remove(label) { |
|||
const annotation = this.annotations.find(item => item.label === label.id) |
|||
this.$emit('remove', annotation.id) |
|||
} |
|||
} |
|||
} |
|||
</script> |
@ -1,12 +1,13 @@ |
|||
<template> |
|||
<v-select |
|||
:value="annotatedLabel" |
|||
chips |
|||
:items="labels" |
|||
item-text="text" |
|||
:label="$t('labels.labels')" |
|||
hide-details |
|||
hide-selected |
|||
return-object |
|||
chips |
|||
class="pt-0" |
|||
@change="addOrRemove" |
|||
> |
|||
<template v-slot:selection="{ attrs, item, select, selected }"> |
Write
Preview
Loading…
Cancel
Save