add user/test marks to Live

This commit is contained in:
Seth Trowbridge 2023-06-14 22:32:21 -04:00
parent 3b802fadc7
commit e101a376b7
3 changed files with 14 additions and 9 deletions

View File

@ -82,7 +82,7 @@ export const Grade =(inTest)=>
const Reselect =(inState, inTest)=> const Reselect =(inState, inTest)=>
{ {
/** @type {Store.Context} */ /** @type {Store.Context} */
const output = { Test:inTest??inState.Live.Test }; const output = { Test:inTest??inState.Live.Test, Mark:{User:undefined} };
const column = ColumnMapping[inState.Freq.Value]; const column = ColumnMapping[inState.Freq.Value];
if(column && output.Test) if(column && output.Test)
{ {
@ -93,7 +93,8 @@ const Reselect =(inState, inTest)=>
if(plot.Hz == hz) if(plot.Hz == hz)
{ {
output.Freq = plot; output.Freq = plot;
output.Mark = inState.Chan.Value ? plot.UserR : plot.UserL; output.Mark.User = inState.Chan.Value ? plot.UserR : plot.UserL;
output.Mark.Test = inState.Chan.Value ? plot.TestR : plot.TestL;
break; break;
} }
} }
@ -179,8 +180,8 @@ export function Reducer(inState, inAction)
if(clone.Live.Test && clone.Live.Freq) if(clone.Live.Test && clone.Live.Freq)
{ {
const key = clone.Chan.Value == 0 ? "UserL" : "UserR"; const key = clone.Chan.Value == 0 ? "UserL" : "UserR";
clone.Live.Mark = Data !== null ? {Stim:clone.Stim.Value, Resp:Data} : undefined; clone.Live.Mark.User = Data !== null ? {Stim:clone.Stim.Value, Resp:Data} : undefined;
clone.Live.Freq[key] = clone.Live.Mark; clone.Live.Freq[key] = clone.Live.Mark.User;
clone.Draw[key] = Redraw(clone.Live.Test, clone.Chan.Value, clone.Stim, true); clone.Draw[key] = Redraw(clone.Live.Test, clone.Chan.Value, clone.Stim, true);
clone.Live.Test.Done = Grade(clone.Live.Test); clone.Live.Test.Done = Grade(clone.Live.Test);
SaveTests(clone); SaveTests(clone);
@ -328,7 +329,7 @@ export const Initial = Reducer(
{ {
Test: undefined, Test: undefined,
Freq: undefined, Freq: undefined,
Mark: undefined Mark: {User: undefined}
}, },
Draw: Draw:
{ {

View File

@ -267,7 +267,7 @@ export const Controls =()=>
`} `}
onClick=${()=>Dispatch({Name:"Mark", Data:null })} onClick=${()=>Dispatch({Name:"Mark", Data:null })}
classes="text-sm w-full" classes="text-sm w-full"
disabled=${State.Live.Mark == undefined} disabled=${State.Live.Mark.User == undefined}
> >
Clear Clear
<//> <//>
@ -284,9 +284,9 @@ export const Audiogram =()=>
const [State] = Store.Consumer(); const [State] = Store.Consumer();
const testMarksL = State.Draw.TestL.Points.map(p=>html`<${Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${false}/>`); const testMarksL = State.Draw.TestL.Points.map(p=>html`<${Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${false}/>`);
const userMarksL = State.Draw.UserL.Points.map(p=>html`<${Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${false} classes=${State.Live.Mark == p.Mark ? "stroke-bold":""}/>`); const userMarksL = State.Draw.UserL.Points.map(p=>html`<${Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${false} classes=${State.Live.Mark.User == p.Mark ? "stroke-bold":""}/>`);
const testMarksR = State.Draw.TestR.Points.map(p=>html`<${Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${true} />`); const testMarksR = State.Draw.TestR.Points.map(p=>html`<${Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${true} />`);
const userMarksR = State.Draw.UserR.Points.map(p=>html`<${Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${true} classes=${State.Live.Mark == p.Mark ? "stroke-bold":""}/>`); const userMarksR = State.Draw.UserR.Points.map(p=>html`<${Mark} x=${p.X} y=${p.Y} response=${p.Mark?.Resp} right=${true} classes=${State.Live.Mark.User == p.Mark ? "stroke-bold":""}/>`);
const testLinesL = State.Draw.TestL.Paths.map( p=>html`<line class="opacity-60" x1=${p.Head.X} y1=${p.Head.Y} x2=${p.Tail.X} y2=${p.Tail.Y} />`); const testLinesL = State.Draw.TestL.Paths.map( p=>html`<line class="opacity-60" x1=${p.Head.X} y1=${p.Head.Y} x2=${p.Tail.X} y2=${p.Tail.Y} />`);
const userLinesL = State.Draw.UserL.Paths.map( p=>html`<line class="opacity-60" x1=${p.Head.X} y1=${p.Head.Y} x2=${p.Tail.X} y2=${p.Tail.Y} />`); const userLinesL = State.Draw.UserL.Paths.map( p=>html`<line class="opacity-60" x1=${p.Head.X} y1=${p.Head.Y} x2=${p.Tail.X} y2=${p.Tail.Y} />`);

6
ts/store.d.ts vendored
View File

@ -21,7 +21,11 @@ declare namespace Store {
type Context = { type Context = {
Test?: Test; Test?: Test;
Freq?: TestFrequency; Freq?: TestFrequency;
Mark?: TestFrequencySample; Mark:
{
User?: TestFrequencySample,
Test?: TestFrequencySample,
}
}; };
type StatePartSimple = type StatePartSimple =