Merge pull request #1670 from nextcloud/bugfix/noid/fix-card-order

Fix filtering and sorting of stacks that caused card reordering
This commit is contained in:
Julius Härtl
2020-04-09 16:34:05 +02:00
committed by GitHub
2 changed files with 13 additions and 7 deletions

View File

@@ -77,7 +77,7 @@
:drag-handle-selector="dragHandleSelector" :drag-handle-selector="dragHandleSelector"
@should-accept-drop="canEdit" @should-accept-drop="canEdit"
@drop="($event) => onDropCard(stack.id, $event)"> @drop="($event) => onDropCard(stack.id, $event)">
<Draggable v-for="card in cardsByStack(stack.id)" :key="card.id"> <Draggable v-for="card in cardsByStack" :key="card.id">
<CardItem v-if="card" :id="card.id" /> <CardItem v-if="card" :id="card.id" />
</Draggable> </Draggable>
</Container> </Container>
@@ -122,7 +122,7 @@ export default {
'canEdit', 'canEdit',
]), ]),
cardsByStack() { cardsByStack() {
return (id) => this.$store.getters.cardsByStack(id) return this.$store.getters.cardsByStack(this.stack.id)
}, },
dragHandleSelector() { dragHandleSelector() {
return this.canEdit ? null : '.no-drag' return this.canEdit ? null : '.no-drag'
@@ -150,7 +150,7 @@ export default {
}, },
payloadForCard(stackId) { payloadForCard(stackId) {
return index => { return index => {
return this.cardsByStack(stackId)[index] return this.cardsByStack[index]
} }
}, },
deleteStack(stack) { deleteStack(stack) {

View File

@@ -76,10 +76,16 @@ export default {
return true return true
}) })
.filter((card) => card.stackId === id && (getters.getSearchQuery === '' .filter((card) => card.stackId === id)
|| (card.title.toLowerCase().includes(getters.getSearchQuery.toLowerCase()) .filter((card) => {
|| card.description.toLowerCase().includes(getters.getSearchQuery.toLowerCase())) if (getters.getSearchQuery === '') {
.sort((a, b) => a.order - b.order))) return true
}
return card.title.toLowerCase().includes(getters.getSearchQuery.toLowerCase())
|| card.description.toLowerCase().includes(getters.getSearchQuery.toLowerCase())
})
.sort((a, b) => a.order - b.order)
}, },
cardById: state => (id) => { cardById: state => (id) => {
return state.cards.find((card) => card.id === id) return state.cards.find((card) => card.id === id)