src_js/iconolab-bundle/src/components/editor/AnnotationForm.vue
author Alexandre Segura <mex.zktk@gmail.com>
Tue, 02 May 2017 13:50:05 +0200
changeset 485 47080491b330
parent 483 dce041bc57a9
child 504 11a862e01b04
permissions -rw-r--r--
Add intro.js for on boarding.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
     1
<template>
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
     2
    <div>
485
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 483
diff changeset
     3
        <button
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 483
diff changeset
     4
            data-intro="Proposez une nouvelle version" data-position="left"
47080491b330 Add intro.js for on boarding.
Alexandre Segura <mex.zktk@gmail.com>
parents: 483
diff changeset
     5
            v-if="annotation && isAuthenticated" @click="readonly = !readonly"
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
     6
            class="btn btn-xs pull-right"
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
     7
            v-bind:class="{ 'btn-primary': readonly, 'btn-warning': !readonly }">
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
     8
            <i class="fa fa-edit" v-if="readonly"></i>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
     9
            <span v-if="readonly">Modifier</span>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    10
            <i class="fa fa-ban" v-if="!readonly"></i>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    11
            <span v-if="!readonly">Annuler</span>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    12
        </button>
356
a45f7dac4789 Change wordings, align text.
Alexandre Segura <mex.zktk@gmail.com>
parents: 351
diff changeset
    13
        <div v-if="!annotation" class="alert alert-warning text-center">
433
616fc1fad25f Toggle annotation on click.
Alexandre Segura <mex.zktk@gmail.com>
parents: 427
diff changeset
    14
            Aucune annotation sélectionnée
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    15
        </div>
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    16
        <form v-bind:action="formAction" method="post">
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    17
            <slot>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    18
                <!-- CSRF token -->
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    19
            </slot>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    20
            <input type="hidden" name="fragment" v-model="fragment">
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    21
            <div v-if="annotation" class="form-group form-group-sm">
402
376158f6d760 hides title and description if there is none
duong tam kien <tk@deveha.com>
parents: 400
diff changeset
    22
                <label v-if="!readonly || title" class="small text-muted">Titre</label>
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    23
                <input type="text" class="form-control" name="title" v-model="title" v-if="!readonly">
402
376158f6d760 hides title and description if there is none
duong tam kien <tk@deveha.com>
parents: 400
diff changeset
    24
                <p v-if="readonly && title" v-bind:class="{ 'text-muted': !title }">{{ title || 'Pas de titre' }}</p>
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    25
            </div>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    26
            <div v-if="annotation" class="form-group form-group-sm">
402
376158f6d760 hides title and description if there is none
duong tam kien <tk@deveha.com>
parents: 400
diff changeset
    27
                <label v-if="!readonly || description" class="small text-muted">Description</label>
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    28
                <textarea class="form-control" name="description" v-model="description" v-if="!readonly" placeholder="Décrivez ce que vous voyez"></textarea>
403
0ed5207089ee adds formatting (markdown) to annotation description
duong tam kien <tk@deveha.com>
parents: 402
diff changeset
    29
                <p v-if="readonly && description" v-bind:class="{ 'text-muted': !description }" v-html="descriptionComputed">{{ descriptionComputed || 'Pas de description' }}</p>
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    30
            </div>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    31
            <div v-if="annotation" class="form-group form-group-sm">
400
c85505149eea orthographe mots-cléS + css
duong tam kien <tk@deveha.com>
parents: 385
diff changeset
    32
                <label class="small text-muted">Mots-clés</label>
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    33
                <tag-list ref="taglist"
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    34
                    v-bind:original-tags="annotation.tags"
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    35
                    v-bind:readonly="readonly"
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    36
                    @change="onTagsChange($event.tags)"></tag-list>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    37
                <input type="hidden" name="tags" v-model="serializedTags">
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    38
            </div>
