Skip to content

Commit 7c80933

Browse files
committed
Enable to list all labels
1 parent 3e98dbe commit 7c80933

File tree

1 file changed

+44
-5
lines changed

1 file changed

+44
-5
lines changed

frontend/components/tasks/sequenceLabeling/EntityEditor.vue

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,34 @@
2929
max-height="400"
3030
class="overflow-y-auto"
3131
>
32+
<v-list-item>
33+
<v-autocomplete
34+
:value="currentLabel"
35+
:items="entityLabels"
36+
autofocus
37+
chips
38+
dense
39+
deletable-chips
40+
hide-details
41+
item-text="text"
42+
item-value="id"
43+
label="Label List"
44+
small-chips
45+
@input="addOrUpdateEntity"
46+
>
47+
<template #selection="data">
48+
<v-chip
49+
v-bind="data.attrs"
50+
:input-value="data.selected"
51+
close
52+
@click="data.select"
53+
@click:close="deleteEntity(entity)"
54+
>
55+
{{ data.item.text }}
56+
</v-chip>
57+
</template>
58+
</v-autocomplete>
59+
</v-list-item>
3260
<v-list-item
3361
v-for="(label, i) in entityLabels"
3462
:key="i"
@@ -117,13 +145,22 @@ export default Vue.extend({
117145
y: 0,
118146
startOffset: 0,
119147
endOffset: 0,
120-
entityId: -1,
148+
entity: null as any,
149+
value: false
121150
};
122151
},
123152
124153
computed: {
125154
hasAnySuffixKey(): boolean {
126155
return this.entityLabels.some((label: any) => label.suffixKey !== null)
156+
},
157+
currentLabel(): any {
158+
if (this.entity) {
159+
const label = this.entityLabels.find((label: any) => label.id === this.entity!.label)
160+
return label
161+
} else {
162+
return null
163+
}
127164
}
128165
},
129166
@@ -134,7 +171,7 @@ export default Vue.extend({
134171
},
135172
136173
setEntity(entityId: number) {
137-
this.entityId = entityId
174+
this.entity = this.entities.find((entity: any) => entity.id === entityId)
138175
},
139176
140177
showEntityLabelMenu(e: any) {
@@ -158,27 +195,29 @@ export default Vue.extend({
158195
},
159196
160197
addOrUpdateEntity(labelId: number) {
161-
if (this.entityId !== -1) {
198+
if (this.entity) {
162199
this.updateEntity(labelId)
163200
} else {
164201
this.addEntity(labelId)
165202
}
166203
this.showMenu = false
167204
this.startOffset = 0
168205
this.endOffset = 0
169-
this.entityId = -1
206+
this.entity = null
170207
},
171208
172209
addEntity(labelId: number) {
173210
this.$emit('addEntity', this.startOffset, this.endOffset, labelId)
174211
},
175212
176213
updateEntity(labelId: number) {
177-
this.$emit('click:entity', this.entityId, labelId)
214+
this.$emit('click:entity', this.entity!.id, labelId)
178215
},
179216
180217
deleteEntity(entity: any) {
181218
this.$emit('contextmenu:entity', entity.id)
219+
this.entity = null
220+
this.showMenu = false
182221
},
183222
184223
updateRelation() {

0 commit comments

Comments
 (0)