Merge pull request #24575 from akhilnarang/sort-grid_row-options

fix(grid_row): sort options based on selected data first, so as to maintain order
This commit is contained in:
Akhil Narang 2024-01-29 13:47:04 +05:30 committed by GitHub
commit 9b2e0446c5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -461,6 +461,7 @@ export default class GridRow {
fieldname: "fields",
options: docfields,
columns: 2,
sort_options: false,
},
],
});
@ -495,12 +496,31 @@ export default class GridRow {
const show_field = (f) => always_allow.includes(f) || !blocked_fields.includes(f);
// First, add selected fields
selected_fields.forEach((selectedField) => {
const selectedColumn = this.docfields.find(
(column) => column.fieldname === selectedField
);
if (selectedColumn && !selectedColumn.hidden && show_field(selectedColumn.fieldtype)) {
fields.push({
label: selectedColumn.label,
value: selectedColumn.fieldname,
checked: true,
});
}
});
// Then, add the rest of the fields
this.docfields.forEach((column) => {
if (!column.hidden && show_field(column.fieldtype)) {
if (
!selected_fields.includes(column.fieldname) &&
!column.hidden &&
show_field(column.fieldtype)
) {
fields.push({
label: column.label,
value: column.fieldname,
checked: selected_fields ? selected_fields.includes(column.fieldname) : false,
checked: false,
});
}
});