From 2dc0d5e45bdf8ae10dd84e13564ebef3bb68e771 Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sun, 15 Mar 2020 14:19:15 -0400 Subject: [PATCH] Work on the trace viewer for form lines. --- src/FormView.css | 19 ++++++++++++++++++ src/FormView.tsx | 50 +++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 7 deletions(-) diff --git a/src/FormView.css b/src/FormView.css index 051e6c9..944984c 100644 --- a/src/FormView.css +++ b/src/FormView.css @@ -47,3 +47,22 @@ color: red; font-weight: bold; } + +.trace-viewer { + background-color: #fffdf1; + padding: 10px; +} + +.trace-viewer h2 { + margin: 0; + font-size: 14pt; +} + +.trace { + font-family: monospace; + white-space: pre; + max-height: 400px; + overflow: scroll; + border: 1px solid #444; + padding: 4px; +} diff --git a/src/FormView.tsx b/src/FormView.tsx index 3ffc9a4..dc8eead 100644 --- a/src/FormView.tsx +++ b/src/FormView.tsx @@ -3,9 +3,10 @@ // version 3.0. The full text of the license can be found in LICENSE.txt. // SPDX-License-Identifier: GPL-3.0-only -import { createMemo } from 'solid-js'; -import { For } from 'solid-js/dom'; -import { TaxReturn, Form } from 'ustaxlib/core'; +import { createDependentEffect, createMemo, createState } from 'solid-js'; +import { For, Show } from 'solid-js/dom'; +import { TaxReturn, Form, Line } from 'ustaxlib/core'; +import { getLastTraceList } from 'ustaxlib/core/Trace'; const S = require('./FormView.css'); @@ -27,14 +28,19 @@ export default function FormView(props: FormProps) { - {line => } + {line => }
); } -function Line(props: { tr, line }) { +interface LineProps { + tr: TaxReturn; + line: Line; +} + +function LineView(props: LineProps) { const { tr, line } = props; const value = createMemo(() => { try { @@ -43,11 +49,41 @@ function Line(props: { tr, line }) { return {e.message}; } }); + + const [ state, setState ] = createState({ + trace: "", + showTrace: false + }); + + createDependentEffect(() => setState('trace', JSON.stringify(getLastTraceList(), null, ' ')), [value]); + + const toggleTrace = () => setState('showTrace', !state.showTrace); + return ( - {line.id} - {line.description} + {line.id} + + {line.description} + + + + + {value()} ); } + +interface TraceProps { + line: Line; + trace: string; +} + +function TraceViewer(props: TraceProps) { + return ( +
+

Trace {props.line.id}

+
{props.trace}
+
+ ); +} -- 2.22.5