Sort parent objects as well in Schema Diff tool.

This commit is contained in:
Akshay Joshi 2023-08-14 17:14:34 +05:30
parent a9799f25a2
commit 2c81b33925

View File

@ -369,8 +369,21 @@ function checkRowExpanedStatus(rows, record) {
function prepareRows(rows, gridData, filterParams) {
let newRows = [];
let adedIds = [];
gridData.map((record) => {
let addedIds = [];
// Filter data objects with label 'Database Objects'.
let newGridData = gridData.filter(function (obj) {
return obj.label === gettext('Database Objects');
});
// Filter data objects except 'Database Objects'
let otherObjects = gridData.filter(function (obj) {
return obj.label !== gettext('Database Objects');
});
// Sort other objects
otherObjects.sort((a, b) => (a.label > b.label) ? 1 : -1);
// Merge 'Database Objects' and other data
newGridData = newGridData.concat(otherObjects);
newGridData.map((record) => {
let children = getChildrenRows(record);
// Sort the children using label
children.sort((a, b) => (a.label > b.label) ? 1 : -1);
@ -384,18 +397,18 @@ function prepareRows(rows, gridData, filterParams) {
subChildren.map((subChild) => {
if (filterParams.includes(subChild.status)) {
tempChildList.push(subChild);
adedIds.push(subChild.id);
addedIds.push(subChild.id);
}
});
if (!adedIds.includes(record.id) && tempChildList.length > 0) {
adedIds.push(record.id);
if (!addedIds.includes(record.id) && tempChildList.length > 0) {
addedIds.push(record.id);
record.isExpanded = true;
newRows.push(record);
}
if (!adedIds.includes(child.id) && tempChildList.length > 0) {
adedIds.push(child.id);
if (!addedIds.includes(child.id) && tempChildList.length > 0) {
addedIds.push(child.id);
child.isExpanded = checkRowExpanedStatus(rows, child);
newRows.push(child);
newRows = checkAndAddChild(child, newRows, tempChildList);