mirror of https://github.com/doccano/doccano.git
Hironsan
3 years ago
2 changed files with 0 additions and 199 deletions
Split View
Diff Options
-
92frontend/components/tasks/textClassification/SingleLabel.vue
-
107frontend/components/tasks/textClassification/TextClassification.vue
@ -1,92 +0,0 @@ |
|||
<template> |
|||
<v-select |
|||
:value="annotatedLabel" |
|||
:items="labels" |
|||
item-text="text" |
|||
:label="$t('labels.labels')" |
|||
hide-selected |
|||
return-object |
|||
chips |
|||
@change="addOrRemove" |
|||
> |
|||
<template v-slot:selection="{ attrs, item, select, selected }"> |
|||
<v-chip |
|||
v-if="item.backgroundColor" |
|||
v-bind="attrs" |
|||
:input-value="selected" |
|||
:color="item.backgroundColor" |
|||
:text-color="$contrastColor(item.backgroundColor)" |
|||
close |
|||
@click="select" |
|||
@click:close="remove(item)" |
|||
> |
|||
<v-avatar |
|||
left |
|||
color="white" |
|||
class="black--text font-weight-bold" |
|||
> |
|||
{{ item.suffixKey }} |
|||
</v-avatar> |
|||
{{ item.text }} |
|||
</v-chip> |
|||
</template> |
|||
<template v-slot:item="{ item }"> |
|||
<v-chip |
|||
:color="item.backgroundColor" |
|||
:text-color="$contrastColor(item.backgroundColor)" |
|||
> |
|||
<v-avatar |
|||
left |
|||
color="white" |
|||
class="black--text font-weight-bold" |
|||
> |
|||
{{ item.suffixKey }} |
|||
</v-avatar> |
|||
{{ item.text }} |
|||
</v-chip> |
|||
</template> |
|||
</v-select> |
|||
</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.find(item => labelIds.includes(item.id)) |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
addOrRemove(val) { |
|||
if (val) { |
|||
this.add(val) |
|||
} else { |
|||
this.remove(this.annotatedLabel) |
|||
} |
|||
}, |
|||
|
|||
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,107 +0,0 @@ |
|||
<template> |
|||
<v-combobox |
|||
v-model="annotatedLabels" |
|||
:items="labels" |
|||
item-text="text" |
|||
:label="$t('labels.labels')" |
|||
hide-selected |
|||
chips |
|||
multiple |
|||
:search-input.sync="search" |
|||
@change="search=''" |
|||
> |
|||
<template v-slot:selection="{ attrs, item, select, selected }"> |
|||
<v-chip |
|||
v-bind="attrs" |
|||
:input-value="selected" |
|||
:color="item.backgroundColor" |
|||
:text-color="$contrastColor(item.backgroundColor)" |
|||
close |
|||
@click="select" |
|||
@click:close="remove(item)" |
|||
> |
|||
<v-avatar |
|||
left |
|||
color="white" |
|||
class="black--text font-weight-bold" |
|||
> |
|||
{{ item.suffixKey }} |
|||
</v-avatar> |
|||
{{ item.text }} |
|||
</v-chip> |
|||
</template> |
|||
<template v-slot:item="{ item }"> |
|||
<v-chip |
|||
:color="item.backgroundColor" |
|||
:text-color="$contrastColor(item.backgroundColor)" |
|||
> |
|||
<v-avatar |
|||
left |
|||
color="white" |
|||
class="black--text font-weight-bold" |
|||
> |
|||
{{ item.suffixKey }} |
|||
</v-avatar> |
|||
{{ item.text }} |
|||
</v-chip> |
|||
</template> |
|||
</v-combobox> |
|||
</template> |
|||
|
|||
<script> |
|||
export default { |
|||
props: { |
|||
labels: { |
|||
type: Array, |
|||
default: () => [], |
|||
required: true |
|||
}, |
|||
annotations: { |
|||
type: Array, |
|||
default: () => ([]), |
|||
required: true |
|||
} |
|||
}, |
|||
|
|||
data() { |
|||
return { |
|||
search: '' |
|||
} |
|||
}, |
|||
|
|||
computed: { |
|||
annotatedLabels: { |
|||
get() { |
|||
const labelIds = this.annotations.map(item => item.label) |
|||
return this.labels.filter(item => labelIds.includes(item.id)) |
|||
}, |
|||
set(newValue) { |
|||
if (newValue.length > this.annotations.length) { |
|||
const label = newValue[newValue.length - 1] |
|||
if (typeof label === 'object') { |
|||
this.add(label) |
|||
} else { |
|||
newValue.pop() |
|||
} |
|||
} else { |
|||
const label = this.annotatedLabels.find(x => !newValue.some(y => y.id === x.id)) |
|||
if (typeof label === 'object') { |
|||
this.remove(label) |
|||
} |
|||
} |
|||
} |
|||
} |
|||
}, |
|||
|
|||
methods: { |
|||
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> |
Write
Preview
Loading…
Cancel
Save