diff --git a/src/lib/components/datatable/accessories/Rows.svelte b/src/lib/components/datatable/accessories/Rows.svelte index e13de9be..d53525cd 100644 --- a/src/lib/components/datatable/accessories/Rows.svelte +++ b/src/lib/components/datatable/accessories/Rows.svelte @@ -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) { diff --git a/src/lib/components/explorer/export/ExportStepper.svelte b/src/lib/components/explorer/export/ExportStepper.svelte index 6b9911bf..611cf468 100644 --- a/src/lib/components/explorer/export/ExportStepper.svelte +++ b/src/lib/components/explorer/export/ExportStepper.svelte @@ -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); diff --git a/src/lib/stores/Export.ts b/src/lib/stores/Export.ts index 61eb2c8a..85aac877 100644 --- a/src/lib/stores/Export.ts +++ b/src/lib/stores/Export.ts @@ -6,7 +6,7 @@ const exports: Writable = 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]); @@ -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]); } @@ -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() {