Merge pull request #1579 from nextcloud/bugfix/card-store-cleanup
Card store cleanup
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
<label for="new-stack-input-main" class="hidden-visually">{{ t('deck', 'Add new list') }}</label>
|
<label for="new-stack-input-main" class="hidden-visually">{{ t('deck', 'Add new list') }}</label>
|
||||||
<input id="new-stack-input-main"
|
<input id="new-stack-input-main"
|
||||||
v-model="newStackTitle"
|
v-model="newStackTitle"
|
||||||
|
v-focus
|
||||||
type="text"
|
type="text"
|
||||||
class="no-close"
|
class="no-close"
|
||||||
:placeholder="t('deck', 'List name')"
|
:placeholder="t('deck', 'List name')"
|
||||||
|
|||||||
@@ -51,17 +51,22 @@
|
|||||||
</Actions>
|
</Actions>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form v-if="showAddCard" class="stack--card-add" @submit.prevent="clickAddCard()">
|
<form v-if="showAddCard"
|
||||||
|
class="stack--card-add"
|
||||||
|
:class="{ 'icon-loading-small': stateCardCreating }"
|
||||||
|
@submit.prevent="clickAddCard()">
|
||||||
<label for="new-stack-input-main" class="hidden-visually">{{ t('deck', 'Add a new card') }}</label>
|
<label for="new-stack-input-main" class="hidden-visually">{{ t('deck', 'Add a new card') }}</label>
|
||||||
<input id="new-stack-input-main"
|
<input id="new-stack-input-main"
|
||||||
v-model="newCardTitle"
|
v-model="newCardTitle"
|
||||||
v-focus
|
v-focus
|
||||||
type="text"
|
type="text"
|
||||||
class="no-close"
|
class="no-close"
|
||||||
|
:disabled="stateCardCreating"
|
||||||
placeholder="Add a new card"
|
placeholder="Add a new card"
|
||||||
required>
|
required>
|
||||||
|
|
||||||
<input class="icon-confirm"
|
<input v-show="!stateCardCreating"
|
||||||
|
class="icon-confirm"
|
||||||
type="submit"
|
type="submit"
|
||||||
value="">
|
value="">
|
||||||
</form>
|
</form>
|
||||||
@@ -108,6 +113,7 @@ export default {
|
|||||||
copiedStack: '',
|
copiedStack: '',
|
||||||
newCardTitle: '',
|
newCardTitle: '',
|
||||||
showAddCard: false,
|
showAddCard: false,
|
||||||
|
stateCardCreating: false,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -160,15 +166,21 @@ export default {
|
|||||||
}
|
}
|
||||||
this.editing = false
|
this.editing = false
|
||||||
},
|
},
|
||||||
clickAddCard() {
|
async clickAddCard() {
|
||||||
const newCard = {
|
this.stateCardCreating = true
|
||||||
|
try {
|
||||||
|
await this.$store.dispatch('addCard', {
|
||||||
title: this.newCardTitle,
|
title: this.newCardTitle,
|
||||||
stackId: this.stack.id,
|
stackId: this.stack.id,
|
||||||
boardId: this.stack.boardId,
|
boardId: this.stack.boardId,
|
||||||
}
|
})
|
||||||
this.$store.dispatch('addCard', newCard)
|
|
||||||
this.newCardTitle = ''
|
this.newCardTitle = ''
|
||||||
this.showAddCard = false
|
this.showAddCard = false
|
||||||
|
} catch (e) {
|
||||||
|
OCP.Toast.error('Could not create card: ' + e.response.data.message)
|
||||||
|
} finally {
|
||||||
|
this.stateCardCreating = false
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -209,11 +221,14 @@ export default {
|
|||||||
|
|
||||||
.stack--card-add {
|
.stack--card-add {
|
||||||
display: flex;
|
display: flex;
|
||||||
margin-left: 3px;
|
margin-bottom: 10px;
|
||||||
margin-right: 3px;
|
box-shadow: 0 0 3px var(--color-box-shadow);
|
||||||
box-shadow: 0 0 3px #aaa;
|
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
margin-bottom: 15px;
|
|
||||||
|
&.icon-loading-small:after,
|
||||||
|
&.icon-loading-small-dark:after {
|
||||||
|
margin-left: calc(50% - 25px);
|
||||||
|
}
|
||||||
|
|
||||||
input[type=text] {
|
input[type=text] {
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|||||||
@@ -227,6 +227,8 @@ export default {
|
|||||||
|
|
||||||
if (this.currentCard.assignedUsers.length > 0) {
|
if (this.currentCard.assignedUsers.length > 0) {
|
||||||
this.assignedUsers = this.currentCard.assignedUsers.map((item) => item.participant)
|
this.assignedUsers = this.currentCard.assignedUsers.map((item) => item.participant)
|
||||||
|
} else {
|
||||||
|
this.assignedUsers = []
|
||||||
}
|
}
|
||||||
|
|
||||||
this.desc = this.currentCard.description
|
this.desc = this.currentCard.description
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ export default {
|
|||||||
},
|
},
|
||||||
finishedEdit(card) {
|
finishedEdit(card) {
|
||||||
if (this.copiedCard.title !== card.title) {
|
if (this.copiedCard.title !== card.title) {
|
||||||
this.$store.dispatch('updateCard', this.copiedCard)
|
this.$store.dispatch('updateCardTitle', this.copiedCard)
|
||||||
}
|
}
|
||||||
this.editing = false
|
this.editing = false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -53,6 +53,14 @@ Vue.directive('focus', {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Vue.config.errorHandler = (err, vm, info) => {
|
||||||
|
if (err.response && err.response.data.message) {
|
||||||
|
const errorMessage = t('deck', 'Something went wrong')
|
||||||
|
OCP.Toast.error(`${errorMessage}: ${err.response.data.status} ${err.response.data.message}`)
|
||||||
|
}
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
|
||||||
/* eslint-disable-next-line no-new */
|
/* eslint-disable-next-line no-new */
|
||||||
new Vue({
|
new Vue({
|
||||||
el: '#content',
|
el: '#content',
|
||||||
|
|||||||
@@ -119,12 +119,6 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateTitle(state, card) {
|
|
||||||
const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
|
|
||||||
if (existingIndex !== -1) {
|
|
||||||
state.cards[existingIndex].title = card.title
|
|
||||||
}
|
|
||||||
},
|
|
||||||
assignCardToUser(state, user) {
|
assignCardToUser(state, user) {
|
||||||
const existingIndex = state.cards.findIndex(_card => _card.id === user.cardId)
|
const existingIndex = state.cards.findIndex(_card => _card.id === user.cardId)
|
||||||
if (existingIndex !== -1) {
|
if (existingIndex !== -1) {
|
||||||
@@ -140,44 +134,25 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateCardDesc(state, card) {
|
updateCardProperty(state, { card, property }) {
|
||||||
const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
|
const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
|
||||||
if (existingIndex !== -1) {
|
if (existingIndex !== -1) {
|
||||||
state.cards[existingIndex].description = card.description
|
Vue.set(state.cards[existingIndex], property, card[property])
|
||||||
}
|
|
||||||
},
|
|
||||||
updateCardDue(state, card) {
|
|
||||||
const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
|
|
||||||
if (existingIndex !== -1) {
|
|
||||||
state.cards[existingIndex].duedate = card.duedate
|
|
||||||
}
|
|
||||||
},
|
|
||||||
updateCardLabels(state, card) {
|
|
||||||
const existingIndex = state.cards.findIndex(_card => _card.id === card.id)
|
|
||||||
if (existingIndex !== -1) {
|
|
||||||
const existingCard = state.cards.find(_card => _card.id === card.id)
|
|
||||||
existingCard.labels = card.labels
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
addCard({ commit }, card) {
|
async addCard({ commit }, card) {
|
||||||
apiClient.addCard(card)
|
const createdCard = await apiClient.addCard(card)
|
||||||
.then((createdCard) => {
|
|
||||||
commit('addCard', createdCard)
|
commit('addCard', createdCard)
|
||||||
})
|
|
||||||
},
|
},
|
||||||
updateCard({ commit }, card) {
|
async updateCardTitle({ commit }, card) {
|
||||||
apiClient.updateCard(card)
|
const updatedCard = await apiClient.updateCard(card)
|
||||||
.then((updatedCard) => {
|
commit('updateCardProperty', { property: 'title', card: updatedCard })
|
||||||
commit('updateTitle', updatedCard)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
moveCard({ commit }, card) {
|
async moveCard({ commit }, card) {
|
||||||
apiClient.updateCard(card)
|
const updatedCard = await apiClient.updateCard(card)
|
||||||
.then((updatedCard) => {
|
|
||||||
commit('deleteCard', updatedCard)
|
commit('deleteCard', updatedCard)
|
||||||
})
|
|
||||||
},
|
},
|
||||||
async reorderCard({ commit, getters }, card) {
|
async reorderCard({ commit, getters }, card) {
|
||||||
let i = 0
|
let i = 0
|
||||||
@@ -196,66 +171,47 @@ export default {
|
|||||||
|
|
||||||
const cards = await apiClient.reorderCard(card)
|
const cards = await apiClient.reorderCard(card)
|
||||||
await commit('updateCardsReorder', Object.values(cards))
|
await commit('updateCardsReorder', Object.values(cards))
|
||||||
|
|
||||||
},
|
},
|
||||||
deleteCard({ commit }, card) {
|
async deleteCard({ commit }, card) {
|
||||||
apiClient.deleteCard(card.id)
|
await apiClient.deleteCard(card.id)
|
||||||
.then((card) => {
|
|
||||||
commit('deleteCard', card)
|
commit('deleteCard', card)
|
||||||
})
|
|
||||||
},
|
},
|
||||||
archiveUnarchiveCard({ commit }, card) {
|
async archiveUnarchiveCard({ commit }, card) {
|
||||||
let call = 'archiveCard'
|
let call = 'archiveCard'
|
||||||
if (card.archived === false) {
|
if (card.archived === false) {
|
||||||
call = 'unArchiveCard'
|
call = 'unArchiveCard'
|
||||||
}
|
}
|
||||||
|
|
||||||
apiClient[call](card)
|
const updatedCard = await apiClient[call](card)
|
||||||
.then((card) => {
|
commit('deleteCard', updatedCard)
|
||||||
commit('deleteCard', card)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
assignCardToUser({ commit }, card) {
|
async assignCardToUser({ commit }, card) {
|
||||||
apiClient.assignUser(card)
|
const user = await apiClient.assignUser(card)
|
||||||
.then((user) => {
|
|
||||||
commit('assignCardToUser', user)
|
commit('assignCardToUser', user)
|
||||||
})
|
|
||||||
},
|
},
|
||||||
removeUserFromCard({ commit }, card) {
|
async removeUserFromCard({ commit }, card) {
|
||||||
apiClient.removeUser(card)
|
const user = await apiClient.removeUser(card)
|
||||||
.then((user) => {
|
|
||||||
commit('removeUserFromCard', user)
|
commit('removeUserFromCard', user)
|
||||||
})
|
|
||||||
},
|
},
|
||||||
addLabel({ commit }, data) {
|
async addLabel({ commit }, data) {
|
||||||
apiClient.assignLabelToCard(data)
|
await apiClient.assignLabelToCard(data)
|
||||||
.then(() => {
|
commit('updateCardProperty', { property: 'labels', card: data.card })
|
||||||
commit('updateCardLabels', data.card)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
removeLabel({ commit }, data) {
|
async removeLabel({ commit }, data) {
|
||||||
apiClient.removeLabelFromCard(data)
|
await apiClient.removeLabelFromCard(data)
|
||||||
.then(() => {
|
commit('updateCardProperty', { property: 'labels', card: data.card })
|
||||||
commit('updateCardLabels', data.card)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
cardUndoDelete({ commit }, card) {
|
async cardUndoDelete({ commit }, card) {
|
||||||
apiClient.updateCard(card)
|
const updatedCard = await apiClient.updateCard(card)
|
||||||
.then((card) => {
|
commit('addCard', updatedCard)
|
||||||
commit('addCard', card)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
updateCardDesc({ commit }, card) {
|
async updateCardDesc({ commit }, card) {
|
||||||
apiClient.updateCard(card)
|
const updatedCard = await apiClient.updateCard(card)
|
||||||
.then((updatedCard) => {
|
commit('updateCardProperty', { property: 'description', card: updatedCard })
|
||||||
commit('updateCardDesc', updatedCard)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
updateCardDue({ commit }, card) {
|
async updateCardDue({ commit }, card) {
|
||||||
apiClient.updateCard(card)
|
const updatedCard = apiClient.updateCard(card)
|
||||||
.then((card) => {
|
commit('updateCardProperty', { property: 'duedate', card: updatedCard })
|
||||||
commit('updateCardDue', card)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user