File tree Expand file tree Collapse file tree 2 files changed +6
-16
lines changed
app/server/static/components Expand file tree Collapse file tree 2 files changed +6
-16
lines changed Original file line number Diff line number Diff line change @@ -90,11 +90,7 @@ export default {
90
90
this . next = response . data . next ;
91
91
this . prev = response . data . previous ;
92
92
this . count = response . data . count ;
93
- this . annotations = [ ] ;
94
- for ( let i = 0 ; i < this . docs . length ; i ++ ) {
95
- const doc = this . docs [ i ] ;
96
- this . annotations . push ( doc . annotations ) ;
97
- }
93
+ this . annotations = this . docs . map ( doc => doc . annotations ) ;
98
94
this . offset = getOffsetFromUrl ( this . url ) ;
99
95
} ) ;
100
96
} ,
Original file line number Diff line number Diff line change @@ -58,14 +58,8 @@ export default {
58
58
mixins: [annotationMixin],
59
59
60
60
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 );
69
63
},
70
64
71
65
async submit () {
@@ -76,9 +70,9 @@ export default {
76
70
},
77
71
78
72
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 );
82
76
} else {
83
77
const docId = this .docs [this .pageNumber ].id ;
84
78
const payload = {
You can’t perform that action at this time.
0 commit comments