Skip to content

Commit ac765d5

Browse files
committed
can now nest functions. still working on full functionality
1 parent 072dcc5 commit ac765d5

File tree

7 files changed

+28
-37
lines changed

7 files changed

+28
-37
lines changed

app/src/components/main/AddRoute.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ function AddRoute({
99
}: AddRoutes) {
1010
// const [, dispatch] = useContext(StateContext);
1111
const dispatch = useDispatch();
12-
12+
const contextParam = useSelector(store => store.contextSlice)
1313
const handleClick = (id) => {
1414
dispatch(addChild({
1515
type: 'HTML Element',
1616
typeId: -1,
17-
childId: id // this is the id of the parent to attach it to
17+
childId: id, // this is the id of the parent to attach it to
18+
contextParam: store.contextSlice
1819
}))
1920
// dispatch({
2021
// type: 'ADD CHILD',

app/src/components/main/Canvas.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Arrow from './Arrow';
1010
import { getRowsStateFromCache } from '@mui/x-data-grid/hooks/features/rows/gridRowsUtils';
1111
// Redux Toolkit test
1212
import { useDispatch, useSelector } from 'react-redux';
13-
import { changeFocus, addChild,snapShotAction } from '../../redux/reducers/slice/appStateSlice';
13+
import { changeFocus, addChild, snapShotAction } from '../../redux/reducers/slice/appStateSlice';
1414

1515
function Canvas(props): JSX.Element {
1616
// const [state, dispatch] = useContext(StateContext);

app/src/components/main/DirectChildHTMLNestable.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import AddRoute from './AddRoute';
1414
import AddLink from './AddLink';
1515
import { useDispatch, useSelector } from 'react-redux';
1616

17-
import { changeFocus, changePosition,addChild } from '../../redux/reducers/slice/appStateSlice';
17+
import { changeFocus, changePosition, addChild, snapShotAction } from '../../redux/reducers/slice/appStateSlice';
1818

1919
import { styleContext } from '../../containers/AppContainer';
2020

@@ -30,7 +30,11 @@ function DirectChildHTMLNestable({
3030
// const [state, dispatch] = useContext(StateContext);
3131
const { isThemeLight } = useContext(styleContext);
3232
const isDarkMode = useSelector(store => store.darkMode.isDarkMode);
33-
const state = useSelector(store => store.appState);
33+
// const state = useSelector(store => store.appState);
34+
const { state, contextParam } = useSelector((store) => ({
35+
state: store.appState,
36+
contextParam: store.contextSlice,
37+
}));
3438
const dispatch = useDispatch();
3539
const ref = useRef(null);
3640
// const [linkDisplayed, setLinkDisplayed] = useState('');
@@ -41,9 +45,9 @@ function DirectChildHTMLNestable({
4145
const deepCopiedState = JSON.parse(JSON.stringify(state));
4246
const focusIndex = state.canvasFocus.componentId - 1;
4347
//pushes the last user action on the canvas into the past array of Component
44-
state.components[focusIndex].past.push(
45-
deepCopiedState.components[focusIndex].children
46-
);
48+
// state.components[focusIndex].past.push(
49+
// deepCopiedState.components[focusIndex].children
50+
dispatch(snapShotAction({focusIndex: focusIndex, deepCopiedState: deepCopiedState}))
4751
};
4852

4953
// find the HTML element corresponding with this instance of an HTML element
@@ -96,7 +100,8 @@ function DirectChildHTMLNestable({
96100
dispatch(addChild({
97101
type: item.instanceType,
98102
typeId: item.instanceTypeId,
99-
childId: childId
103+
childId: childId,
104+
contextParam: contextParam
100105
}))
101106
// dispatch({
102107
// type: 'ADD CHILD',

app/src/components/main/RouteLink.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,8 @@ function RouteLink({ childId, type, typeId, style }: ChildElement) {
4646
// the route handler will change the focus of the canvas to the component referenced in the route link when the text is selected
4747
function onClickHandlerRoute(event) {
4848
event.stopPropagation();
49-
<<<<<<< HEAD
50-
// changeFocus(typeId, null);
51-
// dispatch(changeFocus({ componentId:typeId, childId: null}));
52-
dispatch(changeFocus(typeId));
53-
=======
5449
changeFocusFunction(typeId, null);
5550
// dispatch(changeFocus({ componentId:typeId, childId: null}));
56-
>>>>>>> allstate
5751
}
5852
// combine all styles so that higher priority style specifications overrule lower priority style specifications
5953
// priority order is 1) style directly set for this child (style), 2) style for the routeLink component, and 3) default styling

app/src/components/main/SeparatorChild.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import validateNewParent from '../../helperFunctions/changePositionValidation'
1010
import componentNest from '../../helperFunctions/componentNestValidation'
1111
import { useDispatch, useSelector } from 'react-redux';
1212

13-
import { changeFocus, changePosition,addChild } from '../../redux/reducers/slice/appStateSlice';
13+
import { changeFocus, changePosition, addChild } from '../../redux/reducers/slice/appStateSlice';
1414

1515

1616

@@ -22,7 +22,11 @@ function DirectChildHTMLNestable({
2222
children
2323
}: ChildElement) {
2424
// const [state, dispatch] = useContext(StateContext);
25-
const state = useSelector(store => store.appState);
25+
// const state = useSelector(store => store.appState);
26+
const { state, contextParam } = useSelector((store) => ({
27+
state: store.appState,
28+
contextParam: store.contextSlice,
29+
}));
2630
const dispatch = useDispatch();
2731
const ref = useRef(null);
2832

@@ -67,6 +71,7 @@ function DirectChildHTMLNestable({
6771
type: item.instanceType,
6872
typeId: item.instanceTypeId,
6973
childId: childId,
74+
contextParam: contextParam
7075
}))
7176
// dispatch({
7277
// type: 'ADD CHILD',
@@ -110,14 +115,8 @@ function DirectChildHTMLNestable({
110115
// onClickHandler is responsible for changing the focused component and child component
111116
function onClickHandler(event) {
112117
event.stopPropagation();
113-
<<<<<<< HEAD
114-
// changeFocus(state.canvasFocus.componentId, childId);
115-
// dispatch(changeFocus({ componentId: state.canvasFocus.componentId, childId: state.canvasFocus.childId}));
116-
dispatch(changeFocus(state.canvasFocus.componentId));
117-
=======
118118
changeFocusFunction(state.canvasFocus.componentId, childId);
119119
// dispatch(changeFocus({ componentId: state.canvasFocus.componentId, childId: state.canvasFocus.childId}));
120-
>>>>>>> allstate
121120
}
122121

123122
// combine all styles so that higher priority style specifications overrule lower priority style specifications

app/src/components/right/ComponentPanel.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,7 @@ const dispatch = useDispatch();
107107
// type: 'ADD COMPONENT',
108108
// payload: { componentName: formattedName, root: isRoot }
109109
// });
110-
<<<<<<< HEAD
111-
112-
// dispatch(addComponent( { componentName: formattedName, root: isRoot }));
113-
const component = addComponent({ componentName: formattedName, root: isRoot });
114-
dispatch(component);
115-
console.log('component:', component);
116-
=======
117110
dispatch(addComponent({ componentName: formattedName, root: isRoot, contextParam: contextParam }));
118-
>>>>>>> allstate
119111
// reset root toggle back to default position
120112
setIsRoot(false);
121113
// reset name field

app/src/containers/CustomizationPanel.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,11 +307,11 @@ const CustomizationPanel = ({ isThemeLight }): JSX.Element => {
307307

308308
const deleteEvent = selectedEvent => {
309309
dispatch(deleteEventAction({ event: selectedEvent }))
310-
// dispatch({
311-
// type: 'DELETE EVENT',
312-
// payload: { event: selectedEvent }
313-
// });
314-
// };
310+
// dispatch({
311+
// type: 'DELETE EVENT',
312+
// payload: { event: selectedEvent }
313+
// });
314+
};
315315

316316

317317
const handleSave = (tailwind): Object => {
@@ -1007,5 +1007,5 @@ const useStyles = makeStyles({
10071007
color: '#fff'
10081008
}
10091009
});
1010-
};
1010+
10111011
export default CustomizationPanel;

0 commit comments

Comments
 (0)