diff --git a/src/App.svelte b/src/App.svelte index 799c949729ef22371c1a624a46beeb9aad839800..b8159c0b8956036ed366c30e3b35d247c1fb175c 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -1,5 +1,6 @@ <script lang="ts"> - import type { WorkPackage } from "./estimator"; + import { element } from "svelte/internal"; +import type { WorkPackage } from "./estimator"; import RowWorkItem from "./RowWorkItem.svelte"; import SumRow from "./SumRow.svelte"; @@ -10,6 +11,7 @@ workPackages.push({a: null, b:null, c: null}); } $: dataJson = JSON.stringify(workPackages, null, 2) + let jsonPasteArea = ""; </script> <main> @@ -30,6 +32,38 @@ <SumRow {workPackages}></SumRow> </tbody> </table> + <details> + <summary> + Debug: Show Input as JSON + </summary> + <pre> + {dataJson} + </pre> + </details><details> + <summary> + Debug: Paste Input as JSON + </summary> + <textarea bind:value="{jsonPasteArea}" on:input={() => { + if (jsonPasteArea.trim().length === 0) return + try { + const decoded = JSON.parse(jsonPasteArea.trim()); + if (!Array.isArray(decoded)) + throw TypeError("Input must be an array") + for (const elem of decoded) { + if (typeof elem.a !== 'number' && elem.a !== null) + throw TypeError("An 'a' attribute was neither number not null"); + if (typeof elem.b !== 'number' && elem.b !== null) + throw TypeError("An 'b' attribute was neither number not null"); + if (typeof elem.c !== 'number' && elem.c !== null) + throw TypeError("An 'c' attribute was neither number not null"); + } + workPackages = decoded; + jsonPasteArea = ""; + } catch (error) { + alert(error.toString()) + } + }}/> + </details> </main> <a href="https://gitlab.fachschaften.org/jfowl/swk-project-effort-estimation"