Feat(tag): Start creating new tag

This commit is contained in:
Bertrand Benjamin 2019-01-28 15:14:22 +01:00
parent f5bbf195f3
commit 62ec65ce53
3 changed files with 42 additions and 14 deletions

View File

@ -41,7 +41,7 @@ tags:
variant: info variant: info
icon: directions icon: directions
invert: true invert: true
color: '#f6b93b' color: '#fc69e6'
words: words:
- PAIEMENT - PAIEMENT
- RETRAIT - RETRAIT

View File

@ -4,7 +4,7 @@
<font-awesome-icon :style="{ color: value.color}" :icon="value.icon" class="fa-2x"/> <font-awesome-icon :style="{ color: value.color}" :icon="value.icon" class="fa-2x"/>
</div> </div>
<div class="description"> <div class="description">
<div v-if="value.name"> <div v-if="existing_tag">
<h4>{{ value.name }}</h4> <h4>{{ value.name }}</h4>
</div> </div>
<div v-else> <div v-else>
@ -42,11 +42,14 @@ export default {
props: { props: {
value: { value: {
type: Object, type: Object,
default: { default: function () {
return {
color: '', color: '',
icon: '', icon: 'question',
name: '', name: '',
variant: '' variant: '',
words: []
}
} }
} }
}, },
@ -55,6 +58,9 @@ export default {
} }
}, },
computed: { computed: {
...mapGetters({
'tag': 'config/tag',
}),
keywords: { keywords: {
get: function () { get: function () {
return this.value.words.join('\n') return this.value.words.join('\n')
@ -63,6 +69,9 @@ export default {
var kwds = keywords.split('\n') var kwds = keywords.split('\n')
this.value.words = kwds this.value.words = kwds
} }
},
existing_tag () {
return this.tag(this.value.name) ? true : false
} }
}, },
methods: { methods: {

View File

@ -33,12 +33,26 @@
<b-button @click="reload_config" size="sm"> <b-button @click="reload_config" size="sm">
<font-awesome-icon icon="sync-alt" class="fa" /> Recharger <font-awesome-icon icon="sync-alt" class="fa" /> Recharger
</b-button> </b-button>
</p>
<p> <p>
Le fichier configuration se trouve à <span class="dir">{{ config_dir + config_filename}}</span> Le fichier configuration se trouve à <span class="dir">{{ config_dir + config_filename}}</span>
</p> </p>
</p>
<h2>Tags</h2> <h2>Tags</h2>
<b-list-group> <b-list-group>
<b-list-group-item>
<div v-if="!newTag">
<b-button @click="toggle_new_tag" size="sm">
<font-awesome-icon icon="plus" class="fa" /> Ajouter un tag
</b-button>
</div>
<div v-else>
<h4> Nouveau tag </h4>
<tag-edit></tag-edit>
<b-button @click="toggle_new_tag" size="sm">
<font-awesome-icon icon="ban" class="fa" /> Annuler
</b-button>
</div>
</b-list-group-item>
<b-list-group-item v-for="tag in tags"> <b-list-group-item v-for="tag in tags">
<tag-item :tagname="tag.name"></tag-item> <tag-item :tagname="tag.name"></tag-item>
</b-list-group-item> </b-list-group-item>
@ -55,17 +69,19 @@
<script> <script>
import { mapGetters, mapActions } from 'vuex' import { mapGetters, mapActions } from 'vuex'
import tagItem from '../components/item_tag' import tagItem from '../components/item_tag'
import tagEdit from '../components/edit_tag'
import categorieItem from '../components/item_categorie' import categorieItem from '../components/item_categorie'
export default { export default {
name: 'home', name: 'home',
components: { components: {
'tag-item': tagItem, 'tag-item': tagItem,
'tag-edit': tagEdit,
'categorie-item': categorieItem 'categorie-item': categorieItem
}, },
data () { data () {
return { return {
file: '' newTag: false
} }
}, },
mounted: function () { mounted: function () {
@ -90,6 +106,9 @@ export default {
}), }),
open_filebrowser (dir) { open_filebrowser (dir) {
console.log("plop") console.log("plop")
},
toggle_new_tag () {
this.newTag = !this.newTag
} }
} }
} }