Rahmen bleiben rot wenn man Feld ausgefüllt hat

This commit is contained in:
Moritz Utcke
2025-10-14 18:25:07 -04:00
parent 1ef0b5e15a
commit 882d2d2f60
5 changed files with 37 additions and 21 deletions

View File

@@ -52,6 +52,11 @@
if (!value && element.required) { if (!value && element.required) {
element.setCustomValidity("Eine Auswahl ist verpflichtend.") element.setCustomValidity("Eine Auswahl ist verpflichtend.")
element.dataset["isinvalid"] = "true" element.dataset["isinvalid"] = "true"
element.addEventListener("change", () => {
element.setCustomValidity("")
element.dataset["isinvalid"] = "false"
})
} else { } else {
element.setCustomValidity("") element.setCustomValidity("")
} }

View File

@@ -1,9 +1,8 @@
<script lang="ts"> <script lang="ts">
import HelpLabel from "#components/labels/HelpLabel.svelte"; import HelpLabel from "#components/labels/HelpLabel.svelte";
import Inputlabel from "#components/labels/InputLabel.svelte"; import Inputlabel from "#components/labels/InputLabel.svelte";
import PlzSuche from "#components/PlzSuche.svelte";
import ZipSearch from "#components/PlzSuche.svelte";
import { Enums } from "#lib/client/prisma.js"; import { Enums } from "#lib/client/prisma.js";
import { AufnahmeClient, ObjektClient } from "./types.js"; import { AufnahmeClient, ObjektClient } from "./types.js";
@@ -27,6 +26,8 @@
event.preventDefault(); event.preventDefault();
} }
} }
let ortInput: HTMLInputElement;
</script> </script>
<div <div
@@ -69,9 +70,12 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
<div class="input-noHelp"> <div class="input-noHelp">
<Inputlabel title="PLZ *"></Inputlabel> <Inputlabel title="PLZ *"></Inputlabel>
<ZipSearch <PlzSuche
bind:zip={objekt.plz} bind:zip={objekt.plz}
bind:city={objekt.ort} bind:city={objekt.ort}
onchange={(e) => {
ortInput.dispatchEvent(new Event('change'));
}}
name="plz" name="plz"
/> />
</div> </div>
@@ -85,6 +89,7 @@ xl:grid-cols-3 xl:gap-x-8 xl:gap-y-8
readonly={false} readonly={false}
required required
bind:value={objekt.ort} bind:value={objekt.ort}
bind:this={ortInput}
type="text" type="text"
/> />

View File

@@ -746,6 +746,7 @@
<div class="card-body"> <div class="card-body">
<div class="flex flex-col flex-wrap items-left gap-2"> <div class="flex flex-col flex-wrap items-left gap-2">
{#if aufnahme.bilder.length > 0}
<h3 class="font-semibold text-lg">Bilder</h3> <h3 class="font-semibold text-lg">Bilder</h3>
<div class="grid grid-cols-[1fr] md:grid-cols-[1fr,1fr,1fr] lg:grid-cols-[1fr,1fr,1fr] justify-start items-center gap-2"> <div class="grid grid-cols-[1fr] md:grid-cols-[1fr,1fr,1fr] lg:grid-cols-[1fr,1fr,1fr] justify-start items-center gap-2">
{#each aufnahme.bilder as bild, i (i)} {#each aufnahme.bilder as bild, i (i)}
@@ -753,6 +754,8 @@
{/each} {/each}
</div> </div>
<hr> <hr>
{/if}
{#if aufnahme.unterlagen.length > 0}
<h3 class="font-semibold text-lg">Unterlagen</h3> <h3 class="font-semibold text-lg">Unterlagen</h3>
<div class="text-sm"> <div class="text-sm">
{#if aufnahme.unterlagen.length > 0} {#if aufnahme.unterlagen.length > 0}
@@ -761,9 +764,11 @@
{/each} {/each}
{/if} {/if}
</div> </div>
{/if}
</div> </div>
<div class="dropdown dropdown-top items-end absolute bottom-4 right-4 z-50"> <!-- Benachrichtigungen -->
<!-- <div class="dropdown dropdown-top items-end absolute bottom-4 right-4 z-50">
<div class="indicator"> <div class="indicator">
{#if Object.keys($notifications).length > 0} {#if Object.keys($notifications).length > 0}
<span class="indicator-item badge badge-accent text-xs" <span class="indicator-item badge badge-accent text-xs"
@@ -782,7 +787,7 @@
> >
<NotificationProvider component={DashboardNotification} /> <NotificationProvider component={DashboardNotification} />
</ul> </ul>
</div> </div> -->
</div> </div>
</div> </div>

View File

@@ -5,7 +5,7 @@
export let readonly: boolean = false; export let readonly: boolean = false;
export let city: string | null | undefined; export let city: string | null | undefined;
export let zip: string | null = ""; export let zip: string | null = "";
export let onchange: (event: Event) => void;
let hideZipDropdown: boolean = true; let hideZipDropdown: boolean = true;
let zipCodes: inferOutput<API["postleitzahlen"]["GET"]> = []; let zipCodes: inferOutput<API["postleitzahlen"]["GET"]> = [];
@@ -58,6 +58,7 @@
{...$$restProps} {...$$restProps}
bind:value={zip} bind:value={zip}
on:input={fetchZipCodeInformation} on:input={fetchZipCodeInformation}
on:change={onchange}
on:focus={() => { on:focus={() => {
if (zipCodes.length > 0) { if (zipCodes.length > 0) {
hideZipDropdown = false hideZipDropdown = false

View File

@@ -3,7 +3,7 @@ import { memoize } from "./Memoization.js";
import { api } from "astro-typesafe-api/client" import { api } from "astro-typesafe-api/client"
export const getKlimafaktoren = memoize(async (date: Date, plz: string) => { export const getKlimafaktoren = memoize(async (date: Date, plz: string) => {
if (!plz || !date) { if (!plz || plz.length < 5 || !date) {
return null; return null;
} }