Skip to content

Commit ad1d6f0

Browse files
committed
Allow switching between SHLinks
1 parent 28f20c4 commit ad1d6f0

File tree

2 files changed

+30
-24
lines changed

2 files changed

+30
-24
lines changed

src/HealthLink.svelte

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
<script lang="ts">
2-
import { getContext } from 'svelte';
32
import QRCode from 'qrcode';
3+
import { getContext } from 'svelte';
44
import { Button } from 'sveltestrap';
55
6-
6+
import type { Writable } from 'svelte/store';
77
import type { SHLAdminParams, SHLClient } from './managementClient';
8+
89
export let shl: SHLAdminParams;
10+
let shlStore: Writable<SHLAdminParams[]> = getContext('shlStore');
11+
let selectedShl: Writable<number | undefined> = getContext('selectedShl');
912
let shlClient: SHLClient = getContext('shlClient');
13+
1014
let copyNotice = '';
1115
1216
let href: Promise<string>;
@@ -30,6 +34,17 @@
3034
copyNotice = copyNoticePrev;
3135
}, 1000);
3236
}
37+
38+
async function deleteShl() {
39+
const newStore = [...$shlStore];
40+
newStore.splice($selectedShl!, 1);
41+
$shlStore = newStore;
42+
if ($shlStore.length == 0) {
43+
$selectedShl = undefined;
44+
} else {
45+
$selectedShl = $selectedShl! - 1;
46+
}
47+
}
3348
</script>
3449

3550
<div>
@@ -55,7 +70,7 @@
5570
{#if copyNotice}
5671
{copyNotice}
5772
{:else}
58-
Copy SMART Health Link
73+
Copy SMART Health Link to Clipboard
5974
{/if}
6075
</Button>
6176
</li>
@@ -65,11 +80,15 @@
6580
</li>
6681
{/await}
6782
{#await qrCode then dataUrl}
68-
<li class="logo"> <span class="show">Show SMART Health Link</span>
83+
<li class="logo">
84+
<span class="show">Present SMART Health Link as QR</span>
6985
<img class="qr" alt="QR Code for SHL" src={dataUrl} />
70-
<img class="logo" alt="SMART Logo" src={"./smart-logo.svg"} />
86+
<img class="logo" alt="SMART Logo" src={'./smart-logo.svg'} />
7187
</li>
7288
{/await}
89+
<li>
90+
<Button size="sm" on:click={deleteShl} color="danger">Delete SMART Health Link</Button>
91+
</li>
7392
</ul>
7493
</div>
7594

@@ -82,7 +101,7 @@
82101
top: 1.5em;
83102
}
84103
li.logo {
85-
position:relative;
104+
position: relative;
86105
width: 250px;
87106
height: 250px;
88107
margin-bottom: 2em;
@@ -92,7 +111,7 @@
92111
background: white;
93112
width: 100px;
94113
left: calc(50% - 1em - 50px);
95-
top: calc(50% + .7em);
114+
top: calc(50% + 0.7em);
96115
border: 2px solid white;
97116
box-sizing: border-box;
98117
}

src/routes/+layout.svelte

+4-17
Original file line numberDiff line numberDiff line change
@@ -53,28 +53,15 @@
5353
{#each $shlStore as shl, i}
5454
<DropdownItem
5555
on:click={() => {
56-
if ($selectedShl !== undefined) {
57-
if (i < $selectedShl) {
58-
$selectedShl--;
59-
}
60-
}
61-
const newStore = [...$shlStore];
62-
newStore.splice(i, 1);
63-
$shlStore = newStore;
64-
if ($shlStore.length == 0) {
65-
$selectedShl = undefined;
66-
}
67-
}}><Icon name="trash" /> {shl.label || `SHLink ${i + 1}`}</DropdownItem
56+
$selectedShl = i;
57+
}}
58+
><Icon name="eye" />
59+
{shl.label || `SHLink ${i + 1}`}</DropdownItem
6860
>
6961
{/each}
7062
{/if}
7163
</DropdownMenu>
7264
</ButtonDropdown>
73-
<!-- <NavLink
74-
on:click={() => {
75-
$reset++;
76-
}}>Reset SHL</NavLink
77-
> -->
7865
</Navbar>
7966
</Col>
8067
</Row>

0 commit comments

Comments
 (0)