Skip to content

Commit 00b5986

Browse files
committed
adding in descriptor setting functions
1 parent de9db92 commit 00b5986

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

web-server/plugins/slycat-cca/js/components/wizard-store/reducers/cCAWizardSlice.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ export interface CCAWizardState {
3232
attributes: Attribute[];
3333
scaleInputs: boolean;
3434
marking: string | undefined;
35+
description: string | undefined;
36+
name: string | undefined;
3537
}
3638
const initialState: CCAWizardState = {
3739
tab: TabNames.CCA_DATA_WIZARD_SELECTION_TAB,
@@ -42,6 +44,8 @@ const initialState: CCAWizardState = {
4244
attributes: [],
4345
scaleInputs: false,
4446
marking: undefined,
47+
description: undefined,
48+
name: undefined,
4549
};
4650
export const cCAWizardSlice = createSlice({
4751
name: "cCAWizard",
@@ -71,6 +75,12 @@ export const cCAWizardSlice = createSlice({
7175
setMarking: (state, action: PayloadAction<string>) => {
7276
state.marking = action.payload;
7377
},
78+
setDescription: (state, action: PayloadAction<string>) => {
79+
state.description = action.payload;
80+
},
81+
setName: (state, action: PayloadAction<string>) => {
82+
state.name = action.payload;
83+
},
7484
resetCCAWizard: () => initialState,
7585
},
7686
});
@@ -85,7 +95,9 @@ export const {
8595
setFileUploaded,
8696
setAttributes,
8797
setScaleInputs,
88-
setMarking
98+
setMarking,
99+
setDescription,
100+
setName,
89101
} = cCAWizardSlice.actions;
90102
// Other code such as selectors can use the imported `RootState` type
91103
export const selectTab = (state: RootState) => state.cCAWizard.tab;
@@ -96,5 +108,7 @@ export const selectMid = (state: RootState) => state.cCAWizard.mid;
96108
export const selectAttributes = (state: RootState) => state.cCAWizard.attributes;
97109
export const selectScaleInputs = (state: RootState) => state.cCAWizard.scaleInputs;
98110
export const selectMarking = (state: RootState) => state.cCAWizard.marking;
111+
export const selectDescription = (state: RootState) => state.cCAWizard.marking;
112+
export const selectName = (state: RootState) => state.cCAWizard.marking;
99113

100114
export default cCAWizardSlice.reducer;

web-server/plugins/slycat-cca/js/components/wizard-tabs/CCALocalBrowserTab.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import * as React from "react";
55
import { SlycatLocalBrowser } from "../slycat-local-browser/SlycatLocalBrowser";
66
import { useSetUploadStatus } from "../CCAWizardUtils";
7-
import { useAppSelector } from "../wizard-store/hooks";
8-
import { selectFileUploaded } from "../wizard-store/reducers/cCAWizardSlice";
97

108
export const CCALocalBrowserTab = (props: { hidden?: boolean }) => {
119
const { hidden = false } = props;

web-server/plugins/slycat-cca/js/components/wizard-tabs/CCAModelCreation.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import * as React from "react";
55
import selectable_markings from "js/slycat-selectable-markings";
66
import { useAppDispatch, useAppSelector } from "../wizard-store/hooks";
7-
import { selectMarking, setMarking } from "../wizard-store/reducers/cCAWizardSlice";
7+
import { selectMarking, setDescription, setMarking, setName } from "../wizard-store/reducers/cCAWizardSlice";
88

99
export const CCAModelCreation = (props: { hidden?: boolean }) => {
1010
const { hidden = false } = props;
@@ -23,20 +23,35 @@ export const CCAModelCreation = (props: { hidden?: boolean }) => {
2323
dispatch(setMarking(event.target?.value));
2424
}
2525
};
26+
const onDescriptionChangeHandler = (event: React.ChangeEvent<HTMLTextAreaElement>) => {
27+
if (event.target?.value) {
28+
dispatch(setDescription(event.target?.value));
29+
}
30+
};
31+
const onNameChangeHandler = (event: React.ChangeEvent<HTMLInputElement>) => {
32+
if (event.target?.value) {
33+
dispatch(setName(event.target?.value));
34+
}
35+
};
2636
return (
2737
<div hidden={hidden}>
2838
<form data-bind="submit: name_model" id="new-cca-name-model-form" noValidate>
2939
<div className="mb-3 row required">
3040
<label className="col-sm-2 col-form-label">Name</label>
3141
<div className="col-sm-10">
32-
<input id="slycat-model-name" className="form-control" type="text" required />
42+
<input id="slycat-model-name" onChange={onNameChangeHandler} className="form-control" type="text" required />
3343
<div className="invalid-feedback">Please enter a model name.</div>
3444
</div>
3545
</div>
3646
<div className="mb-3 row">
3747
<label className="col-sm-2 col-form-label">Description</label>
3848
<div className="col-sm-10">
39-
<textarea id="slycat-model-description" className="form-control" rows={5}></textarea>
49+
<textarea
50+
id="slycat-model-description"
51+
onChange={onDescriptionChangeHandler}
52+
className="form-control"
53+
rows={5}
54+
></textarea>
4055
</div>
4156
</div>
4257
<div className="mb-3 row">

0 commit comments

Comments
 (0)