Skip to content

Commit

Permalink
Merge pull request #39 from mad-lab-fau/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
roschro-fau authored May 30, 2024
2 parents 884c7fc + 3a2d177 commit 0c41c03
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
15 changes: 8 additions & 7 deletions src/lib/components/preparation/QrCodeForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,12 @@
<hr class="my-4">

{#if !uniformSalivaDistances}
<label class="label md:w-1/3">
<label class="label">
<span>Number of samples that have to be taken at a fixed time</span>
<input
class="input md:w-1/4"
class="input"
id="samplesAbsTime"
style="width: 8rem;"
type="number"
bind:value={numSampleAlarmTimes}
min="0"
Expand All @@ -185,9 +186,9 @@

<h4>Times for biomarker samples</h4>
{#if uniformSalivaDistances}
<div class="h-full max-h-72 py-2 md:w-1/4 p overflow-y-auto overflow-x-hidden flex flex-col flex-grow px-4">
<div class="h-full max-h-72 py-2 p overflow-y-auto overflow-x-hidden flex flex-col flex-grow px-4">
<label class="label pb-1" for="distances"><span>Time between all samples</span></label>
<div class="input-group input-group-divider grid-cols-[auto_1fr_auto]">
<div class="input-group input-group-divider grid-cols-[auto_1fr_auto]" style="width: 15rem;">
<input
class="input col-span-2"
id="distances"
Expand All @@ -201,7 +202,7 @@
</div>
</div>
{:else}
<div class="h-full md:w-1/3 py-2 overflow-y-auto overflow-x-hidden flex flex-col flex-grow px-4">
<div class="h-full py-2 overflow-y-auto overflow-x-hidden flex flex-col flex-grow px-4">
{#each Array($studyProps.numSamples - numSampleAlarmTimes) as _, i}
<label class="label pt-2 pb-1" for="distance{i}">
{#if i === 0}
Expand All @@ -210,7 +211,7 @@
<span>Time span between sample {i + Number(!$studyProps.startSampleFromZero) - 1} and sample {i + Number(!$studyProps.startSampleFromZero)}</span>
{/if}
</label>
<div class="input-group input-group-divider grid-cols-[auto_2fr_auto]">
<div class="input-group input-group-divider grid-cols-[auto_2fr_auto]" style="width: 15rem;">
<input
class="input col-span-2"
id="distance{i}"
Expand All @@ -227,7 +228,7 @@
Alarm time for sample {$studyProps.numSamples - numSampleAlarmTimes + i + Number(!$studyProps.startSampleFromZero)}
</span>
</label>
<div class="input-group input-group-divider grid-cols-[auto_2fr_auto]">
<div class="input-group input-group-divider grid-cols-[auto_2fr_auto]" style="width: 15rem;">
<input
class="input col-span-2"
id="time{i}"
Expand Down
15 changes: 12 additions & 3 deletions src/lib/stores/configStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ const defaultBarcodeProps: BarcodeProperties = { generateBarcodes: true, hasBarc
const defaultQrCodeProps: QrCodeProperties = { generateQrCodes: true, numSampleAlarmTimes: 0, salivaDistances: [], salivaAlarmTimes: [], contact: '', includeParticipantId: false, checkDuplicates: false, enableManualScan: false, useLetterFormat: false, numColumns: 3, numRows: 6 }

// Create the stores
export const studyProps = storedStudyProps ? writable<StudyProperties>(JSON.parse(storedStudyProps)) : writable<StudyProperties>(defaultStudyProps);
export const barcodeProps = storedBarcodeProps ? writable<BarcodeProperties>(JSON.parse(storedBarcodeProps)) : writable<BarcodeProperties>(defaultBarcodeProps);
export const qrCodeProps = storedQrCodeProps ? writable<QrCodeProperties>(JSON.parse(storedQrCodeProps)) : writable<QrCodeProperties>(defaultQrCodeProps);
export const studyProps = storedStudyProps ? writable<StudyProperties>(addMissingProperties(JSON.parse(storedStudyProps), defaultStudyProps)) : writable<StudyProperties>(defaultStudyProps);
export const barcodeProps = storedBarcodeProps ? writable<BarcodeProperties>(addMissingProperties(JSON.parse(storedBarcodeProps), defaultBarcodeProps)) : writable<BarcodeProperties>(defaultBarcodeProps);
export const qrCodeProps = storedQrCodeProps ? writable<QrCodeProperties>(addMissingProperties(JSON.parse(storedQrCodeProps), defaultQrCodeProps)) : writable<QrCodeProperties>(defaultQrCodeProps);

export const studyPropsValid = writable(Boolean(storedStudyProps));
export const barcodePropsValid = writable(Boolean(storedBarcodeProps));
Expand All @@ -89,3 +89,12 @@ if (browser) {
}
});
}

function addMissingProperties(storedValues, defaultValues) {
for (const key in defaultValues) {
if (!(key in storedValues) || storedValues[key] === undefined || storedValues[key] === null) {
storedValues[key] = defaultValues[key];
}
}
return storedValues;
}

0 comments on commit 0c41c03

Please sign in to comment.