Skip to content

Commit 9b09733

Browse files
authored
Merge pull request #44 from ShlomoPorges/development
Fixed "focus component" & "focus child" in state and actions
2 parents 845aa4d + efde5d5 commit 9b09733

File tree

6 files changed

+167
-134
lines changed

6 files changed

+167
-134
lines changed

src/actions/components.js

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -42,23 +42,23 @@ export const loadInitData = () => (dispatch) => {
4242
}));
4343
};
4444

45-
export const updateChildren = ({ parentIds, childIndex, childId }) => ({
46-
type: UPDATE_CHILDREN,
47-
payload: {
48-
parentIds,
49-
childIndex,
50-
childId,
51-
},
52-
});
45+
// export const updateChildren = ({ parentIds, childIndex, childId }) => ({
46+
// type: UPDATE_CHILDREN,
47+
// payload: {
48+
// parentIds,
49+
// childIndex,
50+
// childId,
51+
// },
52+
// });
5353

54-
export const parentReassignment = ({ index, id, parentIds }) => ({
55-
type: REASSIGN_PARENT,
56-
payload: {
57-
index,
58-
id,
59-
parentIds,
60-
},
61-
});
54+
// export const parentReassignment = ({ index, id, parentIds }) => ({
55+
// type: REASSIGN_PARENT,
56+
// payload: {
57+
// index,
58+
// id,
59+
// parentIds,
60+
// },
61+
// });
6262

6363
export const addComponent = ({ title }) => (dispatch) => {
6464
dispatch({ type: ADD_COMPONENT, payload: { title } });
@@ -97,36 +97,36 @@ export const deleteComponent = ({ componentId, stateComponents }) => (dispatch)
9797
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });
9898
};
9999

100-
export const updateComponent = ({
101-
id,
102-
index,
103-
newParentId = null,
104-
color = null,
105-
stateful = null,
106-
}) => (dispatch) => {
107-
dispatch({
108-
type: UPDATE_COMPONENT,
109-
payload: {
110-
id,
111-
index,
112-
newParentId,
113-
color,
114-
stateful,
115-
},
116-
});
100+
// export const updateComponent = ({
101+
// id,
102+
// index,
103+
// newParentId = null,
104+
// color = null,
105+
// stateful = null,
106+
// }) => (dispatch) => {
107+
// dispatch({
108+
// type: UPDATE_COMPONENT,
109+
// payload: {
110+
// id,
111+
// index,
112+
// newParentId,
113+
// color,
114+
// stateful,
115+
// },
116+
// });
117117

118-
if (newParentId) {
119-
dispatch(
120-
updateChildren({
121-
parentIds: [newParentId],
122-
childId: id,
123-
childIndex: index,
124-
}),
125-
);
126-
}
127-
128-
dispatch({ type: SET_SELECTABLE_PARENTS });
129-
};
118+
// if (newParentId) {
119+
// dispatch(
120+
// updateChildren({
121+
// parentIds: [newParentId],
122+
// childId: id,
123+
// childIndex: index,
124+
// }),
125+
// );
126+
// }
127+
128+
// dispatch({ type: SET_SELECTABLE_PARENTS });
129+
// };
130130

131131
export const changeFocusComponent = ({ title }) => (dispatch) => {
132132
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title } });

src/components/DataTable.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ function dataTable(props) {
3232
const { classes , rowData, rowHeader , deletePropHandler } = props;
3333

3434
// console.log(classes)
35-
console.log(`rowHeader`)
36-
console.log(rowHeader)
37-
console.log(`rowData`)
38-
console.log(rowData)
35+
// console.log(`rowHeader`)
36+
// console.log(rowHeader)
37+
// console.log(`rowData`)
38+
// console.log(rowData)
3939

4040
const renderHeader = rowHeader.map( (col,idx) => {
4141
return <TableCell key={`head_+${idx}`}>{col}</TableCell>

src/containers/LeftContainer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class LeftContainer extends Component {
7777
key={component.id}
7878
index={i}
7979
id={component.id}
80-
updateComponent={updateComponent}
80+
// updateComponent={updateComponent}
8181
component={component}
8282
focusComponent={focusComponent}
8383
addChild={addChild}

src/reducers/componentReducer.js

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,11 @@ const appComponent = {
8686

8787
childrenArray: [],
8888
nextChildId: 1,
89-
focusChild: null,
89+
focusChildId: 0,
9090
};
9191

92-
const initialApplicationState = {
93-
totalComponents: 1,
94-
nextId: 2,
95-
// imagePath: '',
96-
successOpen: false,
97-
errorOpen: false,
98-
focusComponent: appComponent,
99-
selectableChildren: [],
100-
ancestors: [],
101-
focusChild: {
92+
const initialApplicationFocusChild =
93+
{
10294
childId: 0,
10395
componentName: null,
10496
position: {
@@ -108,7 +100,19 @@ const initialApplicationState = {
108100
height: 400,
109101
},
110102
draggable: true,
111-
},
103+
}
104+
105+
const initialApplicationState = {
106+
totalComponents: 1,
107+
nextId: 2,
108+
// imagePath: '',
109+
successOpen: false,
110+
errorOpen: false,
111+
focusComponent: appComponent,
112+
selectableChildren: [],
113+
ancestors: [],
114+
initialApplicationFocusChild: initialApplicationFocusChild,
115+
focusChild: JSON.parse(JSON.stringify( initialApplicationFocusChild)) ,
112116
components: [appComponent],
113117
appDir: '',
114118
loading: false,
@@ -141,12 +145,12 @@ const componentReducer = (state = initialApplicationState, action) => {
141145
return changeFocusChild(state, action.payload);
142146
case CHANGE_COMPONENT_FOCUS_CHILD:
143147
return changeComponentFocusChild(state, action.payload);
144-
case UPDATE_CHILDREN:
145-
return updateChildren(state, action.payload);
146-
case REASSIGN_PARENT:
147-
return reassignParent(state, action.payload);
148-
case SET_SELECTABLE_PARENTS:
149-
return setSelectableP(state);
148+
// case UPDATE_CHILDREN:
149+
// return updateChildren(state, action.payload);
150+
// case REASSIGN_PARENT:
151+
// return reassignParent(state, action.payload);
152+
// case SET_SELECTABLE_PARENTS:
153+
// return setSelectableP(state);
150154
case CREATE_APPLICATION:
151155
case EXPORT_FILES:
152156
return { ...state, loading: true };

0 commit comments

Comments
 (0)