107 lines
2.1 KiB
Vue
107 lines
2.1 KiB
Vue
<template>
|
|
<div class="item">
|
|
<div v-if="edit_mode" class="tag">
|
|
<edit-tag v-model="edited_tag"></edit-tag>
|
|
</div>
|
|
<div v-else class="tag">
|
|
<div class="icon">
|
|
<font-awesome-icon :style="{ color: tag.color}" :icon="tag.icon" class="fa-2x"/>
|
|
</div>
|
|
<div class="description">
|
|
<h4>{{ tag.name }}</h4>
|
|
Mots clés<span v-if="tag.invert"> (tout sauf)</span>: {{ tag.words.join(" - ") }}
|
|
</div>
|
|
</div>
|
|
|
|
<div class="actions">
|
|
<b-button-group vertical>
|
|
<div v-if="edit_mode">
|
|
<b-button @click="save()">Sauver</b-button>
|
|
<b-button @click="toggleEdit()">Annuler</b-button>
|
|
<b-button @click="deleteIt()">Supprimer</b-button>
|
|
</div>
|
|
<div v-else>
|
|
<b-button @click="toggleEdit()">Editer</b-button>
|
|
</div>
|
|
</b-button-group>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import { mapGetters, mapActions } from 'vuex'
|
|
import editTag from './edit_tag'
|
|
export default {
|
|
name: 'tagItem',
|
|
components: {
|
|
editTag: editTag
|
|
},
|
|
props: [
|
|
'tagname'
|
|
],
|
|
data () {
|
|
return {
|
|
edit_mode: false,
|
|
edited_tag: {}
|
|
}
|
|
},
|
|
computed: {
|
|
...mapGetters('config', {
|
|
getTag: 'tag'
|
|
}),
|
|
tag () {
|
|
return this.getTag(this.tagname)
|
|
},
|
|
},
|
|
methods: {
|
|
...mapActions('config', [
|
|
'edit_tag',
|
|
'delete_tag'
|
|
]),
|
|
toggleEdit () {
|
|
// toggle edit mod for the tag
|
|
this.edited_tag = { ...this.tag }
|
|
this.edit_mode = !this.edit_mode
|
|
},
|
|
save () {
|
|
// Save the edited tag
|
|
this.edit_tag(this.edited_tag)
|
|
this.toggleEdit()
|
|
},
|
|
deleteIt () {
|
|
// Delete the edited tag
|
|
this.delete_tag(this.edited_tag.name)
|
|
this.toggleEdit()
|
|
}
|
|
}
|
|
}
|
|
|
|
</script>
|
|
|
|
<style scoped>
|
|
.item {
|
|
display: flex;
|
|
}
|
|
.tag {
|
|
flex: 90%;
|
|
text-align: left;
|
|
align-self: center;
|
|
display: flex;
|
|
}
|
|
.actions {
|
|
flex: 10%;
|
|
text-align: left;
|
|
margin-left: 10px;
|
|
align-self: center;
|
|
}
|
|
.icon {
|
|
flex: 10%;
|
|
align-self: center;
|
|
}
|
|
.description {
|
|
flex: 90%;
|
|
text-align: left;
|
|
align-self: center;
|
|
}
|
|
</style>
|