| author | ymh <ymh.work@gmail.com> |
| Wed, 06 Jun 2018 16:21:54 +0200 | |
| changeset 539 | 08e2513dbc2f |
| parent 504 | 11a862e01b04 |
| permissions | -rw-r--r-- |
|
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" |
|
504
11a862e01b04
Implement annotation on the whole picture.
Alexandre Segura <mex.zktk@gmail.com>
parents:
485
diff
changeset
|
5 |
v-if="annotation && isAuthenticated" |
|
11a862e01b04
Implement annotation on the whole picture.
Alexandre Segura <mex.zktk@gmail.com>
parents:
485
diff
changeset
|
6 |
@click="onCancelClick" |
|
339
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
7 |
class="btn btn-xs pull-right" |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
8 |
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
|
9 |
<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
|
10 |
<span v-if="readonly">Modifier</span> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
11 |
<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
|
12 |
<span v-if="!readonly">Annuler</span> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
13 |
</button> |
|
356
a45f7dac4789
Change wordings, align text.
Alexandre Segura <mex.zktk@gmail.com>
parents:
351
diff
changeset
|
14 |
<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
|
15 |
Aucune annotation sélectionnée |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
16 |
</div> |
|
339
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
17 |
<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
|
18 |
<slot> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
19 |
<!-- CSRF token --> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
20 |
</slot> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
21 |
<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
|
22 |
<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
|
23 |
<label v-if="!readonly || title" class="small text-muted">Titre</label> |
|
504
11a862e01b04
Implement annotation on the whole picture.
Alexandre Segura <mex.zktk@gmail.com>
parents:
485
diff
changeset
|
24 |
<input type="text" class="form-control" name="title" v-model="title" v-if="!readonly" ref="title"> |
|
402
376158f6d760
hides title and description if there is none
duong tam kien <tk@deveha.com>
parents:
400
diff
changeset
|
25 |
<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
|
26 |
</div> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
27 |
<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
|
28 |
<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
|
29 |
<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
|
30 |
<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
|
31 |
</div> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
32 |
<div v-if="annotation" class="form-group form-group-sm"> |
| 400 | 33 |
<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
|
34 |
<tag-list ref="taglist" |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
35 |
v-bind:original-tags="annotation.tags" |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
36 |
v-bind:readonly="readonly" |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
37 |
@change="onTagsChange($event.tags)"></tag-list> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
38 |
<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
|
39 |
</div> |
|
504
11a862e01b04
Implement annotation on the whole picture.
Alexandre Segura <mex.zktk@gmail.com>
parents:
485
diff
changeset
|
40 |
<p class="small text-center text-muted" v-if="annotation && annotation.annotation_guid"> |
|
482
b71475c27159
Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
433
diff
changeset
|
41 |
<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
|
42 |
<span>{{ dateComputed }} par</span>
|
|
b71475c27159
Add page with list of revisions.
Alexandre Segura <mex.zktk@gmail.com>
parents:
433
diff
changeset
|
43 |
<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
|
44 |
</p> |
|
339
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
45 |
<button type="submit" v-if="annotation && !readonly" v-bind:class="{ disabled: !hasChanged }"
|
|
504
11a862e01b04
Implement annotation on the whole picture.
Alexandre Segura <mex.zktk@gmail.com>
parents:
485
diff
changeset
|
46 |
class="btn btn-block btn-sm btn-primary">{{ submitButtonText }}</button>
|
|
339
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
47 |
</form> |
|
ba89f767b091
Introduce readonly prop in AnnotationForm & child components.
Alexandre Segura <mex.zktk@gmail.com>
parents:
333
diff
changeset
|
48 |
</div> |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
49 |
</template> |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
50 |
|
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
51 |
<script> |
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
52 |
import TagList from "../tagform/TagList.vue"; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
53 |
import _ from "lodash"; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
54 |
import showdown from "showdown"; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
55 |
import moment from "moment"; |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
56 |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
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 |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
59 |
var defaults = {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
60 |
title: "", |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
61 |
description: "", |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
62 |
fragment: "", |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
63 |
tags: [], |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
64 |
readonly: true |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
65 |
}; |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
66 |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
67 |
export default {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
68 |
props: {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
69 |
annotation: {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
70 |
type: Object, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
71 |
default: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
72 |
return null; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
73 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
74 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
75 |
isAuthenticated: {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
76 |
type: Boolean, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
77 |
default: false |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
78 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
79 |
revisionsUrl: String, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
80 |
authorUrl: String, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
81 |
newAnnotationUrl: String, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
82 |
editAnnotationUrl: String |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
83 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
84 |
components: {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
85 |
"tag-list": TagList |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
86 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
87 |
data() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
88 |
return defaults; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
89 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
90 |
mounted() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
91 |
if (this.annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
92 |
this.loadAnnotation(this.annotation); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
93 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
94 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
95 |
watch: {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
96 |
annotation: function(annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
97 |
if (annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
98 |
this.loadAnnotation(annotation); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
99 |
} else {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
100 |
this.reset(); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
101 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
102 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
103 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
104 |
computed: {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
105 |
descriptionComputed: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
106 |
return converter.makeHtml(this.description); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
107 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
108 |
lastRevisionText: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
109 |
if (this.annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
110 |
var date = moment(this.annotation.created).locale("fr");
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
111 |
return ( |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
112 |
"Dernière version " + |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
113 |
date.fromNow() + |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
114 |
" par " + |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
115 |
this.annotation.author |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
116 |
); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
117 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
118 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
119 |
revisionsUrlComputed: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
120 |
if (this.annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
121 |
return this.revisionsUrl.replace( |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
122 |
":annotation_guid", |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
123 |
this.annotation.annotation_guid |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
124 |
); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
125 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
126 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
127 |
authorUrlComputed: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
128 |
if (this.annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
129 |
return this.authorUrl.replace("--username--", this.annotation.author);
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
130 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
131 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
132 |
dateComputed: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
133 |
if (this.annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
134 |
return moment(this.annotation.created) |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
135 |
.locale("fr")
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
136 |
.fromNow(); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
137 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
138 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
139 |
formAction: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
140 |
if (this.annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
141 |
if (this.annotation.annotation_guid) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
142 |
return this.editAnnotationUrl.replace( |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
143 |
":annotation_guid", |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
144 |
this.annotation.annotation_guid |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
145 |
); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
146 |
} |
|
504
11a862e01b04
Implement annotation on the whole picture.
Alexandre Segura <mex.zktk@gmail.com>
parents:
485
diff
changeset
|
147 |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
148 |
return this.newAnnotationUrl; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
149 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
150 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
151 |
submitButtonText: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
152 |
return this.isNewAnnotation |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
153 |
? "Enregistrer" |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
154 |
: "Enregister une nouvelle version"; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
155 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
156 |
isNewAnnotation: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
157 |
return this.annotation && !this.annotation.annotation_guid; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
158 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
159 |
serializedTags: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
160 |
var tags = this.tags.map(function(tag) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
161 |
return {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
162 |
tag_input: |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
163 |
typeof tag.tag_link === "string" && tag.tag_link.length |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
164 |
? tag.tag_link |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
165 |
: tag.tag_label, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
166 |
tag_label: tag.tag_label, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
167 |
accuracy: tag.accuracy, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
168 |
relevancy: tag.relevancy |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
169 |
}; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
170 |
}); |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
171 |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
172 |
return JSON.stringify(tags); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
173 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
174 |
hasChanged: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
175 |
if (!this.annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
176 |
return false; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
177 |
} |
|
333
625ac8b8bb87
Improve change detection in TagList.
Alexandre Segura <mex.zktk@gmail.com>
parents:
327
diff
changeset
|
178 |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
179 |
return ( |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
180 |
this.title !== this.annotation.title || |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
181 |
this.description !== this.annotation.description || |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
182 |
!_.isEqual(this.annotation.tags, this.tags) |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
183 |
); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
184 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
185 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
186 |
methods: {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
187 |
onCancelClick: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
188 |
if (this.isNewAnnotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
189 |
this.$emit("close");
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
190 |
} else {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
191 |
this.readonly = !this.readonly; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
192 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
193 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
194 |
onTagsChange: function(tags) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
195 |
this.tags = tags; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
196 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
197 |
reset: function() {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
198 |
Object.assign(this, defaults); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
199 |
}, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
200 |
loadAnnotation(annotation) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
201 |
// Make sure we have an actual copy |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
202 |
Object.assign(this, {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
203 |
title: annotation.title, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
204 |
description: annotation.description, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
205 |
fragment: annotation.fragment, |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
206 |
tags: annotation.tags.slice(), |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
207 |
readonly: !this.isNewAnnotation |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
208 |
}); |
|
504
11a862e01b04
Implement annotation on the whole picture.
Alexandre Segura <mex.zktk@gmail.com>
parents:
485
diff
changeset
|
209 |
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
210 |
if (!annotation.annotation_guid) {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
211 |
setTimeout(() => {
|
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
212 |
$(this.$refs.title).focus(); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
213 |
}, 500); |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
214 |
} |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
215 |
} |
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
216 |
} |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
217 |
}; |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
218 |
</script> |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
219 |
|
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
220 |
<style scoped> |
|
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
221 |
form {
|
|
539
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
222 |
margin-bottom: 20px; |
|
08e2513dbc2f
Upgrade webpack to 4, upgrade vue.js, and some style changes
ymh <ymh.work@gmail.com>
parents:
504
diff
changeset
|
223 |
clear: both; |
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
224 |
} |
| 400 | 225 |
|
226 |
label {
|
|
227 |
font-weight: normal; |
|
228 |
} |
|
|
323
55c024fc7c60
Roughly implement annotation navigator.
Alexandre Segura <mex.zktk@gmail.com>
parents:
diff
changeset
|
229 |
</style> |