diff --git a/packages/demo/public/options.json b/packages/demo/public/options.json index 211f37b..e54f859 100644 --- a/packages/demo/public/options.json +++ b/packages/demo/public/options.json @@ -5,6 +5,24 @@ "text": "Add all" } }, + "siteMappings": { + "berlin": "Berlin", + "berlin-test": "Berlin", + "bonn": "Bonn", + "dresden": "Dresden", + "essen": "Essen", + "frankfurt": "Frankfurt", + "freiburg": "Freiburg", + "hannover": "Hannover", + "mainz": "Mainz", + "muenchen-lmu": "München(LMU)", + "muenchen-tum": "München(TUM)", + "ulm": "Ulm", + "wuerzburg": "Würzburg", + "mannheim": "Mannheim", + "dktk-test": "DKTK-Test", + "hamburg": "Hamburg" + }, "chartOptions": { "patients": { "legendMapping": { @@ -171,8 +189,7 @@ { "stratifierCode": "Histologies", "stratumCode": "1" - }, - {} + } ] } ], diff --git a/packages/lib/src/components/Options.wc.svelte b/packages/lib/src/components/Options.wc.svelte index d0c44c5..1a69387 100644 --- a/packages/lib/src/components/Options.wc.svelte +++ b/packages/lib/src/components/Options.wc.svelte @@ -20,11 +20,16 @@ import type { MeasureStore } from "../types/backend"; import type { Criteria } from "../types/treeData"; import type { LensOptions } from "../types/options"; + import { uiSiteMappingsStore } from "../stores/mappings"; export let options: LensOptions = {}; export let catalogueData: Criteria[] = []; export let measures: MeasureStore = {} as MeasureStore; + /** + * updates the icon store with the options passed in + * @param options the Lens options + */ const updateIconStore = (options: LensOptions): void => { iconStore.update((store) => { if (typeof options === "object" && "iconOptions" in options) { @@ -61,6 +66,22 @@ }); }; + /** + * watches the backendConfig for changes to populate the uiSiteMappingsStore with a map + * web components' props are json, meaning that Maps are not supported + * therefore it's a 2d array of strings which is converted to a map + */ + $: uiSiteMappingsStore.update((mappings) => { + if (!options?.siteMappings) return mappings; + console.log("options", options); + console.log(Object.entries(options?.siteMappings)); + Object.entries(options?.siteMappings)?.forEach((site) => { + mappings.set(site[0], site[1]); + }); + + return mappings; + }); + $: $lensOptions = options; $: updateIconStore(options); $: $catalogue = catalogueData; diff --git a/packages/lib/src/components/buttons/SearchButtonComponenet.wc.svelte b/packages/lib/src/components/buttons/SearchButtonComponenet.wc.svelte index c8b85d8..c84ddf1 100644 --- a/packages/lib/src/components/buttons/SearchButtonComponenet.wc.svelte +++ b/packages/lib/src/components/buttons/SearchButtonComponenet.wc.svelte @@ -17,10 +17,7 @@ import { buildLibrary, buildMeasure } from "../../helpers/cql-measure"; import { Spot } from "../../classes/spot"; import { Blaze } from "../../classes/blaze"; - import { - catalogueKeyToResponseKeyMap, - uiSiteMappingsStore, - } from "../../stores/mappings"; + import { catalogueKeyToResponseKeyMap } from "../../stores/mappings"; import { responseStore, updateResponseStore } from "../../stores/response"; import { lensOptions } from "../../stores/options"; import type { @@ -42,20 +39,6 @@ let controller: AbortController = new AbortController(); - /** - * watches the backendConfig for changes to populate the uiSiteMappingsStore with a map - * web components' props are json, meaning that Maps are not supported - * therefore it's a 2d array of strings which is converted to a map - */ - $: uiSiteMappingsStore.update((mappings) => { - options?.spots.forEach((spot) => { - spot.uiSiteMap.forEach((site) => { - mappings.set(site[0], site[1]); - }); - }); - return mappings; - }); - $: catalogueKeyToResponseKeyMap.update((mappings) => { options?.spots?.forEach((spot) => { spot.catalogueKeyToResponseKeyMap.forEach((mapping) => { diff --git a/packages/lib/src/components/results/ResultTableComponent.wc.svelte b/packages/lib/src/components/results/ResultTableComponent.wc.svelte index e51f5f2..c32a454 100644 --- a/packages/lib/src/components/results/ResultTableComponent.wc.svelte +++ b/packages/lib/src/components/results/ResultTableComponent.wc.svelte @@ -24,10 +24,7 @@ let claimedText: string; $: claimedText = - (($lensOptions?.tableOptions && - $lensOptions.tableOptions?.claimedText && - $lensOptions.tableOptions.claimedText) as string) || - "Processing..."; + ($lensOptions?.tableOptions?.claimedText as string) || "Processing..."; /** * data-types for the table