Skip to content

Commit 038cfa4

Browse files
authored
Merge pull request #40 from ChristianEdwardPadilla/development
New Canvas Features
2 parents b30c641 + dea1694 commit 038cfa4

14 files changed

+434
-722
lines changed

src/actionTypes/index.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export const HANDLE_TRANSFORM = 'HANDLE_TRANSFORM';
1818
export const CREATE_APPLICATION = 'CREATE_APPLICATION';
1919
export const CREATE_APPLICATION_SUCCESS = 'CREATE_APPLICATION_SUCCESS';
2020
export const CREATE_APPLICATION_ERROR = 'CREATE_APPLICATION_ERROR';
21-
export const TOGGLE_DRAGGING = 'TOGGLE_DRAGGING';
2221
export const MOVE_TO_BOTTOM = 'MOVE_TO_BOTTOM';
2322
export const MOVE_TO_TOP = 'MOVE_TO_TOP';
2423
export const OPEN_EXPANSION_PANEL = 'OPEN_EXPANSION_PANEL';

src/actions/components.js

Lines changed: 50 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -19,91 +19,80 @@ import {
1919
CREATE_APPLICATION,
2020
CREATE_APPLICATION_SUCCESS,
2121
CREATE_APPLICATION_ERROR,
22-
TOGGLE_DRAGGING,
2322
MOVE_TO_BOTTOM,
2423
MOVE_TO_TOP,
2524
OPEN_EXPANSION_PANEL,
2625
DELETE_PROP,
2726
ADD_PROP,
2827
DELETE_ALL_DATA,
29-
CHANGE_IMAGE_PATH
30-
} from "../actionTypes/index";
28+
CHANGE_IMAGE_PATH,
29+
} from '../actionTypes/index';
3130

32-
import { loadState } from "../localStorage";
31+
import { loadState } from '../localStorage';
3332

3433
// import createFiles from '../utils/createFiles.util';
3534
// import createApplicationUtil from '../utils/createApplication.util';
3635

37-
export const loadInitData = () => dispatch => {
38-
loadState().then(data =>
39-
dispatch({
40-
type: LOAD_INIT_DATA,
41-
payload: {
42-
data: data ? data.workspace : {}
43-
}
44-
})
45-
);
36+
export const loadInitData = () => (dispatch) => {
37+
loadState().then(data => dispatch({
38+
type: LOAD_INIT_DATA,
39+
payload: {
40+
data: data ? data.workspace : {},
41+
},
42+
}));
4643
};
4744

4845
export const updateChildren = ({ parentIds, childIndex, childId }) => ({
4946
type: UPDATE_CHILDREN,
5047
payload: {
5148
parentIds,
5249
childIndex,
53-
childId
54-
}
50+
childId,
51+
},
5552
});
5653

5754
export const parentReassignment = ({ index, id, parentIds }) => ({
5855
type: REASSIGN_PARENT,
5956
payload: {
6057
index,
6158
id,
62-
parentIds
63-
}
59+
parentIds,
60+
},
6461
});
6562

66-
export const addComponent = ({ title }) => dispatch => {
63+
export const addComponent = ({ title }) => (dispatch) => {
6764
dispatch({ type: ADD_COMPONENT, payload: { title } });
6865
};
6966

70-
export const addChild = ({ title }) => dispatch => {
67+
export const addChild = ({ title }) => (dispatch) => {
7168
dispatch({ type: ADD_CHILD, payload: { title } });
7269
};
7370

74-
export const deleteChild = ({}) => dispatch => {
71+
export const deleteChild = ({}) => (dispatch) => {
7572
// with no payload, it will delete focusd child
7673
dispatch({ type: DELETE_CHILD, payload: {} });
7774
};
7875

79-
export const deleteComponent = ({
80-
componentId,
81-
stateComponents
82-
}) => dispatch => {
83-
console.log(
84-
"Hello from component.js delete component.componentId= ",
85-
componentId
86-
);
76+
export const deleteComponent = ({ componentId, stateComponents }) => (dispatch) => {
77+
console.log('Hello from component.js delete component.componentId= ', componentId);
8778

8879
// find all places where the "to be delted" is a child and do what u gotta do
89-
stateComponents.forEach(parent => {
90-
parent.childrenArray
91-
.filter(child => child.childComponentId == componentId)
92-
.forEach(child => {
93-
// console.log(`Should delete ${child.childId} from component id:${parent.id} ${parent.title}`)
94-
dispatch({
95-
type: DELETE_CHILD,
96-
payload: {
97-
parentId: parent.id,
98-
childId: child.childId,
99-
calledFromDeleteComponent: true
100-
}
101-
});
80+
stateComponents.forEach((parent) => {
81+
parent.childrenArray.filter(child => child.childComponentId == componentId).forEach((child) => {
82+
// console.log(`Should delete ${child.childId} from component id:${parent.id} ${parent.title}`)
83+
dispatch({
84+
type: DELETE_CHILD,
85+
payload: {
86+
parentId: parent.id,
87+
childId: child.childId,
88+
calledFromDeleteComponent: true,
89+
},
10290
});
91+
});
10392
});
10493

10594
// change focus to APp
106-
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: "App" } });
95+
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: 'App' } });
10796
// after taking care of the children delete the component
10897
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });
10998
};
@@ -113,48 +102,45 @@ export const updateComponent = ({
113102
index,
114103
newParentId = null,
115104
color = null,
116-
stateful = null
117-
}) => dispatch => {
105+
stateful = null,
106+
}) => (dispatch) => {
118107
dispatch({
119108
type: UPDATE_COMPONENT,
120109
payload: {
121110
id,
122111
index,
123112
newParentId,
124113
color,
125-
stateful
126-
}
114+
stateful,
115+
},
127116
});
128117

