@@ -30,8 +30,8 @@ import {
30
30
31
31
import { loadState } from '../localStorage' ;
32
32
33
- // import createFiles from '../utils/createFiles.util';
34
- // import createApplicationUtil from '../utils/createApplication.util';
33
+ import createFiles from '../utils/createFiles.util' ;
34
+ import createApplicationUtil from '../utils/createApplication.util' ;
35
35
36
36
export const loadInitData = ( ) => ( dispatch ) => {
37
37
loadState ( ) . then ( data => dispatch ( {
@@ -42,30 +42,30 @@ export const loadInitData = () => (dispatch) => {
42
42
} ) ) ;
43
43
} ;
44
44
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
+ // });
53
53
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
+ // });
62
62
63
63
export const addComponent = ( { title } ) => ( dispatch ) => {
64
64
dispatch ( { type : ADD_COMPONENT , payload : { title } } ) ;
65
65
} ;
66
66
67
- export const addChild = ( { title } ) => ( dispatch ) => {
68
- dispatch ( { type : ADD_CHILD , payload : { title } } ) ;
67
+ export const addChild = ( { title, childType , HTMLInfo } ) => ( dispatch ) => {
68
+ dispatch ( { type : ADD_CHILD , payload : { title, childType , HTMLInfo } } ) ;
69
69
} ;
70
70
71
71
export const deleteChild = ( { } ) => ( dispatch ) => {
@@ -79,6 +79,7 @@ export const deleteComponent = ({ componentId, stateComponents }) => (dispatch)
79
79
// find all places where the "to be delted" is a child and do what u gotta do
80
80
stateComponents . forEach ( ( parent ) => {
81
81
parent . childrenArray . filter ( child => child . childComponentId == componentId ) . forEach ( ( child ) => {
82
+ // console.log(`Should delete ${child.childId} from component id:${parent.id} ${parent.title}`)
82
83
dispatch ( {
83
84
type : DELETE_CHILD ,
84
85
payload : {
@@ -96,36 +97,36 @@ export const deleteComponent = ({ componentId, stateComponents }) => (dispatch)
96
97
dispatch ( { type : DELETE_COMPONENT , payload : { componentId } } ) ;
97
98
} ;
98
99
99
- export const updateComponent = ( {
100
- id,
101
- index,
102
- newParentId = null ,
103
- color = null ,
104
- stateful = null ,
105
- } ) => ( dispatch ) => {
106
- dispatch ( {
107
- type : UPDATE_COMPONENT ,
108
- payload : {
109
- id,
110
- index,
111
- newParentId,
112
- color,
113
- stateful,
114
- } ,
115
- } ) ;
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
+ // });
116
117
117
- if ( newParentId ) {
118
- dispatch (
119
- updateChildren ( {
120
- parentIds : [ newParentId ] ,
121
- childId : id ,
122
- childIndex : index ,
123
- } ) ,
124
- ) ;
125
- }
118
+ // if (newParentId) {
119
+ // dispatch(
120
+ // updateChildren({
121
+ // parentIds: [newParentId],
122
+ // childId: id,
123
+ // childIndex: index,
124
+ // }),
125
+ // );
126
+ // }
126
127
127
- dispatch ( { type : SET_SELECTABLE_PARENTS } ) ;
128
- } ;
128
+ // dispatch({ type: SET_SELECTABLE_PARENTS });
129
+ // };
129
130
130
131
export const changeFocusComponent = ( { title } ) => ( dispatch ) => {
131
132
dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title } } ) ;
@@ -143,21 +144,21 @@ export const changeComponentFocusChild = ({ componentId, childId }) => (dispatch
143
144
} ) ;
144
145
} ;
145
146
146
- // export const exportFiles = ({ components, path }) => (dispatch) => {
147
- // dispatch({
148
- // type: EXPORT_FILES,
149
- // });
147
+ export const exportFiles = ( { components, path } ) => ( dispatch ) => {
148
+ dispatch ( {
149
+ type : EXPORT_FILES ,
150
+ } ) ;
150
151
151
- // createFiles(components, path)
152
- // .then(dir => dispatch({
153
- // type: EXPORT_FILES_SUCCESS,
154
- // payload: { status: true, dir: dir[0] },
155
- // }))
156
- // .catch(err => dispatch({
157
- // type: EXPORT_FILES_ERROR,
158
- // payload: { status: true, err },
159
- // }));
160
- // };
152
+ createFiles ( components , path )
153
+ . then ( dir => dispatch ( {
154
+ type : EXPORT_FILES_SUCCESS ,
155
+ payload : { status : true , dir : dir [ 0 ] } ,
156
+ } ) )
157
+ . catch ( err => dispatch ( {
158
+ type : EXPORT_FILES_ERROR ,
159
+ payload : { status : true , err } ,
160
+ } ) ) ;
161
+ } ;
161
162
162
163
export const handleClose = ( ) => ( {
163
164
type : HANDLE_CLOSE ,
@@ -178,30 +179,37 @@ export const handleTransform = (componentId, childId, {
178
179
} ,
179
180
} ) ;
180
181
181
- // export const createApplication = ({
182
- // path, components = [], genOption, appName = 'proto_app', repoUrl,
183
- // }) => (dispatch) => {
184
- // if (genOption === 0) {
185
- // dispatch(exportFiles({ path, components }));
186
- // } else if (genOption) {
187
- // dispatch({
188
- // type: CREATE_APPLICATION,
189
- // });
190
- // createApplicationUtil({
191
- // path, appName, genOption, repoUrl,
192
- // })
193
- // .then(() => {
194
- // dispatch({
195
- // type: CREATE_APPLICATION_SUCCESS,
196
- // });
197
- // dispatch(exportFiles({ path: `${path}/${appName}`, components }));
198
- // })
199
- // .catch(err => dispatch({
200
- // type: CREATE_APPLICATION_ERROR,
201
- // payload: { status: true, err },
202
- // }));
203
- // }
204
- // };
182
+ export const createApplication = ( {
183
+ path,
184
+ components = [ ] ,
185
+ genOption,
186
+ appName = 'proto_app' ,
187
+ repoUrl,
188
+ } ) => ( dispatch ) => {
189
+ if ( genOption === 0 ) {
190
+ dispatch ( exportFiles ( { path, components } ) ) ;
191
+ } else if ( genOption ) {
192
+ dispatch ( {
193
+ type : CREATE_APPLICATION ,
194
+ } ) ;
195
+ createApplicationUtil ( {
196
+ path,
197
+ appName,
198
+ genOption,
199
+ repoUrl,
200
+ } )
201
+ . then ( ( ) => {
202
+ dispatch ( {
203
+ type : CREATE_APPLICATION_SUCCESS ,
204
+ } ) ;
205
+ dispatch ( exportFiles ( { path : `${ path } /${ appName } ` , components } ) ) ;
206
+ } )
207
+ . catch ( err => dispatch ( {
208
+ type : CREATE_APPLICATION_ERROR ,
209
+ payload : { status : true , err } ,
210
+ } ) ) ;
211
+ }
212
+ } ;
205
213
206
214
export const openExpansionPanel = component => ( {
207
215
type : OPEN_EXPANSION_PANEL ,
0 commit comments