Skip to content

Commit

Permalink
feat: remember last board, list for new card dialog
Browse files Browse the repository at this point in the history
Signed-off-by: Luka Trovic <luka@nextcloud.com>
  • Loading branch information
luka-nextcloud committed Aug 24, 2023
1 parent 56a0025 commit e03e57e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
7 changes: 2 additions & 5 deletions cypress/e2e/cardFeatures.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,8 @@ describe('Card', function() {
cy.get('.reference-picker-modal--content .reference-picker').should('be.visible')
cy.get('.reference-picker-modal--content .reference-picker').contains('Create a new card')
cy.get('.reference-picker-modal--content .reference-picker .card-title').should('be.visible').click().type(newCardTitle)
cy.get('.reference-picker-modal--content .reference-picker .multiselect-board').should('be.visible').click()
cy.get('.reference-picker-modal--content .reference-picker .multiselect-board li:contains("' + boardData.title + '")').should('be.visible').click()
cy.wait('@getBoard', { timeout: 7000 })
cy.get('.reference-picker-modal--content .reference-picker .multiselect-list').should('be.visible').click()
cy.get('.reference-picker-modal--content .reference-picker .multiselect-list li').eq(0).should('be.visible').click()
cy.get('.reference-picker-modal--content .reference-picker .multiselect-board').should('be.visible').contains(boardData.title)
cy.get('.reference-picker-modal--content .reference-picker .multiselect-list').should('be.visible').contains(boardData.stacks[0].title)
cy.get('.reference-picker-modal--content .reference-picker button.button-vue--vue-primary').should('be.visible').click()
cy.wait('@save', { timeout: 7000 })
cy.get('.modal__card .ProseMirror').contains('/index.php/apps/deck/card/').should('be.visible')
Expand Down
2 changes: 2 additions & 0 deletions src/components/card/CardSidebarTabDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ export default {
}
this.copiedCard = JSON.parse(JSON.stringify(this.card))
localStorage.setItem('deck.selectedBoardId', this.currentBoard.id)
localStorage.setItem('deck.selectedStackId', this.card.stackId)
},
async updateCardDue(val) {
Expand Down
32 changes: 30 additions & 2 deletions src/views/CreateNewCardCustomPicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
:disabled="loading"
label="title"
class="selector-wrapper--selector multiselect-board"
@select="fetchBoardDetails">
@select="onSelectBoard">
<template slot="singleLabel" slot-scope="props">
<span>
<span :style="{ 'backgroundColor': '#' + props.option.color }" class="board-bullet" />
Expand All @@ -47,7 +47,8 @@
:max-height="100"
:disabled="loading || !selectedBoard"
class="selector-wrapper--selector multiselect-list"
label="title" />
label="title"
@select="onSelectStack" />
</div>
</div>

Expand Down Expand Up @@ -220,6 +221,7 @@ export default {
return board?.permissions?.PERMISSION_EDIT && !board?.archived && !board?.deletedAt
})
this.loading = false
this.preSelectBoard()
})
},
async fetchBoardDetails(board) {
Expand All @@ -230,6 +232,7 @@ export default {
this.labels = response.data.labels
this.boardUsers = response.data.users
this.boardAcl = response.data.acl
this.preSelectStack()
} catch (err) {
return err
}
Expand Down Expand Up @@ -295,6 +298,31 @@ export default {
openNewCard() {
window.location = generateUrl('/apps/deck') + `#/board/${this.selectedBoard.id}/card/${this.newCard.id}`
},
preSelectBoard() {
const selectedBoardId = Number(localStorage.getItem('deck.selectedBoardId'))
const preSelectedBoard = this.boards.find(item => item.id === selectedBoardId)
if (preSelectedBoard) {
this.selectedBoard = preSelectedBoard
this.onSelectBoard(preSelectedBoard)
}
},
preSelectStack() {
const selectedStackId = Number(localStorage.getItem('deck.selectedStackId'))
const preSelectedStack = this.stacksFromBoard.find(item => item.id === selectedStackId)
if (preSelectedStack) {
this.selectedStack = preSelectedStack
}
},
async onSelectBoard(board) {
localStorage.setItem('deck.selectedBoardId', board.id)
this.selectedStack = ''
await this.fetchBoardDetails(board)
},
onSelectStack(stack) {
localStorage.setItem('deck.selectedStackId', stack.id)
},
},
}
Expand Down

0 comments on commit e03e57e

Please sign in to comment.