diff -r a6290b2fae6b -r 11a862e01b04 src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue --- a/src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue Mon May 15 14:44:14 2017 +0200 +++ b/src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue Tue May 16 11:29:33 2017 +0200 @@ -2,7 +2,8 @@
+ class="btn btn-block btn-sm btn-primary">{{ submitButtonText }}
@@ -66,7 +67,6 @@ export default { props: { - action: String, annotation: { type: Object, default: function () { @@ -78,7 +78,9 @@ default: false }, revisionsUrl: String, - authorUrl: String + authorUrl: String, + newAnnotationUrl: String, + editAnnotationUrl: String }, components: { 'tag-list': TagList @@ -127,9 +129,19 @@ }, formAction: function() { if (this.annotation) { - return this.action.replace(':annotation_guid', this.annotation.annotation_guid); + if (this.annotation.annotation_guid) { + return this.editAnnotationUrl.replace(':annotation_guid', this.annotation.annotation_guid); + } + + return this.newAnnotationUrl } }, + submitButtonText: function() { + return this.isNewAnnotation ? 'Enregistrer' : 'Enregister une nouvelle version' + }, + isNewAnnotation: function() { + return this.annotation && !this.annotation.annotation_guid + }, serializedTags: function() { var tags = this.tags.map(function(tag) { return { @@ -151,6 +163,13 @@ } }, methods: { + onCancelClick: function() { + if (this.isNewAnnotation) { + this.$emit('close') + } else { + this.readonly = !this.readonly + } + }, onTagsChange: function(tags) { this.tags = tags; }, @@ -164,8 +183,14 @@ description: annotation.description, fragment: annotation.fragment, tags: annotation.tags.slice(), - readonly: true, + readonly: !this.isNewAnnotation, }); + + if (!annotation.annotation_guid) { + setTimeout(() => { + $(this.$refs.title).focus() + }, 500); + } } } }