diff --git a/src/components/Ausweis/Ausweisart.svelte b/src/components/Ausweis/Ausweisart.svelte index b3aabc93..f2252659 100644 --- a/src/components/Ausweis/Ausweisart.svelte +++ b/src/components/Ausweis/Ausweisart.svelte @@ -2,9 +2,16 @@ import { Verbrauchsausweis } from "src/lib/Ausweis/Verbrauchsausweis"; import { Gebaeude } from "src/lib/Gebaeude"; import HelpLabel from "~/components/HelpLabel.svelte"; + import { auditHeizungGebaeudeBaujahr } from "../Verbrauchsausweis/audits/HeizungGebaeudeBaujahr"; + import { addNotification, deleteNotification } from "../Notifications/shared"; + import TagInput from "../TagInput.svelte"; + import { writable } from "svelte/store"; export let gebaeude: Gebaeude; + // TODO: Das ist scheise + let tags = writable([]); + $: ausweis = gebaeude.ausweis || new Verbrauchsausweis(); @@ -71,11 +78,27 @@ />z.B. 1994-2001.
- { + addNotification({ + message: "Info", + subtext: "Wussten sie, dass sie mehrere Jahre angeben können in denen z.B. Renovierungen an ihrer Heizung durchgeführt wurden. Drücken sie dafür einfach Enter oder Space nach jedem Jahr.", + dismissable: true, + uid: "HEIZUNG_BAUJAHR", + timeout: 0, + type: "info" + }); + }} + onFocusOut={() => { + deleteNotification("HEIZUNG_BAUJAHR") + }} + className="{auditHeizungGebaeudeBaujahr(gebaeude) ? "linked" : ""}" required - bind:value={ausweis.baujahr_anlage} + autocomplete="off" + bind:tags />
@@ -92,12 +115,27 @@ -saniert- angeben.
- { + addNotification({ + message: "Info", + subtext: "Wussten sie, dass sie mehrere Jahre angeben können in denen z.B. Renovierungen an ihrem Gebäude durchgeführt wurden. Drücken sie dafür einfach Enter oder Space nach jedem Jahr.", + dismissable: true, + uid: "GEBAEUDE_BAUJAHR", + timeout: 0, + type: "info" + }); + }} + onFocusOut={() => { + deleteNotification("GEBAEUDE_BAUJAHR") + }} + className="{auditHeizungGebaeudeBaujahr(gebaeude) ? "linked" : ""}" required autocomplete="off" - bind:value={gebaeude.baujahr} + bind:tags />
diff --git a/src/components/Ausweis/Verbrauch.svelte b/src/components/Ausweis/Verbrauch.svelte index 87d4eda3..0141cbf1 100644 --- a/src/components/Ausweis/Verbrauch.svelte +++ b/src/components/Ausweis/Verbrauch.svelte @@ -4,11 +4,11 @@ import Label from "../Label.svelte"; import fuelList from "./fuelList"; import { Verbrauchsausweis } from "src/lib/Ausweis/Verbrauchsausweis"; - import { VerbrauchsausweisGewerbe } from "src/lib/Ausweis/VerbrauchsausweisGewerbe"; - import { Bedarfsausweis } from "src/lib/Ausweis/Bedarfsausweis"; + import { Gebaeude } from "src/lib/Gebaeude"; + import { auditVerbrauchAbweichung } from "../Verbrauchsausweis/audits/VerbrauchAbweichung"; let availableYears = [ - 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, + 2018, 2019, ]; let availableMonths = [ "Januar", @@ -25,7 +25,7 @@ "Dezember", ]; - export let ausweis: Verbrauchsausweis |VerbrauchsausweisGewerbe | Bedarfsausweis; + export let gebaeude: Gebaeude; const fuelMap: Record = {}; for (const fuel of fuelList) { @@ -37,11 +37,15 @@ let month: string = "01"; let year: string = "2018"; + $: ausweis = gebaeude.ausweis || new Verbrauchsausweis(); + $: { if (month && year) { - ausweis.energieverbrauch_zeitraum = moment(`${month}.01.${year}`); + ausweis.kennwerte.zeitraum = moment(`${month}.01.${year}`); } } + + $: abweichung = auditVerbrauchAbweichung(gebaeude);
@@ -56,7 +60,7 @@
@@ -88,7 +92,7 @@ Koks: Stark kohlenstoffhaltiger Brennstoff.

- {#each Object.keys(fuelMap) as fuel} @@ -107,10 +111,10 @@ @@ -122,8 +126,8 @@
- {#each (fuelMap.hasOwnProperty(ausweis.energietraeger_2) ? fuelMap[ausweis.energietraeger_2] : []) as unit} + {#each (fuelMap.hasOwnProperty(ausweis.kennwerte.energietraeger_2) ? fuelMap[ausweis.kennwerte.energietraeger_2] : []) as unit} {/each} @@ -184,7 +188,7 @@ von von bis bis bis -1} + bind:value={ausweis.kennwerte.verbrauch_1} required />
@@ -248,7 +253,8 @@ -1} + bind:value={ausweis.kennwerte.verbrauch_2} required />
@@ -257,7 +263,8 @@ -1} + bind:value={ausweis.kennwerte.verbrauch_3} required /> @@ -268,8 +275,9 @@ -1} + disabled={!ausweis.kennwerte.zusaetzliche_heizquelle} />
@@ -277,8 +285,9 @@ -1} + disabled={!ausweis.kennwerte.zusaetzliche_heizquelle} />
@@ -286,8 +295,9 @@ -1} + disabled={!ausweis.kennwerte.zusaetzliche_heizquelle} />
diff --git a/src/components/Header.astro b/src/components/Header.astro index 369710bb..a6309600 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -18,8 +18,8 @@ const loggedIn = isLoggedIn(Astro); alt="IBCornelsen - Logo" onclick="window.location.href = '/'" /> -

