Implement edit board name
Signed-off-by: Michael Weimann <mail@michael-weimann.eu>
This commit is contained in:
@@ -21,7 +21,7 @@
|
|||||||
-->
|
-->
|
||||||
<template>
|
<template>
|
||||||
<router-link :id="`board-${board.id}`"
|
<router-link :id="`board-${board.id}`"
|
||||||
:title="board.title" :class="[{'icon-loading-small': loading, deleted: deleted }, classes]"
|
:title="board.title" :class="[{'icon-loading-small': loading, deleted: deleted, editing: editing }, classes]"
|
||||||
:to="routeTo" tag="li">
|
:to="routeTo" tag="li">
|
||||||
<div :style="{ backgroundColor: `#${board.color}` }" class="app-navigation-entry-bullet" />
|
<div :style="{ backgroundColor: `#${board.color}` }" class="app-navigation-entry-bullet" />
|
||||||
<a href="#">
|
<a href="#">
|
||||||
@@ -48,6 +48,16 @@
|
|||||||
class="app-navigation-entry-deleted-button icon-history"
|
class="app-navigation-entry-deleted-button icon-history"
|
||||||
@click="unDelete" />
|
@click="unDelete" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- edit entry -->
|
||||||
|
<div v-if="editing" class="app-navigation-entry-edit">
|
||||||
|
<form @submit.prevent.stop="applyEdit">
|
||||||
|
<input v-model="editTitle" type="text">
|
||||||
|
<input type="submit" value="" class="icon-confirm">
|
||||||
|
<input type="submit" value="" class="icon-close"
|
||||||
|
@click.stop.prevent="cancelEdit">
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
</router-link>
|
</router-link>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -74,8 +84,10 @@ export default {
|
|||||||
classes: [],
|
classes: [],
|
||||||
deleted: false,
|
deleted: false,
|
||||||
loading: false,
|
loading: false,
|
||||||
|
editing: false,
|
||||||
menuOpen: false,
|
menuOpen: false,
|
||||||
undoTimeoutHandle: null
|
undoTimeoutHandle: null,
|
||||||
|
editTitle: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -96,7 +108,11 @@ export default {
|
|||||||
if (this.loading === false) {
|
if (this.loading === false) {
|
||||||
|
|
||||||
actions.push({
|
actions.push({
|
||||||
action: () => {},
|
action: () => {
|
||||||
|
this.hideMenu()
|
||||||
|
this.editTitle = this.board.title
|
||||||
|
this.editing = true
|
||||||
|
},
|
||||||
icon: 'icon-edit',
|
icon: 'icon-edit',
|
||||||
text: t('deck', 'Edit board')
|
text: t('deck', 'Edit board')
|
||||||
})
|
})
|
||||||
@@ -160,11 +176,20 @@ export default {
|
|||||||
hideMenu() {
|
hideMenu() {
|
||||||
this.menuOpen = false
|
this.menuOpen = false
|
||||||
},
|
},
|
||||||
cancelEdit(e) {
|
applyEdit(e) {
|
||||||
const editingIdx = this.classes.indexOf('editing')
|
this.editing = false
|
||||||
if (editingIdx !== -1) {
|
if (this.editTitle) {
|
||||||
this.classes.splice(editingIdx, 1)
|
this.loading = true
|
||||||
|
const copy = JSON.parse(JSON.stringify(this.board))
|
||||||
|
copy.title = this.editTitle
|
||||||
|
this.$store.dispatch('updateBoard', copy)
|
||||||
|
.then(() => {
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
cancelEdit(e) {
|
||||||
|
this.editing = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inject: [
|
inject: [
|
||||||
@@ -172,3 +197,9 @@ export default {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
#app-navigation #deck-navigation .editing {
|
||||||
|
height: auto !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -82,6 +82,13 @@ export default new Vuex.Store({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
|
/**
|
||||||
|
* Adds or replaces a board in the store.
|
||||||
|
* Matches a board by it's id.
|
||||||
|
*
|
||||||
|
* @param state
|
||||||
|
* @param board
|
||||||
|
*/
|
||||||
addBoard(state, board) {
|
addBoard(state, board) {
|
||||||
const indexExisting = state.boards.findIndex((b) => {
|
const indexExisting = state.boards.findIndex((b) => {
|
||||||
return board.id === b.id
|
return board.id === b.id
|
||||||
@@ -137,6 +144,17 @@ export default new Vuex.Store({
|
|||||||
commit('addBoard', board)
|
commit('addBoard', board)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* Updates a board API side.
|
||||||
|
*
|
||||||
|
* @param commit
|
||||||
|
* @param board The board to update.
|
||||||
|
* @return {Promise<void>}
|
||||||
|
*/
|
||||||
|
async updateBoard({ commit }, board) {
|
||||||
|
const storedBoard = await apiClient.updateBoard(board)
|
||||||
|
commit('addBoard', storedBoard)
|
||||||
|
},
|
||||||
createBoard({ commit }, boardData) {
|
createBoard({ commit }, boardData) {
|
||||||
apiClient.createBoard(boardData)
|
apiClient.createBoard(boardData)
|
||||||
.then((board) => {
|
.then((board) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user