Skip to content

Commit

Permalink
[ALS-7889] Remove duplication of Sample Ids (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesPeck authored Dec 5, 2024
1 parent ea89e88 commit 7de0a6f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/components/datatable/accessories/Rows.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { DataHandler as RemoteHander } from '@vincjo/datatables/remote';
export let handler: DataHandler | RemoteHander;
export let options: number[] = [5, 10, 20, 50];
const rowsPerPage = handler.getRowsPerPage();
$: rowsPerPage = handler.getRowsPerPage();
const setRowsPerPage = () => {
handler.setPage(1);
if (handler instanceof RemoteHander) {
Expand Down
14 changes: 9 additions & 5 deletions src/lib/components/explorer/export/ExportStepper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,19 @@
(e) =>
({
ref: e,
variableId: e.id,
variableName: e.display,
variableId: e?.searchResult?.conceptPath,
variableName: e?.display,
description: e?.searchResult?.description,
type: e?.searchResult.type,
type: e?.searchResult?.type,
selected: true,
}) as ExportRowInterface,
);
rows = [...rows, ...newRows];
//Remove duplicates
rows = Array.from(
[...rows, ...newRows]
.reduce((map, row) => map.set(row.variableId, row), new Map())
.values(),
);
lastExports = newRows;
} catch (error) {
console.error('Error in toggleSampleIds', error);
Expand Down
11 changes: 8 additions & 3 deletions src/lib/stores/Export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const exports: Writable<ExportInterface[]> = writable([]);

function addExport(exportedField: ExportInterface) {
const currentExports = get(exports);
if (currentExports.some((e: ExportInterface) => e.id === exportedField.id)) {
if (currentExports.some((e: ExportInterface) => e.conceptPath === exportedField.conceptPath)) {
return;
}
exports.set([...currentExports, exportedField]);
Expand All @@ -16,7 +16,8 @@ function addExport(exportedField: ExportInterface) {
function addExports(exportedFields: ExportInterface[]) {
const currentExports = get(exports);
const newExports = exportedFields.filter(
(e: ExportInterface) => !currentExports.some((ce: ExportInterface) => ce.id === e.id),
(e: ExportInterface) =>
!currentExports.some((ce: ExportInterface) => ce.conceptPath === e.conceptPath),
);
exports.set([...currentExports, ...newExports]);
}
Expand All @@ -32,7 +33,11 @@ function removeExport(uuid: string) {

function removeExports(exportsToRemove: ExportInterface[]) {
const currentExports = get(exports);
exports.set(currentExports.filter((e: ExportInterface) => !exportsToRemove.includes(e)));
exports.set(
currentExports.filter(
(e: ExportInterface) => !exportsToRemove.some((re) => re.conceptPath === e.conceptPath),
),
);
}

export function clearExports() {
Expand Down

0 comments on commit 7de0a6f

Please sign in to comment.