Compare commits

..

2 commits

Author SHA1 Message Date
a4eebb944f
fix: avoid global state, use context for savedFilters
All checks were successful
Visitenbuch CI / test (push) Successful in 2m38s
Visitenbuch CI / release (push) Has been skipped
2024-05-16 17:29:22 +02:00
d5e9a9469f
fix: use btn-id class for all tables 2024-05-14 22:51:20 +02:00
8 changed files with 21 additions and 7 deletions

View file

@ -50,6 +50,7 @@ jobs:
id: e2etest id: e2etest
run: | run: |
pnpm run build -l silent pnpm run build -l silent
npx playwright install chromium
pnpm run test:e2e pnpm run test:e2e
- name: 💢 Upload E2E report - name: 💢 Upload E2E report
if: ${{ failure() && steps.e2etest.conclusion == 'failure' }} if: ${{ failure() && steps.e2etest.conclusion == 'failure' }}

View file

@ -8,12 +8,14 @@
import { toastError, toastInfo } from "$lib/shared/util/toast"; import { toastError, toastInfo } from "$lib/shared/util/toast";
import Icon from "$lib/components/ui/Icon.svelte"; import Icon from "$lib/components/ui/Icon.svelte";
import { savedFilters } from "$lib/stores"; import { getSavedFilters } from "$lib/stores";
import Chip from "./SavedFilterChip.svelte"; import Chip from "./SavedFilterChip.svelte";
export let view: string; export let view: string;
const savedFilters = getSavedFilters();
$: filters = $savedFilters[view] ?? []; $: filters = $savedFilters[view] ?? [];
function getQuery(): string { function getQuery(): string {

View file

@ -37,7 +37,7 @@
> >
<td <td
><a ><a
class="btn btn-xs btn-primary" class="btn btn-xs btn-primary btn-id"
aria-label="Eintrag anzeigen" aria-label="Eintrag anzeigen"
href="/patient/{patient.id}">{patient.id}</a href="/patient/{patient.id}">{patient.id}</a
></td ></td

View file

@ -1,3 +1,4 @@
import { getContext } from "svelte";
import { derived, writable, type Writable } from "svelte/store"; import { derived, writable, type Writable } from "svelte/store";
import type { SavedFilter } from "$lib/shared/model"; import type { SavedFilter } from "$lib/shared/model";
@ -6,4 +7,6 @@ import type { SavedFilter } from "$lib/shared/model";
export const screenWidth = writable(0); export const screenWidth = writable(0);
export const screenWidthSmall = derived(screenWidth, ($mainWidth) => $mainWidth < 500); export const screenWidthSmall = derived(screenWidth, ($mainWidth) => $mainWidth < 500);
export const savedFilters: Writable<Record<string, SavedFilter[]>> = writable({}); // Context key: "savedFilters"
export type SavedFilters = Writable<Record<string, SavedFilter[]>>;
export const getSavedFilters: () => SavedFilters = () => getContext("savedFilters");

View file

@ -3,16 +3,22 @@
import type { LayoutData } from "./$types"; import type { LayoutData } from "./$types";
import { mdiAccount, mdiHome } from "@mdi/js"; import { mdiAccount, mdiHome } from "@mdi/js";
import { setContext } from "svelte";
import { writable } from "svelte/store";
import { defaultFilterUrl, defaultVisitUrl } from "$lib/shared/util"; import { defaultFilterUrl, defaultVisitUrl } from "$lib/shared/util";
import Icon from "$lib/components/ui/Icon.svelte"; import Icon from "$lib/components/ui/Icon.svelte";
import NavLink from "$lib/components/ui/NavLink.svelte"; import NavLink from "$lib/components/ui/NavLink.svelte";
import { savedFilters } from "$lib/stores"; import type { SavedFilters } from "$lib/stores";
export let data: LayoutData; export let data: LayoutData;
const savedFilters: SavedFilters = writable();
$: savedFilters.set(data.savedFilters); $: savedFilters.set(data.savedFilters);
setContext("savedFilters", savedFilters);
</script> </script>
<div class="navbar-outer"> <div class="navbar-outer">

View file

@ -4,9 +4,11 @@
import { defaultFilterUrl } from "$lib/shared/util"; import { defaultFilterUrl } from "$lib/shared/util";
import { savedFilters } from "$lib/stores"; import { getSavedFilters } from "$lib/stores";
export let data: PageData; export let data: PageData;
const savedFilters = getSavedFilters();
</script> </script>
<svelte:head> <svelte:head>

View file

@ -27,7 +27,7 @@
<tbody> <tbody>
{#each data.rooms as room (room.id)} {#each data.rooms as room (room.id)}
<tr> <tr>
<td><a class="btn btn-sm" href="/room/{room.id}">{room.name}</a></td> <td><a class="btn btn-sm btn-id" href="/room/{room.id}">{room.name}</a></td>
<td>{room.station.name}</td> <td>{room.station.name}</td>
</tr> </tr>
{/each} {/each}

View file

@ -27,7 +27,7 @@
{#each data.stations as station (station.id)} {#each data.stations as station (station.id)}
<tr> <tr>
<td> <td>
<a class="btn btn-sm" href="/station/{station.id}">{station.name}</a> <a class="btn btn-sm btn-id" href="/station/{station.id}">{station.name}</a>
</td> </td>
</tr> </tr>
{/each} {/each}