committed by
Julius Härtl
parent
96ec6b812c
commit
b3cb618707
@@ -3,14 +3,14 @@
|
|||||||
<ul class="labels">
|
<ul class="labels">
|
||||||
<li v-for="label in labels" :key="label.id">
|
<li v-for="label in labels" :key="label.id">
|
||||||
<template v-if="editingLabelId === label.id">
|
<template v-if="editingLabelId === label.id">
|
||||||
<input :value="label.title"><input :value="label.color">
|
<input v-model="editingLabel.title" ><input v-model="editingLabel.color">
|
||||||
<button @click="updateLabel()">save</button><button @click="editingLabelId = null">cancel</button>
|
<button @click="updateLabel(label)">save</button><button @click="editingLabelId = null">cancel</button>
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span :style="{ backgroundColor: `#${label.color}`, color: `#white` }" class="label-title">
|
<span :style="{ backgroundColor: `#${label.color}`, color: `#white` }" class="label-title">
|
||||||
<span v-if="label.title">{{ label.title }}</span><i v-if="!label.title"><br></i>
|
<span v-if="label.title">{{ label.title }}</span><i v-if="!label.title"><br></i>
|
||||||
</span>
|
</span>
|
||||||
<button @click="editingLabelId=label.id">edit</button><button @click="deleteLabel(label.id)">delete</button>
|
<button @click="clickEdit(label)">edit</button><button @click="deleteLabel(label.id)">delete</button>
|
||||||
</template>
|
</template>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
@@ -25,7 +25,8 @@ export default {
|
|||||||
name: 'TagsTabSidebard',
|
name: 'TagsTabSidebard',
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editingLabelId: null
|
editingLabelId: null,
|
||||||
|
editingLabel: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -34,11 +35,16 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
clickEdit(label) {
|
||||||
|
this.editingLabelId = label.id
|
||||||
|
this.editingLabel = Object.assign({}, label)
|
||||||
|
},
|
||||||
deleteLabel(id) {
|
deleteLabel(id) {
|
||||||
this.$store.dispatch('removeLabelFromCurrentBoard', id)
|
this.$store.dispatch('removeLabelFromCurrentBoard', id)
|
||||||
},
|
},
|
||||||
updateLabel(id, name) {
|
updateLabel(label) {
|
||||||
|
this.$store.dispatch('updateLabelFromCurrentBoard', this.editingLabel)
|
||||||
|
this.editingLabelId = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -140,12 +140,21 @@ export default new Vuex.Store({
|
|||||||
// label mutators
|
// label mutators
|
||||||
removeLabelFromCurrentBoard(state, labelId) {
|
removeLabelFromCurrentBoard(state, labelId) {
|
||||||
const removeIndex = state.currentBoard.labels.findIndex((l) => {
|
const removeIndex = state.currentBoard.labels.findIndex((l) => {
|
||||||
return labelId !== l.id
|
return labelId === l.id
|
||||||
})
|
})
|
||||||
|
|
||||||
if (removeIndex > -1) {
|
if (removeIndex > -1) {
|
||||||
state.currentBoard.labels.splice(removeIndex, 1)
|
state.currentBoard.labels.splice(removeIndex, 1)
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
updateLabelFromCurrentBoard(state, newLabel) {
|
||||||
|
|
||||||
|
let labelToUpdate = state.currentBoard.labels.find((l) => {
|
||||||
|
return newLabel.id === l.id
|
||||||
|
})
|
||||||
|
|
||||||
|
labelToUpdate.title = newLabel.title
|
||||||
|
labelToUpdate.color = newLabel.color
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@@ -227,6 +236,9 @@ export default new Vuex.Store({
|
|||||||
// label actions
|
// label actions
|
||||||
removeLabelFromCurrentBoard({ commit }, labelId) {
|
removeLabelFromCurrentBoard({ commit }, labelId) {
|
||||||
commit('removeLabelFromCurrentBoard', labelId);
|
commit('removeLabelFromCurrentBoard', labelId);
|
||||||
}
|
},
|
||||||
|
updateLabelFromCurrentBoard({ commit }, newLabel) {
|
||||||
|
commit('updateLabelFromCurrentBoard', newLabel);
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
Reference in New Issue
Block a user