Skip to content

Commit e3c309f

Browse files
Merge pull request #95 from tolgamizrakci/development
Development
2 parents 29b23c4 + ab3608a commit e3c309f

17 files changed

+1038
-311
lines changed

src/actions/components.js

Lines changed: 96 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,22 @@ import {
2727
DELETE_ALL_DATA,
2828
CHANGE_IMAGE_PATH,
2929
UPDATE_HTML_ATTR,
30-
UPDATE_CHILDREN_SORT,
31-
} from '../actionTypes/index';
30+
UPDATE_CHILDREN_SORT
31+
} from "../actionTypes/index";
3232

33-
import { loadState } from '../localStorage';
33+
import { loadState } from "../localStorage";
3434

35-
import createFiles from '../utils/createFiles.util';
36-
import createApplicationUtil from '../utils/createApplication.util';
35+
import createFiles from "../utils/createFiles.util.ts";
36+
import createApplicationUtil from "../utils/createApplication.util.ts";
3737

3838
export const loadInitData = () => dispatch => {
3939
loadState().then(data =>
4040
dispatch({
4141
type: LOAD_INIT_DATA,
4242
payload: {
43-
data: data ? data.workspace : {},
44-
},
45-
}),
43+
data: data ? data.workspace : {}
44+
}
45+
})
4646
);
4747
};
4848

@@ -77,22 +77,28 @@ export const deleteChild = ({}) => dispatch => {
7777
dispatch({ type: DELETE_CHILD, payload: {} });
7878
};
7979

