Allow manual ordering of untitled cards

This commit is contained in:
Chen-I Lim 2020-10-28 11:28:23 -07:00
parent 8794145802
commit 3ec91d3208

View file

@ -234,7 +234,19 @@ class MutableBoardTree implements BoardTree {
const indexB = activeView.cardOrder.indexOf(cardB.id)
if (indexA < 0 && indexB < 0) {
// If both cards' order is not defined, use the create date
// If both cards' order is not defined, first use the title
const aValue = cardA.title || ''
const bValue = cardB.title || ''
// Always put untitled cards at the bottom
if (aValue && !bValue) {
return -1
}
if (bValue && !aValue) {
return 1
}
// If both cards are untitled, use the create date
return cardA.createAt - cardB.createAt
} else if (indexA < 0 && indexB >= 0) {
// If cardA's order is not defined, put it at the end
@ -254,20 +266,7 @@ class MutableBoardTree implements BoardTree {
if (sortOptions.length < 1) {
Utils.log('Default sort')
sortedCards = cards.sort((a, b) => {
const aValue = a.title || ''
const bValue = b.title || ''
// Always put empty values at the bottom
if (aValue && !bValue) {
return -1
}
if (bValue && !aValue) {
return 1
}
return this.defaultOrder(a, b)
})
sortedCards = cards.sort((a, b) => this.defaultOrder(a, b))
} else {
sortOptions.forEach((sortOption) => {
if (sortOption.propertyId === '__name') {