Skip to content

Commit 5bc6119

Browse files
committed
Use find to get the annotation of a label
1 parent 8bd7897 commit 5bc6119

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

app/server/static/components/document_classification.vue

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,8 @@ export default {
5858
mixins: [annotationMixin],
5959
6060
methods: {
61-
isIn(label) {
62-
for (let i = 0; i < this.annotations[this.pageNumber].length; i++) {
63-
const a = this.annotations[this.pageNumber][i];
64-
if (a.label === label.id) {
65-
return a;
66-
}
67-
}
68-
return false;
61+
getAnnotation(label) {
62+
return this.annotations[this.pageNumber].find(annotation => annotation.label === label.id);
6963
},
7064
7165
async submit() {
@@ -76,9 +70,9 @@ export default {
7670
},
7771
7872
async addLabel(label) {
79-
const a = this.isIn(label);
80-
if (a) {
81-
this.removeLabel(a);
73+
const annotation = this.getAnnotation(label);
74+
if (annotation) {
75+
this.removeLabel(annotation);
8276
} else {
8377
const docId = this.docs[this.pageNumber].id;
8478
const payload = {

0 commit comments

Comments
 (0)