From a73b761a721b78dbda72678d564c822d1f9cf75f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Thu, 20 Aug 2020 10:28:57 +0200 Subject: [PATCH] Allow editing cards on filtered views MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- src/components/cards/CardItem.vue | 10 +++++-- src/components/cards/CardMenu.vue | 9 +++++-- src/components/dashboards/Dashboards.vue | 34 ++++++++++++------------ src/store/dashboard.js | 12 +++++++-- 4 files changed, 42 insertions(+), 23 deletions(-) diff --git a/src/components/cards/CardItem.vue b/src/components/cards/CardItem.vue index 54b58faf2..3d0207cbc 100644 --- a/src/components/cards/CardItem.vue +++ b/src/components/cards/CardItem.vue @@ -113,9 +113,15 @@ export default { currentBoard: state => state.currentBoard, }), ...mapGetters([ - 'canEdit', 'isArchived', ]), + canEdit() { + if (this.currentBoard) { + return this.$store.getters.canEdit + } + const board = this.$store.getters.boards.find((item) => item.id === this.card.boardId) + return board.permissions.PERMISSION_EDIT + }, card() { return this.item ? this.item : this.$store.getters.cardById(this.id) }, @@ -148,7 +154,7 @@ export default { }, methods: { openCard() { - const boardId = this.item ? this.item.boardId : this.$route.params.id + const boardId = this.card ? this.card.boardId : this.$route.params.id this.$router.push({ name: 'card', params: { id: boardId, cardId: this.card.id } }).catch(() => {}) }, startEditing(card) { diff --git a/src/components/cards/CardMenu.vue b/src/components/cards/CardMenu.vue index 436518a09..f75e305d8 100644 --- a/src/components/cards/CardMenu.vue +++ b/src/components/cards/CardMenu.vue @@ -95,14 +95,19 @@ export default { }, computed: { ...mapGetters([ - 'canEdit', 'isArchived', ]), ...mapState({ showArchived: state => state.showArchived, currentBoard: state => state.currentBoard, }), - + canEdit() { + if (this.currentBoard) { + return this.$store.getters.canEdit + } + const board = this.$store.getters.boards.find((item) => item.id === this.card.boardId) + return board.permissions.PERMISSION_EDIT + }, isBoardAndStackChoosen() { if (this.selectedBoard === '' || this.selectedStack === '') { return false diff --git a/src/components/dashboards/Dashboards.vue b/src/components/dashboards/Dashboards.vue index 2e3593149..728c758ef 100644 --- a/src/components/dashboards/Dashboards.vue +++ b/src/components/dashboards/Dashboards.vue @@ -26,44 +26,44 @@
-

{{ t('deck', 'Loading Dashboard') }}

+

{{ t('deck', 'Loading filtered view') }}

-

{{ t('deck', 'overdue') }}

+

{{ t('deck', 'Overdue') }}

- +
-

{{ t('deck', 'today') }}

+

{{ t('deck', 'Today') }}

- +
-

{{ t('deck', 'tomorrow') }}

+

{{ t('deck', 'Tomorrow') }}

- +
-

{{ t('deck', 'this week') }}

+

{{ t('deck', 'This week') }}

- +
-

{{ t('deck', 'later') }}

+

{{ t('deck', 'Later') }}

- +
@@ -72,42 +72,42 @@

{{ t('deck', 'no due') }}

- +

{{ t('deck', 'overdue') }}

- +

{{ t('deck', 'today') }}

- +

{{ t('deck', 'tomorrow') }}

- +

{{ t('deck', 'this week') }}

- +

{{ t('deck', 'later') }}

- +
diff --git a/src/store/dashboard.js b/src/store/dashboard.js index 1172631bf..ef581506f 100644 --- a/src/store/dashboard.js +++ b/src/store/dashboard.js @@ -56,14 +56,22 @@ export default { }, actions: { async loadDueDashboard({ commit }) { - const withDue = await apiClient.findAllWithDue() - const withDueFlat = withDue.flat() + commit('setCurrentBoard', null) + const cardsWithDueDate = await apiClient.findAllWithDue() + const withDueFlat = cardsWithDueDate.flat() + for (const i in withDueFlat) { + commit('addCard', withDueFlat[i]) + } commit('setWithDueDashboard', withDueFlat) }, async loadAssignDashboard({ commit }) { + commit('setCurrentBoard', null) const assignedCards = await apiClient.findMyAssignedCards() const assignedCardsFlat = assignedCards.flat() + for (const i in assignedCardsFlat) { + commit('addCard', assignedCardsFlat[i]) + } commit('setAssignedCards', assignedCardsFlat) }, },