@@ -25,21 +25,23 @@ import {
25
25
DELETE_PROP ,
26
26
ADD_PROP ,
27
27
DELETE_ALL_DATA ,
28
- CHANGE_IMAGE_PATH ,
29
- } from ' ../actionTypes/index' ;
28
+ CHANGE_IMAGE_PATH
29
+ } from " ../actionTypes/index" ;
30
30
31
- import { loadState } from ' ../localStorage' ;
31
+ import { loadState } from " ../localStorage" ;
32
32
33
33
// import createFiles from '../utils/createFiles.util';
34
34
// import createApplicationUtil from '../utils/createApplication.util';
35
35
36
- export const loadInitData = ( ) => ( dispatch ) => {
37
- loadState ( ) . then ( data => dispatch ( {
38
- type : LOAD_INIT_DATA ,
39
- payload : {
40
- data : data ? data . workspace : { } ,
41
- } ,
42
- } ) ) ;
36
+ export const loadInitData = ( ) => dispatch => {
37
+ loadState ( ) . then ( data =>
38
+ dispatch ( {
39
+ type : LOAD_INIT_DATA ,
40
+ payload : {
41
+ data : data ? data . workspace : { }
42
+ }
43
+ } )
44
+ ) ;
43
45
} ;
44
46
45
47
// export const updateChildren = ({ parentIds, childIndex, childId }) => ({
@@ -60,39 +62,47 @@ export const loadInitData = () => (dispatch) => {
60
62
// },
61
63
// });
62
64
63
- export const addComponent = ( { title } ) => ( dispatch ) => {
65
+ export const addComponent = ( { title } ) => dispatch => {
64
66
dispatch ( { type : ADD_COMPONENT , payload : { title } } ) ;
65
67
} ;
66
68
67
- export const addChild = ( { title } ) => ( dispatch ) => {
68
- dispatch ( { type : ADD_CHILD , payload : { title } } ) ;
69
+ export const addChild = ( { title, childType , HTMLInfo } ) => dispatch => {
70
+ dispatch ( { type : ADD_CHILD , payload : { title, childType , HTMLInfo } } ) ;
69
71
} ;
70
72
71
- export const deleteChild = ( { } ) => ( dispatch ) => {
73
+ export const deleteChild = ( { } ) => dispatch => {
72
74
// with no payload, it will delete focusd child
73
75
dispatch ( { type : DELETE_CHILD , payload : { } } ) ;
74
76
} ;
75
77
76
- export const deleteComponent = ( { componentId, stateComponents } ) => ( dispatch ) => {
77
- console . log ( 'Hello from component.js delete component.componentId= ' , componentId ) ;
78
+ export const deleteComponent = ( {
79
+ componentId,
80
+ stateComponents
81
+ } ) => dispatch => {
82
+ console . log (
83
+ "Hello from component.js delete component.componentId= " ,
84
+ componentId
85
+ ) ;
78
86
79
87
// find all places where the "to be delted" is a child and do what u gotta do
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
- } ,
88
+ stateComponents . forEach ( parent => {
89
+ parent . childrenArray
90
+ . filter ( child => child . childComponentId == componentId )
91
+ . forEach ( child => {
92
+ // console.log(`Should delete ${child.childId} from component id:${parent.id} ${parent.title}`)
93
+ dispatch ( {
94
+ type : DELETE_CHILD ,
95
+ payload : {
96
+ parentId : parent . id ,
97
+ childId : child . childId ,
98
+ calledFromDeleteComponent : true
99
+ }
100
+ } ) ;
90
101
} ) ;
91
- } ) ;
92
102
} ) ;
93
103
94
104
// change focus to APp
95
- dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title : ' App' } } ) ;
105
+ dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title : " App" } } ) ;
96
106
// after taking care of the children delete the component
97
107
dispatch ( { type : DELETE_COMPONENT , payload : { componentId } } ) ;
98
108
} ;
@@ -128,19 +138,22 @@ export const deleteComponent = ({ componentId, stateComponents }) => (dispatch)
128
138
// dispatch({ type: SET_SELECTABLE_PARENTS });
129
139
// };
130
140
131
- export const changeFocusComponent = ( { title } ) => ( dispatch ) => {
141
+ export const changeFocusComponent = ( { title } ) => dispatch => {
132
142
dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title } } ) ;
133
143
} ;
134
144
135
145
// make sure childId is being sent in
136
- export const changeFocusChild = ( { title, childId } ) => ( dispatch ) => {
146
+ export const changeFocusChild = ( { title, childId } ) => dispatch => {
137
147
dispatch ( { type : CHANGE_FOCUS_CHILD , payload : { title, childId } } ) ;
138
148
} ;
139
149
140
- export const changeComponentFocusChild = ( { componentId, childId } ) => ( dispatch ) => {
150
+ export const changeComponentFocusChild = ( {
151
+ componentId,
152
+ childId
153
+ } ) => dispatch => {
141
154
dispatch ( {
142
155
type : CHANGE_COMPONENT_FOCUS_CHILD ,
143
- payload : { componentId, childId } ,
156
+ payload : { componentId, childId }
144
157
} ) ;
145
158
} ;
146
159
@@ -162,21 +175,23 @@ export const changeComponentFocusChild = ({ componentId, childId }) => (dispatch
162
175
163
176
export const handleClose = ( ) => ( {
164
177
type : HANDLE_CLOSE ,
165
- payload : false ,
178
+ payload : false
166
179
} ) ;
167
180
168
- export const handleTransform = ( componentId , childId , {
169
- x, y, width, height,
170
- } ) => ( {
181
+ export const handleTransform = (
182
+ componentId ,
183
+ childId ,
184
+ { x, y, width, height }
185
+ ) => ( {
171
186
type : HANDLE_TRANSFORM ,
172
187
payload : {
173
188
componentId,
174
189
childId,
175
190
x,
176
191
y,
177
192
width,
178
- height,
179
- } ,
193
+ height
194
+ }
180
195
} ) ;
181
196
182
197
// export const createApplication = ({
@@ -206,20 +221,18 @@ export const handleTransform = (componentId, childId, {
206
221
207
222
export const openExpansionPanel = component => ( {
208
223
type : OPEN_EXPANSION_PANEL ,
209
- payload : { component } ,
224
+ payload : { component }
210
225
} ) ;
211
226
212
227
// export const deleteAllData = () => ({
213
228
// type: DELETE_ALL_DATA,
214
229
// });
215
230
216
-
217
-
218
- export const deleteProp = ( propId ) => ( dispatch ) => {
219
- ; dispatch ( { type : DELETE_PROP , payload : propId } ) ;
231
+ export const deleteProp = propId => dispatch => {
232
+ dispatch ( { type : DELETE_PROP , payload : propId } ) ;
220
233
} ;
221
234
222
235
export const addProp = prop => ( {
223
236
type : ADD_PROP ,
224
- payload : { ...prop } ,
237
+ payload : { ...prop }
225
238
} ) ;
0 commit comments