-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodules.js
78 lines (76 loc) · 2.34 KB
/
modules.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
module.exports = {
'module-word': {
props: ['mode', 'entry'],
template: String.raw`<div>
<input v-show="mode === 'edit'" v-model="entry.word" id="input_word">
<h2 v-show="mode === 'view'">{{ entry.word }}</h2>
</div>`,
data() {
return {
name: 'word',
default_values: {
word: ''
}
}
}
},
'module-definition': {
props: ['mode', 'entry'],
template: String.raw`<div>
<textarea v-show="mode === 'edit'" v-model="entry.definition" class="scrollable"></textarea>
<span v-show="mode === 'view'" id="span_definition">{{ entry.definition }}</span>
</div>`,
data() {
return {
name: 'definition',
default_values: {
definition: ''
}
}
}
},
'module-tags': {
props: ['mode', 'entry', 'search_text'],
template: String.raw`<div id="div_tags">
<input id="input_tags" type="text" v-show="mode === 'edit'" v-model="entry.tags"/>
<div class="bt_tag" v-for="tag in entry.tags.split(/[^\w]/).filter(Boolean)" v-show="mode === 'view'" v-on:click="select_tag(tag)">
{{tag}}
</div>
</div>`,
data() {
return {
name: 'tags',
default_values: {
tags: ''
}
}
},
methods: {
select_tag(tag_name) {
this.$emit('update:search_text', 'tag:'+tag_name);
}
}
},
'module-synonyms': {
props: ['mode', 'entry'],
template: String.raw`<div id="div_synonyms">
<input id="input_synonyms" type="text" v-show="mode === 'edit'" v-model="entry.synonyms"/>
<div class="bt_tag" v-for="synonym in entry.synonyms.split(/[^\w]/).filter(Boolean)" v-show="mode === 'view'" v-on:click="select_entry(synonym)">
{{ synonym }}
</div>
</div>`,
data() {
return {
name: 'synonyms',
default_values: {
synonyms: ''
}
}
},
methods: {
select_entry(word) {
this.$emit('select_entry', word)
}
}
}
}