Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fix difference sorting in compare page #233

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions frontend/src/lib/components/instance-views/ComparisonView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -85,29 +85,29 @@
}
});

// trigger this function when clicking column header to sort
function updateSort(model: string | undefined) {
if (model === undefined) return;

// when clicking different model columns, reset compareSort
sortModel = model;

// deep copy to not mutate object
let compareColumnObj = JSON.parse(
JSON.stringify(
$columns.filter(
(col) => col.name == $comparisonColumn?.name && col.model == $comparisonModel
)[0]
)
let sortColumnObjects = $columns.filter(
(col) => col.name == $comparisonColumn?.name && col.model == model
);

// if no column found for model, model is "", find col for any model.
if (sortColumnObjects.length === 0) {
sortColumnObjects = $columns.filter((col) => col.name == $comparisonColumn?.name);
}

// deep copy to not mutate object
let compareColumnObj = JSON.parse(JSON.stringify(sortColumnObjects[0]));
// set ID to blank, telling backend to sort by difference.
if (sortModel === '') {
compareColumnObj.id = '';
}

let compareSortString = JSON.stringify($compareSort[0]);
let newHeaderString = JSON.stringify(compareColumnObj);

if (compareSortString !== newHeaderString) {
compareSort.set([compareColumnObj, true]);
} else if (compareSortString === newHeaderString && $compareSort[1]) {
Expand Down
Loading