@@ -137,6 +137,11 @@ var Annotation = new Schema({
137
137
admin : [ String ] ,
138
138
update : [ String ] ,
139
139
delete : [ String ]
140
+ } ,
141
+ annotation_categories : [ Number ] ,
142
+ sort_position : {
143
+ type : String ,
144
+ required : false
140
145
}
141
146
} ) ;
142
147
@@ -222,6 +227,9 @@ app.get('/api/search', tokenOK, function(req, res) {
222
227
if ( req . query . tags ) {
223
228
query . where ( 'tags' ) . in ( req . query . tags . split ( / [ \s , ] + / ) ) ;
224
229
}
230
+ if ( req . query . annotation_categories ) {
231
+ query . where ( 'annotation_categories' ) . in ( req . query . annotation_categories ) ;
232
+ }
225
233
226
234
query . limit ( req . query . limit ) ;
227
235
@@ -306,7 +314,9 @@ app.post('/api/annotations', tokenOK, function(req, res) {
306
314
parentIndex : req . body . parentIndex ,
307
315
ranges : req . body . ranges ,
308
316
shapes : req . body . shapes ,
309
- permissions : req . body . permissions
317
+ permissions : req . body . permissions ,
318
+ annotation_categories : req . body . annotation_categories ,
319
+ sort_position : req . body . sort_position
310
320
} ) ;
311
321
312
322
annotation . save ( function ( err ) {
@@ -320,6 +330,13 @@ app.post('/api/annotations', tokenOK, function(req, res) {
320
330
return res . send ( annotation ) ;
321
331
} ) ;
322
332
333
+ app . post ( '/api/annotations/positions' , tokenOK , function ( req , res ) {
334
+ for ( annotation_id in req . body . sort_positions ) {
335
+ AnnotationModel . update ( { uuid : annotation_id } , { $set : { sort_position : req . body . sort_positions [ annotation_id ] } } , function ( ) { } ) ;
336
+ }
337
+ res . send ( 'Positions have been updated' ) ;
338
+ } ) ;
339
+
323
340
// PUT to UPDATE
324
341
// Single update
325
342
app . put ( '/api/annotations/:id' , tokenOK , function ( req , res ) {
@@ -344,6 +361,8 @@ app.put('/api/annotations/:id', tokenOK, function(req, res) {
344
361
annotation . parentIndex = req . body . parentIndex ;
345
362
annotation . ranges = req . body . ranges ;
346
363
annotation . permissions = req . body . permissions ;
364
+ annotation . annotation_categories = req . body . annotation_categories ;
365
+ annotation . sort_position = req . body . sort_position ;
347
366
348
367
return annotation . save ( function ( err ) {
349
368
if ( ! err ) {
0 commit comments