Skip to content

Commit

Permalink
fix: Sort table when is lookup and insensitive case.
Browse files Browse the repository at this point in the history
  • Loading branch information
EdwinBetanc0urt committed Jun 24, 2024
1 parent f2f94de commit 4f2e0d0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/components/ADempiere/DataTable/Browser/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
:column-key="fieldAttributes.columnName"
:prop="fieldAttributes.columnName"
sortable
:sort-by="fieldAttributes.sortByProperty"
:min-width="widthColumn(fieldAttributes)"
:fixed="fieldAttributes.isFixedTableColumn"
>
Expand Down
18 changes: 17 additions & 1 deletion src/store/modules/ADempiere/browserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ import {
import {
ROW_ATTRIBUTES, ROW_KEY_ATTRIBUTES, ROWS_OF_RECORDS_BY_PAGE
} from '@/utils/ADempiere/tableUtils'
import { DISPLAY_COLUMN_PREFIX } from '@/utils/ADempiere/dictionaryUtils'
import {
DISPLAY_COLUMN_PREFIX, SORT_COLUMN_PREFIX
} from '@/utils/ADempiere/dictionaryUtils'

// Utils and Helper Methods
import { isEmptyValue } from '@/utils/ADempiere/valueUtils'
Expand Down Expand Up @@ -277,6 +279,20 @@ const browserControl = {
.then(browserSearchResponse => {
const recordsList = browserSearchResponse.records.map((record, rowIndex) => {
const { values } = record

// TODO: Test peformance.
Object.keys(values).forEach(key => {
const currentValue = values[key]
if (key.startsWith(DISPLAY_COLUMN_PREFIX)) {
// Add column with sort values to correct sorting
let sortValue = ''
if (!isEmptyValue(currentValue)) {
sortValue = currentValue.toLowerCase()
}
values[SORT_COLUMN_PREFIX + key] = sortValue
}
})

return {
...values,
// datatables app attributes
Expand Down
7 changes: 6 additions & 1 deletion src/utils/ADempiere/dictionaryUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ import {
*/
export const DISPLAY_COLUMN_PREFIX = `DisplayColumn_`

/**
* Sort Column Prefix on Column Name: "SortColumn_ColumnName"
*/
export const SORT_COLUMN_PREFIX = `SortColumn_`

/**
* Identifier Column Suffix on Column Name: "_ID"
*/
Expand Down Expand Up @@ -243,7 +248,7 @@ export function generateField({
isSupported: componentReference.isSupported,
size: componentReference.size || DEFAULT_SIZE,
displayColumnName: DISPLAY_COLUMN_PREFIX + columnName, // key to display column
sortByProperty: !isSupportLookup(fieldToGenerate.display_type) ? columnName : DISPLAY_COLUMN_PREFIX + columnName,
sortByProperty: !isSupportLookup(fieldToGenerate.display_type) ? columnName : SORT_COLUMN_PREFIX + DISPLAY_COLUMN_PREFIX + columnName,
// value attributes
parsedDefaultValue,
parsedDefaultValueTo,
Expand Down

0 comments on commit 4f2e0d0

Please sign in to comment.