metadataplayer edwin/metadataplayer/CreateAnnotation.js
changeset 4 ed1126cd2b80
parent 2 3cc57cb48aea
--- a/metadataplayer edwin/metadataplayer/CreateAnnotation.js	Tue Jun 26 15:53:42 2012 +0200
+++ b/metadataplayer edwin/metadataplayer/CreateAnnotation.js	Fri Jun 29 12:12:38 2012 +0200
@@ -216,9 +216,14 @@
     var _exportedAnnotations = new IriSP.Model.List(this.player.sourceManager);
         _export = this.player.sourceManager.newLocalSource({serializer: IriSP.serializers[this.api_serializer]}),
         _annotation = new IriSP.Model.Annotation(false, _export),
-        _annotationType = new IriSP.Model.AnnotationType(false, _export),
+        _annotationTypes = this.source.getAnnotationTypes().searchByTitle(this.annotation_type),
+        _annotationType = (_annotationTypes.length ? _annotationTypes[0] : new IriSP.Model.AnnotationType(false, _export)),
         _url = Mustache.to_html(this.api_endpoint_template, {id: this.source.projectId});
 
+    if (!_annotationTypes.length) {
+        _annotationType.dont_send_id = true;
+    }
+    
     _annotationType.title = this.annotation_type;
     _annotation.setBegin(this.begin);
     _annotation.setEnd(this.end);
@@ -254,6 +259,7 @@
         },
         error: function(_xhr, _error, _thrown) {
             IriSP.log("Error when sending annotation", _thrown);
+            _export.getAnnotations().removeElement(_annotation, true);
             _this.showScreen('Error');
             window.setTimeout(function(){
                 _this.showScreen("Main")