Energieausweis online erstellen

-

Energieausweise nach aktueller GEG

+

Energieausweis online erstellen

+

Energieausweise nach aktueller GEG

diff --git a/src/components/LoginView.svelte b/src/components/LoginView.svelte index dec6396b..7e0704b2 100644 --- a/src/components/LoginView.svelte +++ b/src/components/LoginView.svelte @@ -1,9 +1,9 @@ @@ -52,13 +58,7 @@ required /> - - {#if hasError} -

- Das hat leider nicht geklappt, haben sie ihr Passwort und den - Nutzernamen richtig eingegeben? -

- {/if} +
Registrieren Passwort Vergessen? diff --git a/src/components/Notifications/Notification.svelte b/src/components/Notifications/Notification.svelte new file mode 100644 index 00000000..d14a8837 --- /dev/null +++ b/src/components/Notifications/Notification.svelte @@ -0,0 +1,10 @@ + + + +

{@html notification.subtext}

+
\ No newline at end of file diff --git a/src/components/Notifications/NotificationWrapper.svelte b/src/components/Notifications/NotificationWrapper.svelte new file mode 100644 index 00000000..fda211bc --- /dev/null +++ b/src/components/Notifications/NotificationWrapper.svelte @@ -0,0 +1,12 @@ + + + + {#each Object.entries($notifications) as [uid, notification] (uid)} + + {/each} + \ No newline at end of file diff --git a/src/components/Notifications/RawNotification.svelte b/src/components/Notifications/RawNotification.svelte new file mode 100644 index 00000000..f156b583 --- /dev/null +++ b/src/components/Notifications/RawNotification.svelte @@ -0,0 +1,44 @@ + + +
+
+

{@html notification.message}

+

+
+ {#if notification.dismissable} + + {/if} +
+ + \ No newline at end of file diff --git a/src/components/Notifications/RawNotificationWrapper.svelte b/src/components/Notifications/RawNotificationWrapper.svelte new file mode 100644 index 00000000..4a77163c --- /dev/null +++ b/src/components/Notifications/RawNotificationWrapper.svelte @@ -0,0 +1,3 @@ +
+ +
\ No newline at end of file diff --git a/src/components/Notifications/shared.ts b/src/components/Notifications/shared.ts new file mode 100644 index 00000000..b59dce81 --- /dev/null +++ b/src/components/Notifications/shared.ts @@ -0,0 +1,80 @@ +import { Writable, writable } from "svelte/store"; +import { v4 as uuid } from "uuid"; + +export const notifications: Writable> = writable({}); + +const defaults = { + message: "", + dismissable: false, + timeout: 4000, + subtext: "", + type: "error", + onUserDismiss: () => {} +}; + +export interface Notification { + message: string; + dismissable: boolean; + timeout: number; + subtext: string; + type: "error" | "success" | "info" | "warning"; + onUserDismiss: () => any; + uid?: string; +} + +export function updateNotification(uid: string, updater: Partial) { + notifications.update((value) => { + value[uid] = { ...defaults, ...value[uid], ...updater } as Notification; + return value; + }) +} + +export function addNotification(notification: Partial): string { + let uid = uuid(); + + if (notification.uid) { + uid = notification.uid; + } + + const object: Notification = { ...defaults, ...notification } as Notification; + + notifications.update((value) => { + value[uid] = object; + return value; + }) + + if (object.timeout) { + setTimeout(() => { + deleteNotification(uid); + }, object.timeout); + } + + return uid; +} + +export function deleteNotification(uid: string) { + notifications.update((value) => { + delete value[uid]; + return value; + }) +} + +export function showLinkedElement(query: string) { + const element = document.querySelector(query); + + if (!element) { + return; + } + + element.classList.add("linked"); +} + +export function hideLinkedElement(query: string) { + const element = document.querySelector(query); + + if (!element) { + return; + } + + element.classList.remove("linked"); +} \ No newline at end of file diff --git a/src/components/RegisterView.svelte b/src/components/RegisterView.svelte index 250a9b25..b6e096a3 100644 --- a/src/components/RegisterView.svelte +++ b/src/components/RegisterView.svelte @@ -1,13 +1,14 @@

Registrieren:

-