Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
label update
Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
  • Loading branch information
jakobroehrl authored and juliusknorr committed Apr 26, 2019
commit b3cb618707e9a28c8617b77fa9a53e5b061a8a0a
18 changes: 12 additions & 6 deletions src/components/board/TagsTabSidebard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<ul class="labels">
<li v-for="label in labels" :key="label.id">
<template v-if="editingLabelId === label.id">
<input :value="label.title"><input :value="label.color">
<button @click="updateLabel()">save</button><button @click="editingLabelId = null">cancel</button>
<input v-model="editingLabel.title" ><input v-model="editingLabel.color">
<button @click="updateLabel(label)">save</button><button @click="editingLabelId = null">cancel</button>
</template>
<template v-else>
<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>
<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>
</li>
</ul>
Expand All @@ -25,7 +25,8 @@ export default {
name: 'TagsTabSidebard',
data() {
return {
editingLabelId: null
editingLabelId: null,
editingLabel: null
}
},
computed: {
Expand All @@ -34,11 +35,16 @@ export default {
})
},
methods: {
clickEdit(label) {
this.editingLabelId = label.id
this.editingLabel = Object.assign({}, label)
},
deleteLabel(id) {
this.$store.dispatch('removeLabelFromCurrentBoard', id)
},
updateLabel(id, name) {

updateLabel(label) {
this.$store.dispatch('updateLabelFromCurrentBoard', this.editingLabel)
this.editingLabelId = null
}
}
}
Expand Down
18 changes: 15 additions & 3 deletions src/store/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,21 @@ export default new Vuex.Store({
// label mutators
removeLabelFromCurrentBoard(state, labelId) {
const removeIndex = state.currentBoard.labels.findIndex((l) => {
return labelId !== l.id
return labelId === l.id
})

if (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: {
Expand Down Expand Up @@ -227,6 +236,9 @@ export default new Vuex.Store({
// label actions
removeLabelFromCurrentBoard({ commit }, labelId) {
commit('removeLabelFromCurrentBoard', labelId);
}
},
updateLabelFromCurrentBoard({ commit }, newLabel) {
commit('updateLabelFromCurrentBoard', newLabel);
},
}
})
})