129118
if (newParentId) {
130119
dispatch(
131120
updateChildren({
132121
parentIds: [newParentId],
133122
childId: id,
134-
childIndex: index
135-
})
123+
childIndex: index,
124+
}),
136125
);
137126
}
138127

139128
dispatch({ type: SET_SELECTABLE_PARENTS });
140129
};
141130

142-
export const changeFocusComponent = ({ title }) => dispatch => {
131+
export const changeFocusComponent = ({ title }) => (dispatch) => {
143132
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title } });
144133
};
145134

146135
// make sure childId is being sent in
147-
export const changeFocusChild = ({ title, childId }) => dispatch => {
136+
export const changeFocusChild = ({ title, childId }) => (dispatch) => {
148137
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { title, childId } });
149138
};
150139

151-
export const changeComponentFocusChild = ({
152-
componentId,
153-
childId
154-
}) => dispatch => {
140+
export const changeComponentFocusChild = ({ componentId, childId }) => (dispatch) => {
155141
dispatch({
156142
type: CHANGE_COMPONENT_FOCUS_CHILD,
157-
payload: { componentId, childId }
143+
payload: { componentId, childId },
158144
});
159145
};
160146

@@ -176,23 +162,21 @@ export const changeComponentFocusChild = ({
176162

177163
export const handleClose = () => ({
178164
type: HANDLE_CLOSE,
179-
payload: false
165+
payload: false,
180166
});
181167

182-
export const handleTransform = (
183-
componentId,
184-
childId,
185-
{ x, y, width, height }
186-
) => ({
168+
export const handleTransform = (componentId, childId, {
169+
x, y, width, height,
170+
}) => ({
187171
type: HANDLE_TRANSFORM,
188172
payload: {
189173
componentId,
190174
childId,
191175
x,
192176
y,
193177
width,
194-
height
195-
}
178+
height,
179+
},
196180
});
197181

198182
// export const createApplication = ({
@@ -220,41 +204,21 @@ export const handleTransform = (
220204
// }
221205
// };
222206

223-
export const toggleDragging = status => ({
224-
type: TOGGLE_DRAGGING,
225-
payload: status
226-
});
227-
228-
// export const moveToBottom = componentId => ({
229-
// type: MOVE_TO_BOTTOM,
230-
// payload: componentId,
231-
// });
232-
233-
// export const moveToTop = componentId => ({
234-
// type: MOVE_TO_TOP,
235-
// payload: componentId,
236-
// });
237-
238207
export const openExpansionPanel = component => ({
239208
type: OPEN_EXPANSION_PANEL,
240-
payload: { component }
209+
payload: { component },
241210
});
242211

243212
// export const deleteAllData = () => ({
244213
// type: DELETE_ALL_DATA,
245214
// });
246215

247-
// export const changeImagePath = path => ({
248-
// type: CHANGE_IMAGE_PATH,
249-
// payload: path,
250-
// });
251-
252216
export const deleteProp = ({ id, index }) => ({
253217
type: DELETE_PROP,
254-
payload: { id, index }
218+
payload: { id, index },
255219
});
256220

257221
export const addProp = prop => ({
258222
type: ADD_PROP,
259-
payload: { ...prop }
223+
payload: { ...prop },
260224
});

src/components/BottomPanel.jsx

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
1-
import React, { Component } from "react";
2-
import { connect } from "react-redux";
3-
// import PropTypes from 'prop-types';
4-
import {
5-
handleClose,
6-
deleteCompProp,
7-
addCompProp
8-
} from "../actions/components";
9-
// import Snackbars from '../components/Snackbars.jsx';
10-
import RightTabs from "./RightTabs.jsx";
1+
import React, { Component } from 'react';
2+
import { connect } from 'react-redux';
3+
import { handleClose, deleteCompProp, addCompProp } from '../actions/components';
4+
import RightTabs from './RightTabs.jsx';
115

12-
const IPC = require("electron").ipcRenderer;
6+
const IPC = require('electron').ipcRenderer;
137

148
const mapDispatchToProps = dispatch => ({
159
handleNotificationClose: () => dispatch(handleClose()),
1610
deleteProp: ({ id, index }) => dispatch(deleteCompProp({ id, index })),
17-
addProp: prop => dispatch(addCompProp(prop))
11+
addProp: prop => dispatch(addCompProp(prop)),
1812
});
1913

2014
const mapStateToProps = store => ({
2115
successOpen: store.workspace.successOpen,
2216
errorOpen: store.workspace.errorOpen,
23-
appDir: store.workspace.appDir
17+
appDir: store.workspace.appDir,
2418
});
2519

2620
class BottomPanel extends Component {
2721
state = {
2822
successOpen: false,
29-
errorOpen: false
23+
errorOpen: false,
3024
};
3125

3226
viewAppDir = () => {
33-
IPC.send("view_app_dir", this.props.appDir);
27+
IPC.send('view_app_dir', this.props.appDir);
3428
};
3529

3630
render() {
@@ -42,12 +36,12 @@ class BottomPanel extends Component {
4236
appDir,
4337
focusComponent,
4438
deleteProp,
45-
addProp
39+
addProp,
4640
// rightColumnOpen
4741
} = this.props;
4842

4943
return (
50-
<div className="bottom-panel" style={{ width: "100%" }}>
44+
<div className="bottom-panel" style={{ width: '100%' }}>
5145
<RightTabs
5246
components={components}
5347
focusComponent={focusComponent}
@@ -67,20 +61,7 @@ class BottomPanel extends Component {
6761
}
6862
}
6963

70-
// RightContainer.propTypes = {
71-
// components: PropTypes.array.isRequired,
72-
// successOpen: PropTypes.bool.isRequired,
73-
// appDir: PropTypes.string,
74-
// errorOpen: PropTypes.bool.isRequired,
75-
// focusComponent: PropTypes.object.isRequired,
76-
// handleNotificationClose: PropTypes.func.isRequired,
77-
// deleteProp: PropTypes.func.isRequired,
78-
// addProp: PropTypes.func.isRequired,
79-
// width: PropTypes.number.isRequired,
80-
// rightColumnOpen: PropTypes.bool.isRequired,
81-
// };
82-
8364
export default connect(
8465
mapStateToProps,
85-
mapDispatchToProps
66+
mapDispatchToProps,
8667
)(BottomPanel);

src/components/GrandchildRectangle.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React, { Component } from 'react';
22
import { Rect, Group } from 'react-konva';
3-
// import PropTypes from 'prop-types';
43

54
class GrandchildRectangle extends Component {
65
getComponentColor(componentId) {
@@ -40,8 +39,7 @@ class GrandchildRectangle extends Component {
4039
name={`${childId}`}
4140
x={0}
4241
y={0}
43-
// absolutePosition={{ x, y }}
44-
// childId={childId}
42+
childId={childId}
4543
componentId={componentId}
4644
scaleX={1}
4745
scaleY={1}
@@ -56,15 +54,16 @@ class GrandchildRectangle extends Component {
5654
/>
5755
{components
5856
.find(comp => comp.title === childComponentName)
59-
.childrenArray.map((grandchild, i) => (
57+
.childrenArray.filter(child => child.childId !== '-1')
58+
.map((grandchild, i) => (
6059
<GrandchildRectangle
6160
key={i}
6261
components={components}
6362
componentId={componentId}
6463
childComponentName={grandchild.componentName}
6564
childComponentId={grandchild.childComponentId}
6665
focusChild={focusChild}
67-
// childId={grandchild.childId}
66+
childId={childId}
6867
x={grandchild.position.x * (width / (window.innerWidth / 2))}
6968
y={grandchild.position.y * (height / window.innerHeight)}
7069
scaleX={1}

0 commit comments

Comments
 (0)