add clear output to Options component, remove future options

This commit is contained in:
Sorrel Bri 2020-02-28 11:58:16 -08:00
parent d87a99c498
commit e7a7673d68
5 changed files with 23 additions and 10 deletions

View file

@ -24,14 +24,20 @@ const Options = ({ options, dispatch }) => {
});
}
const handleOutputClearSubmit = e => {
e.preventDefault();
console.log('clearing')
dispatch({
type: 'CLEAR',
value: {}
});
}
return (
<div className="Options" data-testid="Options">
<h3>Modeling Options</h3>
<form onSubmit={e=>handleFormSubmit(e, options)} data-testid="Options-form">
{/* <h5>Output</h5> */}
<input
type="radio" name="output" id="default"
checked={options ? options.output === 'default' : true}
@ -41,7 +47,7 @@ const Options = ({ options, dispatch }) => {
<span className="Options__output-example"> output</span>
</label>
<input
{/* <input
type="radio" name="output" id="proto"
checked={options ? options.output === 'proto' : false}
onChange={e=>handleRadioChange(e)}
@ -57,13 +63,14 @@ const Options = ({ options, dispatch }) => {
/>
<label htmlFor="diachronic">Diachronic
<span className="Options__output-example"> *proto > *epoch > output</span>
</label>
</label> */}
<input type="submit" value="Run Changes"></input>
<input type="button" value="Clear Output" onClick={e=>handleOutputClearSubmit(e)}/>
</form>
<form onSubmit={()=>{}}>
{/* <form onSubmit={()=>{}}>
<label>
Load from a prior run:
<select value={load} onChange={e=>setLoad(e.target.value)}>
@ -75,7 +82,7 @@ const Options = ({ options, dispatch }) => {
</select>
</label>
<input type="submit" value="Submit" />
</form>
</form> */}
</div>
);
}

View file

@ -1,8 +1,8 @@
div.Options {
form {
display: flex;
flex-flow: column nowrap;
display: grid;
grid-template-columns: 1fr 1fr;
}
}

View file

@ -0,0 +1,3 @@
export const clearOutput = (state, action) => {
return { ...state, results: [], errors: {} };
}

View file

@ -11,6 +11,7 @@ import { run } from './reducer.results';
import type { resultsAction } from './reducer.results'
import { initState } from './reducer.init';
import type { initAction } from './reducer.init';
import { clearOutput } from './reducer.clear';
export type stateType = {
lexicon: Array<{lexeme: string, epoch: epochType}>,
@ -57,6 +58,8 @@ export const stateReducer = (state: stateType, action: actionType): stateType =>
case 'SET_OPTIONS': return setOptions(state, action);
case 'CLEAR': return clearOutput(state, action);
case 'RUN': return run(state, action);
default: return state;

View file

@ -280,6 +280,6 @@ export const run = (state: stateType, action: resultsAction): stateType => {
return {...state, results, errors: {} }
} catch (err) {
console.log(err)
return {...state, errors: err };
return {...state, errors: err, results:[] };
}
}