Skip to content

Commit

Permalink
fix: changed to datarequestsstore
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickskowronekdkfz committed Oct 30, 2024
1 parent b48490c commit 53f174d
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 447 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import {
getHumanReadableQuery,
buildHumanReadableRecursively,
} from "../../stores/negotiate";
} from "../../stores/datarequests";
import { returnNestedValues } from "../../helpers/ast-transformer";
import type { AstElement } from "../../types/ast";
import type { QueryItem } from "../../types/queryData";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@
/>

<script lang="ts">
import { negotiate, negotiateStore } from "../../stores/negotiate";
import { datarequestsStore } from "../../stores/datarequests";
import { negotiate } from "../../services/bbmriNegotiate.ts";
export let title: string = "Negotiate with biobanks";
</script>

<button
part={`lens-negotiate-button lens-negotiate-button-${
$negotiateStore.length === 0 ? "disabled" : "active"
$datarequestsStore.length === 0 ? "disabled" : "active"
}`}
on:click={() => negotiate($negotiateStore)}
disabled={$negotiateStore.length === 0}
on:click={() => negotiate($datarequestsStore)}
disabled={$datarequestsStore.length === 0}
>
<div part="lens-negotiate-button-title">
{title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<script lang="ts">
import { uiSiteMappingsStore } from "../../stores/mappings";
import { negotiateStore } from "../../stores/negotiate";
import { datarequestsStore } from "../../stores/datarequests.ts";
import {
getSitePopulationForCode,
getSitePopulationForStratumCode,
Expand Down Expand Up @@ -134,21 +134,21 @@
);
/**
* watches the negotiateStore for changes to check or uncheck the checkbox
* watches the datarequestsStore for changes to check or uncheck the checkbox
*/
let allChecked: boolean = false;
$: allChecked =
$negotiateStore.length === tableRowData.length &&
$datarequestsStore.length === tableRowData.length &&
tableRowData.length !== 0;
/**
* checks or unchecks all biobanks
*/
const checkAllBiobanks = (): void => {
if (allChecked) {
$negotiateStore = [];
$datarequestsStore = [];
} else {
$negotiateStore = tableRowData.map(
$datarequestsStore = tableRowData.map(
(tableRow: (string | number)[]) => tableRow[0] as string,
);
}
Expand Down
8 changes: 4 additions & 4 deletions packages/lib/src/components/results/TableItemComponent.svelte
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<script lang="ts">
import { negotiateStore } from "../../stores/negotiate";
import { datarequestsStore } from "../../stores/datarequests";
export let tableRow: (string | number)[];
let checked: boolean = false;
$: checked = $negotiateStore.includes(tableRow[0] as string);
$: checked = $datarequestsStore.includes(tableRow[0] as string);
/**
* adds and removes tableRows from the negotiateStore whenever the checkbox is checked or unchecked
*/
const updateStoreOnCheck = (): void => {
if (!checked) {
negotiateStore.update((store: string[]) => {
datarequestsStore.update((store: string[]) => {
return [...store, tableRow[0] as string];
});
}
if (checked) {
negotiateStore.update((store: string[]) => {
datarequestsStore.update((store: string[]) => {
return store.filter((site: string) => site !== tableRow[0]);
});
}
Expand Down
Loading

0 comments on commit 53f174d

Please sign in to comment.