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

View file

@ -1,8 +1,8 @@
div.Options { div.Options {
form { form {
display: flex; display: grid;
flex-flow: column nowrap; 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 type { resultsAction } from './reducer.results'
import { initState } from './reducer.init'; import { initState } from './reducer.init';
import type { initAction } from './reducer.init'; import type { initAction } from './reducer.init';
import { clearOutput } from './reducer.clear';
export type stateType = { export type stateType = {
lexicon: Array<{lexeme: string, epoch: epochType}>, 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 'SET_OPTIONS': return setOptions(state, action);
case 'CLEAR': return clearOutput(state, action);
case 'RUN': return run(state, action); case 'RUN': return run(state, action);
default: return state; default: return state;

View file

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