483
dce041bc57a9 Fix null pointer.
Alexandre Segura <mex.zktk@gmail.com>
parents: 482
diff changeset
    39
            <p class="small text-center text-muted" v-if="annotation">
482
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
    40
                <a v-bind:href="revisionsUrlComputed">Dernière version</a>
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
    41
                <span>{{ dateComputed }} par</span>
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
    42
                <a v-bind:href="authorUrlComputed">{{ annotation.author }}</a>
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
    43
            </p>
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    44
            <button type="submit" v-if="annotation &amp;&amp; !readonly" v-bind:class="{ disabled: !hasChanged }"
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    45
                class="btn btn-block btn-sm btn-primary">Enregistrer une nouvelle version</button>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    46
        </form>
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    47
    </div>
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    48
</template>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    49
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    50
<script>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    51
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    52
    import TagList from '../tagform/TagList.vue'
333
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
    53
    import _ from 'lodash'
403
0ed5207089ee adds formatting (markdown) to annotation description
duong tam kien <tk@deveha.com>
parents: 402
diff changeset
    54
    import showdown from 'showdown'
427
2a9ce7ec3a29 Display date & author of last revision.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
    55
    import moment from 'moment'
403
0ed5207089ee adds formatting (markdown) to annotation description
duong tam kien <tk@deveha.com>
parents: 402
diff changeset
    56
0ed5207089ee adds formatting (markdown) to annotation description
duong tam kien <tk@deveha.com>
parents: 402
diff changeset
    57
    const converter = new showdown.Converter()
333
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
    58
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
    59
    var defaults = {
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    60
        title: '',
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    61
        description: '',
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    62
        fragment: '',
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    63
        tags: [],
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    64
        readonly: true,
333
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
    65
    }
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    66
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    67
    export default {
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    68
        props: {
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    69
            action: String,
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    70
            annotation: {
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    71
                type: Object,
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    72
                default: function () {
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    73
                    return null;
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    74
                }
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    75
            },
385
d0465086d8d2 Allow editing/commenting only for authenticated users.
Alexandre Segura <mex.zktk@gmail.com>
parents: 356
diff changeset
    76
            isAuthenticated: {
d0465086d8d2 Allow editing/commenting only for authenticated users.
Alexandre Segura <mex.zktk@gmail.com>
parents: 356
diff changeset
    77
                type: Boolean,
d0465086d8d2 Allow editing/commenting only for authenticated users.
Alexandre Segura <mex.zktk@gmail.com>
parents: 356
diff changeset
    78
                default: false
482
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
    79
            },
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
    80
            revisionsUrl: String,
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
    81
            authorUrl: String
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
    82
        },
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    83
        components: {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    84
            'tag-list': TagList
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    85
        },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
    86
        data() {
333
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
    87
            return defaults;
325
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    88
        },
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
    89
        mounted() {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
    90
            if (this.annotation) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
    91
                this.loadAnnotation(this.annotation);
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
    92
            }
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
    93
        },