80-
export const deleteComponent = ({ componentId, stateComponents }) => dispatch => {
80+
export const deleteComponent = ({
81+
componentId,
82+
stateComponents
83+
}) => dispatch => {
8184
// find all places where the "to be delted" is a child and do what u gotta do
82-
stateComponents.forEach((parent) => {
83-
parent.childrenArray.filter(child => child.childComponentId === componentId).forEach((child) => {
84-
dispatch({
85-
type: DELETE_CHILD,
86-
payload: {
87-
parentId: parent.id,
88-
childId: child.childId,
89-
calledFromDeleteComponent: true,
90-
},
85+
stateComponents.forEach(parent => {
86+
parent.childrenArray
87+
.filter(child => child.childComponentId === componentId)
88+
.forEach(child => {
89+
dispatch({
90+
type: DELETE_CHILD,
91+
payload: {
92+
parentId: parent.id,
93+
childId: child.childId,
94+
calledFromDeleteComponent: true
95+
}
96+
});
9197
});
9298
});
9399

94100
// change focus to APp
95-
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: 'App' } });
101+
dispatch({ type: CHANGE_FOCUS_COMPONENT, payload: { title: "App" } });
96102
// after taking care of the children delete the component
97103
dispatch({ type: DELETE_COMPONENT, payload: { componentId } });
98104
};
@@ -134,65 +140,108 @@ export const changeFocusComponent = ({ title }) => dispatch => {
134140

135141
// make sure childId is being sent in
136142
<<<<<<< HEAD
143+
<<<<<<< HEAD
137144
export const changeFocusChild = ({ title, childId }) => dispatch => {
138145
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { title, childId } });
139146
=======
140147
export const changeFocusChild = ({ childId }) => (dispatch) => {
148+
=======
149+
export const changeFocusChild = ({ childId }) => dispatch => {
150+
>>>>>>> fcd32cb... finished ts changes to util files
141151
dispatch({ type: CHANGE_FOCUS_CHILD, payload: { childId } });
142152
>>>>>>> c532596... reducer cleanup, working version
143153
};
144154

155+
<<<<<<< HEAD
145156
export const changeComponentFocusChild = ({ componentId, childId }) => dispatch => {
157+
=======
158+
export const changeComponentFocusChild = ({
159+
componentId,
160+
childId
161+
}) => dispatch => {
162+
>>>>>>> fcd32cb... finished ts changes to util files
146163
dispatch({
147164
type: CHANGE_COMPONENT_FOCUS_CHILD,
148-
payload: { componentId, childId },
165+
payload: { componentId, childId }
149166
});
150167
};
151168

169+
<<<<<<< HEAD
152170
export const exportFiles = ({ components, path, appName, exportAppBool }) => dispatch => {
171+
=======
172+
export const exportFiles = ({
173+
components,
174+
path,
175+
appName,
176+
exportAppBool
177+
}) => dispatch => {
178+
>>>>>>> fcd32cb... finished ts changes to util files
153179
// this dispatch sets the global state property 'loading' to true until the createFiles call resolves below
154180
dispatch({
155-
type: EXPORT_FILES,
181+
type: EXPORT_FILES
156182
});
157183

158184
createFiles(components, path, appName, exportAppBool)
159185
.then(dir =>
160186
dispatch({
161187
type: EXPORT_FILES_SUCCESS,
188+
<<<<<<< HEAD
162189
payload: { status: true, dir: dir[0] },
163190
}),
191+
=======
192+
payload: { status: true, dir: dir[0] }
193+
})
194+
>>>>>>> fcd32cb... finished ts changes to util files
164195
)
165196
.catch(err =>
166197
dispatch({
167198
type: EXPORT_FILES_ERROR,
199+
<<<<<<< HEAD
168200
payload: { status: true, err },
169201
}),
202+
=======
203+
payload: { status: true, err }
204+
})
205+
>>>>>>> fcd32cb... finished ts changes to util files
170206
);
171207
};
172208

173209
export const handleClose = () => ({
174210
type: HANDLE_CLOSE,
175-
payload: false,
211+
payload: false
176212
});
177213

214+
<<<<<<< HEAD
178215
export const handleTransform = (componentId, childId, { x, y, width, height }) => ({
216+
=======
217+
export const handleTransform = (
218+
componentId,
219+
childId,
220+
{ x, y, width, height }
221+
) => ({
222+
>>>>>>> fcd32cb... finished ts changes to util files
179223
type: HANDLE_TRANSFORM,
180224
payload: {
181225
componentId,
182226
childId,
183227
x,
184228
y,
185229
width,
186-
height,
187-
},
230+
height
231+
}
188232
});
189233

190234
export const createApplication = ({
191235
path,
192236
components = [],
193237
genOption,
238+
<<<<<<< HEAD
194239
appName = 'reactype_app',
195240
exportAppBool,
241+
=======
242+
appName = "reactype_app",
243+
exportAppBool
244+
>>>>>>> fcd32cb... finished ts changes to util files
196245
}) => dispatch => {
197246
if (genOption === 0) {
198247
exportAppBool = false;
@@ -201,48 +250,53 @@ export const createApplication = ({
201250
appName,
202251
path,
203252
components,
204-
exportAppBool,
205-
}),
253+
exportAppBool
254+
})
206255
);
207256
} else if (genOption) {
208257
dispatch({
209-
type: CREATE_APPLICATION,
258+
type: CREATE_APPLICATION
210259
});
211260
createApplicationUtil({
212261
path,
213262
appName,
214263
genOption,
215-
exportAppBool,
264+
exportAppBool
216265
})
217266
.then(() => {
218267
dispatch({
219-
type: CREATE_APPLICATION_SUCCESS,
268+
type: CREATE_APPLICATION_SUCCESS
220269
});
221270
dispatch(
222271
exportFiles({
223272
appName,
224273
path,
225274
components,
226-
exportAppBool,
227-
}),
275+
exportAppBool
276+
})
228277
);
229278
})
230279
.catch(err =>
231280
dispatch({
232281
type: CREATE_APPLICATION_ERROR,
282+
<<<<<<< HEAD
233283
payload: { status: true, err },
234284
}),
285+
=======
286+
payload: { status: true, err }
287+
})
288+
>>>>>>> fcd32cb... finished ts changes to util files
235289
);
236290
}
237291
};
238292

239293
export const openExpansionPanel = component => ({
240294
type: OPEN_EXPANSION_PANEL,
241-
payload: { component },
295+
payload: { component }
242296
});
243297

244298
export const deleteAllData = () => ({
245-
type: DELETE_ALL_DATA,
299+
type: DELETE_ALL_DATA
246300
});
247301

248302
export const deleteProp = propId => dispatch => {
@@ -251,19 +305,26 @@ export const deleteProp = propId => dispatch => {
251305

252306
export const addProp = prop => ({
253307
type: ADD_PROP,
254-
payload: { ...prop },
308+
payload: { ...prop }
255309
});
256310

257311
export const updateHtmlAttr = ({ attr, value }) => dispatch => {
258312
dispatch({
259313
type: UPDATE_HTML_ATTR,
260-
payload: { attr, value },
314+
payload: { attr, value }
261315
});
262316
};
263317

318+
<<<<<<< HEAD
319+
export const updateChildrenSort = ({ newChildrenArray }) => dispatch => {
320+
dispatch({
321+
type: UPDATE_CHILDREN_SORT,
322+
payload: { newChildrenArray }
323+
=======
264324
export const updateChildrenSort = ({ newSortValues }) => (dispatch) => {
265325
dispatch({
266326
type: UPDATE_CHILDREN_SORT,
267327
payload: { newSortValues },
328+
>>>>>>> 29b23c438a735dda0a220e39c9795d2ca252eb6d
268329
});
269330
};

0 commit comments

Comments
 (0)