Skip to content

Commit

Permalink
undo for non-string types
Browse files Browse the repository at this point in the history
Signed-off-by: Kiril Isakov <kirix.isakov@gmail.com>
  • Loading branch information
kirisakow committed Jun 15, 2024
1 parent 0c91203 commit b255c47
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class NumberColumn extends AbstractNumberColumn {
if (!valueA && !valueB) {
return super.getNextSortsResult(nextSorts, rowA, rowB)
}
return valueA.localeCompare(valueB, undefined, { numeric: true }) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
return ((valueA < valueB) ? -1 : (valueA > valueB) ? 1 : 0) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export default class NumberProgressColumn extends AbstractNumberColumn {
const factor = mode === 'DESC' ? -1 : 1
return (rowA, rowB) => {
const tmpA = rowA.data.find(item => item.columnId === this.id)?.value || null
const valueA = parseInt(tmpA)
const tmpB = rowB.data.find(item => item.columnId === this.id)?.value || null
return tmpA.localeCompare(tmpB, undefined, { numeric: true }) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
const valueB = parseInt(tmpB)
return ((valueA < valueB) ? -1 : (valueA > valueB) ? 1 : 0) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ export default class NumberStarsColumn extends AbstractNumberColumn {
const factor = mode === 'DESC' ? 1 : -1
return (rowA, rowB) => {
const tmpA = rowA.data.find(item => item.columnId === this.id)?.value
const valueA = Number.isNaN(parseInt(tmpA)) ? -1 : parseInt(tmpA)
const tmpB = rowB.data.find(item => item.columnId === this.id)?.value
return tmpA.localeCompare(tmpB, undefined, { numeric: true }) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
const valueB = Number.isNaN(parseInt(tmpB)) ? -1 : parseInt(tmpB)
return ((valueA < valueB) ? -1 : (valueA > valueB) ? 1 : 0) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class SelectionColumn extends AbstractSelectionColumn {
const selectionIdB = parseInt(rowB.data.find(item => item.columnId === this.id)?.value ?? null)
const vB = Number.isNaN(selectionIdB) ? '' : this.selectionOptions.find(item => item.id === selectionIdB)?.label
const valueB = this.removeEmoji(vB).trim()
return valueA.localeCompare(valueB, undefined) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
return ((valueA < valueB) ? -1 : (valueA > valueB) ? 1 : 0) * factor || super.getNextSortsResult(nextSorts, rowA, rowB)
}
}

Expand Down

0 comments on commit b255c47

Please sign in to comment.