added picker, button update and small changes
Signed-off-by: Jakob Röhrl <jakob.roehrl@web.de>
This commit is contained in:
committed by
Julius Härtl
parent
1cd1684936
commit
49e1d8e8ec
@@ -3,31 +3,28 @@
|
|||||||
<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 v-model="editingLabel.title"><input v-model="editingLabel.color">
|
<input v-model="editingLabel.title">
|
||||||
|
<compact-picker :value=editingLabel.color @input="updateColor" :palette=defaultColors></compact-picker>
|
||||||
<button class="icon-checkmark" @click="updateLabel(label)" :disabled="!editLabelObjValidated"
|
<button class="icon-checkmark" @click="updateLabel(label)" :disabled="!editLabelObjValidated"
|
||||||
v-tooltip="{content: 'title and color must be provided',
|
v-tooltip="{content: missingDataLabel, show: !editLabelObjValidated, trigger: 'manual' }" />
|
||||||
show: !editLabelObjValidated, trigger: 'manual' }" />
|
|
||||||
|
|
||||||
<button v-tooltip="t('deck', 'Cancel')" class="icon-close" @click="editingLabelId = null" />
|
<button v-tooltip="t('deck', 'Cancel')" class="icon-close" @click="editingLabelId = null" />
|
||||||
</template>
|
</template>
|
||||||
<template v-else>
|
<template v-else>
|
||||||
<span :style="{ backgroundColor: `#${label.color}`, color: `#white` }" class="label-title">
|
<span :style="{ backgroundColor: `#${label.color}`, color:textColor(label.color) }" 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 v-tooltip="t('deck', 'Edit')" class="icon-rename" @click="clickEdit(label)" />
|
<button v-tooltip="t('deck', 'Edit')" class="icon-rename" @click="clickEdit(label)" />
|
||||||
|
|
||||||
|
|
||||||
<button v-tooltip="t('deck', 'Delete')" class="icon-delete" @click="deleteLabel(label.id)" />
|
<button v-tooltip="t('deck', 'Delete')" class="icon-delete" @click="deleteLabel(label.id)" />
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li v-if="addLabel">
|
<li v-if="addLabel">
|
||||||
<template>
|
<template>
|
||||||
<input v-model="addLabelObj.title"><input v-model="addLabelObj.color">
|
<input v-model="addLabelObj.title">
|
||||||
|
<compact-picker value="#fff" @input="updateColor" :palette=defaultColors></compact-picker>
|
||||||
<button class="icon-checkmark" @click="clickAddLabel()" :disabled="!addLabelObjValidated"
|
<button class="icon-checkmark" @click="clickAddLabel()" :disabled="!addLabelObjValidated"
|
||||||
v-tooltip="{content: 'title and color must be provided',
|
v-tooltip="{content: missingDataLabel, show: !addLabelObjValidated, trigger: 'manual' }" />
|
||||||
show: !addLabelObjValidated, trigger: 'manual' }" />
|
|
||||||
<button v-tooltip="t('deck', 'Cancel')" class="icon-close" @click="addLabel=false" />
|
<button v-tooltip="t('deck', 'Cancel')" class="icon-close" @click="addLabel=false" />
|
||||||
</template>
|
</template>
|
||||||
</li>
|
</li>
|
||||||
@@ -39,15 +36,23 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
|
import Color from '../../mixins/color'
|
||||||
|
import { Compact } from 'vue-color'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TagsTabSidebard',
|
name: 'TagsTabSidebard',
|
||||||
|
mixins: [Color],
|
||||||
|
components: {
|
||||||
|
'compact-picker': Compact
|
||||||
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
editingLabelId: null,
|
editingLabelId: null,
|
||||||
editingLabel: null,
|
editingLabel: null,
|
||||||
addLabelObj: null,
|
addLabelObj: null,
|
||||||
addLabel: false,
|
addLabel: false,
|
||||||
|
missingDataLabel: t('deck', 'title and color value must be provided'),
|
||||||
|
defaultColors: ['#31CC7C', '#317CCC', '#FF7A66', '#F1DB50', '#7C31CC', '#CC317C', '#3A3B3D', '#CACBCD']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -56,16 +61,27 @@ export default {
|
|||||||
}),
|
}),
|
||||||
addLabelObjValidated() {
|
addLabelObjValidated() {
|
||||||
if (this.addLabelObj.title == '') return false;
|
if (this.addLabelObj.title == '') return false;
|
||||||
if (this.addLabelObj.color == '') return false;
|
if (this.addLabelObj.color == '' ||
|
||||||
|
this.addLabelObj.color.length != 6) return false;
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
editLabelObjValidated() {
|
editLabelObjValidated() {
|
||||||
|
console.log(this.editingLabel.color)
|
||||||
if (this.editingLabel.title == '') return false;
|
if (this.editingLabel.title == '') return false;
|
||||||
if (this.editingLabel.color == '') return false;
|
if (this.editingLabel.color == '' ||
|
||||||
|
this.editingLabel.color.length != 6) return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
updateColor(c) {
|
||||||
|
if (this.editingLabel == null) {
|
||||||
|
this.addLabelObj.color = c.hex.substring(1,7)
|
||||||
|
} else {
|
||||||
|
this.editingLabel.color = c.hex.substring(1,7)
|
||||||
|
}
|
||||||
|
},
|
||||||
clickEdit(label) {
|
clickEdit(label) {
|
||||||
this.editingLabelId = label.id
|
this.editingLabelId = label.id
|
||||||
this.editingLabel = Object.assign({}, label)
|
this.editingLabel = Object.assign({}, label)
|
||||||
@@ -78,14 +94,14 @@ export default {
|
|||||||
this.editingLabelId = null
|
this.editingLabelId = null
|
||||||
},
|
},
|
||||||
clickShowAddLabel() {
|
clickShowAddLabel() {
|
||||||
this.addLabelObj = { boardId: 1, cardId: null, color: '000', title: 'new'}
|
this.addLabelObj = { cardId: null, color: '000', title: ''}
|
||||||
this.addLabel=true
|
this.addLabel=true
|
||||||
},
|
},
|
||||||
clickAddLabel() {
|
clickAddLabel() {
|
||||||
this.$store.dispatch('addLabelToCurrentBoard', this.addLabelObj)
|
this.$store.dispatch('addLabelToCurrentBoard', this.addLabelObj)
|
||||||
this.addLabel = false
|
this.addLabel = false
|
||||||
this.addLabelObj = null
|
this.addLabelObj = null
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ export class BoardApi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateLabel(label) {
|
updateLabel(label) {
|
||||||
return axios.put(this.url('/labels/${label.id}'), label)
|
return axios.put(this.url(`/labels/${label.id}`), label)
|
||||||
.then(
|
.then(
|
||||||
(response) => {
|
(response) => {
|
||||||
return Promise.resolve(response.data)
|
return Promise.resolve(response.data)
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ export default new Vuex.Store({
|
|||||||
|
|
||||||
// label mutators
|
// label mutators
|
||||||
removeLabelFromCurrentBoard(state, labelId) {
|
removeLabelFromCurrentBoard(state, labelId) {
|
||||||
console.log(labelId)
|
|
||||||
const removeIndex = state.currentBoard.labels.findIndex((l) => {
|
const removeIndex = state.currentBoard.labels.findIndex((l) => {
|
||||||
return labelId === l.id
|
return labelId === l.id
|
||||||
})
|
})
|
||||||
@@ -252,6 +251,7 @@ export default new Vuex.Store({
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
addLabelToCurrentBoard({ commit }, newLabel) {
|
addLabelToCurrentBoard({ commit }, newLabel) {
|
||||||
|
newLabel.boardId = this.state.currentBoard.id
|
||||||
apiClient.createLabel(newLabel)
|
apiClient.createLabel(newLabel)
|
||||||
.then((newLabel) => {
|
.then((newLabel) => {
|
||||||
commit('addLabelToCurrentBoard', newLabel);
|
commit('addLabelToCurrentBoard', newLabel);
|
||||||
|
|||||||
Reference in New Issue
Block a user