Skip to content

Commit a3d9ae7

Browse files
committed
adding final step
1 parent 3408ac6 commit a3d9ae7

File tree

6 files changed

+78
-14
lines changed

6 files changed

+78
-14
lines changed

web-server/plugins/slycat-cca/js/components/CCAWizard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
useHandleClosingCallback,
1010
useHandleWizardSetup,
1111
} from "./CCAWizardUtils";
12-
import { useAppDispatch, useAppSelector } from "./wizard-store/hooks";
12+
import { useAppSelector } from "./wizard-store/hooks";
1313
import { selectMid, selectPid } from "./wizard-store/reducers/cCAWizardSlice";
1414

1515
interface CCAWizardParams {

web-server/plugins/slycat-cca/js/components/CCAWizardContent.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ export const CCAModalContent = (props: React.PropsWithChildren<ModalContentProps
3232
<div>
3333
<div className="modal-header">
3434
<h3 className="modal-title">{title}</h3>
35-
<button type="button" className="close" aria-label="Close" onClick={handleCloseModal}>
36-
<span aria-hidden="true">&times;</span>
35+
<button type="button" className="btn-close" aria-label="Close" data-bs-dismiss="modal" onClick={handleCloseModal}>
3736
</button>
3837
</div>
3938
<div className="modal-body" id="slycat-wizard">

web-server/plugins/slycat-cca/js/components/CCAWizardSteps.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ import { CCAWizardDataSelectionTab } from "./wizard-tabs/CCADataWizardSelectionT
66
import { CCAWizardNavItems } from "./CCANavItems";
77
import { useAppSelector } from "./wizard-store/hooks";
88
import { selectTab, TabNames } from "./wizard-store/reducers/cCAWizardSlice";
9-
import { CCALocalBrowserTab } from "./wizard-tabs/CCSLocalBrowserTab";
9+
import { CCALocalBrowserTab } from "./wizard-tabs/CCALocalBrowserTab";
1010
import { CCATableIngestion } from "./wizard-tabs/CCATableIngestion";
11+
import { CCAModelCreation } from "./wizard-tabs/CCAModelCreation";
1112

1213
export const CCAWizardSteps = () => {
1314
// The `state` arg is correctly typed as `RootState` already
@@ -19,6 +20,7 @@ export const CCAWizardSteps = () => {
1920
<CCAWizardDataSelectionTab hidden={!(tabName === TabNames.CCA_DATA_WIZARD_SELECTION_TAB)} />
2021
<CCALocalBrowserTab hidden={!(tabName === TabNames.CCA_LOCAL_BROWSER_TAB)} />
2122
<CCATableIngestion hidden={!(tabName === TabNames.CCA_TABLE_INGESTION)} />
23+
<CCAModelCreation hidden={!(tabName === TabNames.CCA_FINISH_MODEL)}/>
2224
<div hidden={true}>
2325
<form role="form">
2426
{/* <slycat-remote-controls
@@ -55,13 +57,6 @@ export const CCAWizardSteps = () => {
5557
<slycat-parser-controls params="parser:parser,category:'table'"></slycat-parser-controls> */}
5658
</div>
5759
</div>
58-
<div hidden={!(tabName === TabNames.CCA_FINISH_MODEL)}>
59-
<form data-bind="submit: name_model" id="new-cca-name-model-form" noValidate>
60-
{/* <slycat-model-controls
61-
params="name:model.name,description:model.description,marking:model.marking"
62-
></slycat-model-controls> */}
63-
</form>
64-
</div>
6560
</div>
6661
</div>
6762
);

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export enum TabNames {
55
CCA_DATA_WIZARD_SELECTION_TAB = "CCADataWizardSelectionTab",
66
CCA_LOCAL_BROWSER_TAB = "CCSLocalBrowserTab",
77
CCA_TABLE_INGESTION = "CCATableIngestion",
8-
CCA_FINISH_MODEL= "CCAFinishModel"
8+
CCA_FINISH_MODEL = "CCAFinishModel",
99
}
1010
export enum dataLocationType {
1111
LOCAL = "local",
@@ -31,6 +31,7 @@ export interface CCAWizardState {
3131
fileUploaded: boolean;
3232
attributes: Attribute[];
3333
scaleInputs: boolean;
34+
marking: string | undefined;
3435
}
3536
const initialState: CCAWizardState = {
3637
tab: TabNames.CCA_DATA_WIZARD_SELECTION_TAB,
@@ -39,7 +40,8 @@ const initialState: CCAWizardState = {
3940
pid: undefined,
4041
fileUploaded: false,
4142
attributes: [],
42-
scaleInputs: false
43+
scaleInputs: false,
44+
marking: undefined,
4345
};
4446
export const cCAWizardSlice = createSlice({
4547
name: "cCAWizard",
@@ -66,6 +68,9 @@ export const cCAWizardSlice = createSlice({
6668
setScaleInputs: (state, action: PayloadAction<boolean>) => {
6769
state.scaleInputs = action.payload;
6870
},
71+
setMarking: (state, action: PayloadAction<string>) => {
72+
state.marking = action.payload;
73+
},
6974
resetCCAWizard: () => initialState,
7075
},
7176
});
@@ -79,7 +84,8 @@ export const {
7984
resetCCAWizard: resetCCAWizard,
8085
setFileUploaded,
8186
setAttributes,
82-
setScaleInputs
87+
setScaleInputs,
88+
setMarking
8389
} = cCAWizardSlice.actions;
8490
// Other code such as selectors can use the imported `RootState` type
8591
export const selectTab = (state: RootState) => state.cCAWizard.tab;
@@ -89,5 +95,6 @@ export const selectPid = (state: RootState) => state.cCAWizard.pid;
8995
export const selectMid = (state: RootState) => state.cCAWizard.mid;
9096
export const selectAttributes = (state: RootState) => state.cCAWizard.attributes;
9197
export const selectScaleInputs = (state: RootState) => state.cCAWizard.scaleInputs;
98+
export const selectMarking = (state: RootState) => state.cCAWizard.marking;
9299

93100
export default cCAWizardSlice.reducer;
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/* Copyright (c) 2013, 2018 National Technology and Engineering Solutions of Sandia, LLC . Under the terms of Contract
2+
DE-NA0003525 with National Technology and Engineering Solutions of Sandia, LLC, the U.S. Government
3+
retains certain rights in this software. */
4+
import * as React from "react";
5+
import selectable_markings from "js/slycat-selectable-markings";
6+
import { useAppDispatch, useAppSelector } from "../wizard-store/hooks";
7+
import { selectMarking, setMarking } from "../wizard-store/reducers/cCAWizardSlice";
8+
9+
export const CCAModelCreation = (props: { hidden?: boolean }) => {
10+
const { hidden = false } = props;
11+
const dispatch = useAppDispatch();
12+
const marking = useAppSelector(selectMarking);
13+
React.useEffect(() => {
14+
if (!marking) {
15+
const defaultMarking = selectable_markings?.allowed().find((marking: any) => !!marking);
16+
if (defaultMarking?.type()) {
17+
dispatch(setMarking(defaultMarking.type()));
18+
}
19+
}
20+
}, [selectable_markings?.allowed()]);
21+
const onOptionChangeHandler = (event: React.ChangeEvent<HTMLSelectElement>) => {
22+
if (event.target?.value) {
23+
dispatch(setMarking(event.target?.value));
24+
}
25+
};
26+
return (
27+
<div hidden={hidden}>
28+
<form data-bind="submit: name_model" id="new-cca-name-model-form" noValidate>
29+
<div className="mb-3 row required">
30+
<label className="col-sm-2 col-form-label">Name</label>
31+
<div className="col-sm-10">
32+
<input id="slycat-model-name" className="form-control" type="text" required />
33+
<div className="invalid-feedback">Please enter a model name.</div>
34+
</div>
35+
</div>
36+
<div className="mb-3 row">
37+
<label className="col-sm-2 col-form-label">Description</label>
38+
<div className="col-sm-10">
39+
<textarea id="slycat-model-description" className="form-control" rows={5}></textarea>
40+
</div>
41+
</div>
42+
<div className="mb-3 row">
43+
<label className="col-sm-2 col-form-label">Marking</label>
44+
<div className="col-sm-10">
45+
<select
46+
id="slycat-model-marking"
47+
className="form-select"
48+
onChange={onOptionChangeHandler}
49+
>
50+
{selectable_markings?.allowed().map((marking: any) => {
51+
return (
52+
<option key={marking.type()} value={marking.type()}>
53+
{marking.label()}
54+
</option>
55+
);
56+
})}
57+
</select>
58+
</div>
59+
</div>
60+
</form>
61+
</div>
62+
);
63+
};

0 commit comments

Comments
 (0)