325
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    94
        watch: {
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    95
            annotation: function(annotation) {
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    96
                if (annotation) {
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
    97
                    this.loadAnnotation(annotation);
325
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    98
                } else {
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
    99
                    this.reset();
8f158a4c7759 Use props to update annotation in components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 323
diff changeset
   100
                }
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   101
            }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   102
        },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   103
        computed: {
427
2a9ce7ec3a29 Display date & author of last revision.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   104
            descriptionComputed: function() {
403
0ed5207089ee adds formatting (markdown) to annotation description
duong tam kien <tk@deveha.com>
parents: 402
diff changeset
   105
              return converter.makeHtml(this.description);
0ed5207089ee adds formatting (markdown) to annotation description
duong tam kien <tk@deveha.com>
parents: 402
diff changeset
   106
            },
427
2a9ce7ec3a29 Display date & author of last revision.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   107
            lastRevisionText: function() {
2a9ce7ec3a29 Display date & author of last revision.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   108
                if (this.annotation) {
2a9ce7ec3a29 Display date & author of last revision.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   109
                    var date = moment(this.annotation.created).locale('fr');
2a9ce7ec3a29 Display date & author of last revision.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   110
                    return 'Dernière version ' + date.fromNow() + ' par ' + this.annotation.author;
2a9ce7ec3a29 Display date & author of last revision.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   111
                }
2a9ce7ec3a29 Display date & author of last revision.
Alexandre Segura <mex.zktk@gmail.com>
parents: 418
diff changeset
   112
            },
482
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   113
            revisionsUrlComputed: function() {
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   114
                if (this.annotation) {
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   115
                    return this.revisionsUrl.replace(':annotation_guid', this.annotation.annotation_guid);
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   116
                }
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   117
            },
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   118
            authorUrlComputed: function() {
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   119
                if (this.annotation) {
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   120
                    return this.authorUrl.replace('--username--', this.annotation.author);
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   121
                }
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   122
            },
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   123
            dateComputed: function() {
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   124
                if (this.annotation) {
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   125
                    return moment(this.annotation.created).locale('fr').fromNow();
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   126
                }
b71475c27159 Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents: 433
diff changeset
   127
            },
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   128
            formAction: function() {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   129
                if (this.annotation) {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   130
                    return this.action.replace(':annotation_guid', this.annotation.annotation_guid);
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   131
                }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   132
            },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   133
            serializedTags: function() {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   134
                var tags = this.tags.map(function(tag) {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   135
                    return {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   136
                        tag_input: (typeof tag.tag_link === "string" && tag.tag_link.length) ? tag.tag_link : tag.tag_label,
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   137
                        tag_label: tag.tag_label,
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   138
                        accuracy: tag.accuracy,
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   139
                        relevancy: tag.relevancy
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   140
                    }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   141
                });
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   142
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   143
                return JSON.stringify(tags);
333
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
   144
            },
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
   145
            hasChanged: function() {
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
   146
                if (!this.annotation) { return false; }
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
   147
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
   148
                return this.title !== this.annotation.title
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
   149
                    || this.description !== this.annotation.description
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
   150
                    || !_.isEqual(this.annotation.tags, this.tags);
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   151
            }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   152
        },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   153
        methods: {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   154
            onTagsChange: function(tags) {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   155
                this.tags = tags;
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   156
            },
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   157
            reset: function() {
333
625ac8b8bb87 Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents: 327
diff changeset
   158
                Object.assign(this, defaults);
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   159
            },
418
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   160
            loadAnnotation(annotation) {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   161
                // Make sure we have an actual copy
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   162
                Object.assign(this, {
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   163
                    title: annotation.title,
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   164
                    description: annotation.description,
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   165
                    fragment: annotation.fragment,
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   166
                    tags: annotation.tags.slice(),
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   167
                    readonly: true,
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   168
                });
a04c55054afe Introduce display of all annotations at the same time.
Alexandre Segura <mex.zktk@gmail.com>
parents: 403
diff changeset
   169
            }
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   170
        }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   171
    }
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   172
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   173
</script>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   174
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   175
<style scoped>
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   176
form {
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   177
    margin-bottom: 20px;
339
ba89f767b091 Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents: 333
diff changeset
   178
    clear: both;
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   179
}
400
c85505149eea orthographe mots-cléS + css
duong tam kien <tk@deveha.com>
parents: 385
diff changeset
   180
c85505149eea orthographe mots-cléS + css
duong tam kien <tk@deveha.com>
parents: 385
diff changeset
   181
label {
c85505149eea orthographe mots-cléS + css
duong tam kien <tk@deveha.com>
parents: 385
diff changeset
   182
  font-weight: normal;
c85505149eea orthographe mots-cléS + css
duong tam kien <tk@deveha.com>
parents: 385
diff changeset
   183
}
323
55c024fc7c60 Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff changeset
   184
</style>