8
8
ADD_CHILD ,
9
9
DELETE_CHILD ,
10
10
DELETE_COMPONENT ,
11
+ TOGGLE_STATE ,
11
12
CHANGE_FOCUS_COMPONENT ,
12
13
CHANGE_FOCUS_CHILD ,
13
14
CHANGE_COMPONENT_FOCUS_CHILD ,
@@ -24,6 +25,7 @@ import {
24
25
ADD_PROP ,
25
26
DELETE_ALL_DATA ,
26
27
UPDATE_HTML_ATTR ,
28
+
27
29
UPDATE_CHILDREN_SORT ,
28
30
CHANGE_IMAGE_SOURCE ,
29
31
DELETE_IMAGE
@@ -57,7 +59,7 @@ export const addComponent = ({ title }: { title: string }) => (dispatch: (arg: A
57
59
export const addChild = ( {
58
60
title,
59
61
childType,
60
- HTMLInfo,
62
+ HTMLInfo
61
63
} : {
62
64
title : string ;
63
65
childType : string ;
@@ -73,7 +75,7 @@ export const deleteChild = ({}) => (dispatch: (arg: Action) => void) => {
73
75
74
76
export const deleteComponent = ( {
75
77
componentId,
76
- stateComponents,
78
+ stateComponents
77
79
} : {
78
80
componentId : number ;
79
81
stateComponents : ComponentsInt ;
@@ -88,8 +90,8 @@ stateComponents: ComponentsInt;
88
90
payload : {
89
91
parentId : parent . id ,
90
92
childId : child . childId ,
91
- calledFromDeleteComponent : true ,
92
- } ,
93
+ calledFromDeleteComponent : true
94
+ }
93
95
} ) ;
94
96
} ) ;
95
97
} ) ;
@@ -111,14 +113,14 @@ export const changeFocusChild = ({ childId }: { childId: number }) => (dispatch:
111
113
112
114
export const changeComponentFocusChild = ( {
113
115
componentId,
114
- childId,
116
+ childId
115
117
} : {
116
118
componentId : number ;
117
119
childId : number ;
118
120
} ) => ( dispatch : ( arg : Action ) => void ) => {
119
121
dispatch ( {
120
122
type : CHANGE_COMPONENT_FOCUS_CHILD ,
121
- payload : { componentId, childId } ,
123
+ payload : { componentId, childId }
122
124
} ) ;
123
125
} ;
124
126
@@ -131,7 +133,7 @@ export const exportFiles = ({
131
133
components,
132
134
path,
133
135
appName,
134
- exportAppBool,
136
+ exportAppBool
135
137
} : {
136
138
components : ComponentsInt ;
137
139
path : string ;
@@ -140,31 +142,38 @@ exportAppBool: boolean;
140
142
} ) => ( dispatch : ( arg : Action ) => void ) => {
141
143
// this dispatch sets the global state property 'loading' to true until the createFiles call resolves below
142
144
dispatch ( {
143
- type : EXPORT_FILES ,
145
+ type : EXPORT_FILES
144
146
} ) ;
145
147
146
148
createFiles ( components , path , appName , exportAppBool )
147
- . then ( dir => dispatch ( {
148
- type : EXPORT_FILES_SUCCESS ,
149
- payload : { status : true , dir : dir [ 0 ] } ,
150
- } ) )
151
- . catch ( err => dispatch ( {
152
- type : EXPORT_FILES_ERROR ,
153
- payload : { status : true , err } ,
154
- } ) ) ;
149
+ . then ( dir =>
150
+ dispatch ( {
151
+ type : EXPORT_FILES_SUCCESS ,
152
+ payload : { status : true , dir : dir [ 0 ] }
153
+ } )
154
+ )
155
+ . catch ( err =>
156
+ dispatch ( {
157
+ type : EXPORT_FILES_ERROR ,
158
+ payload : { status : true , err }
159
+ } )
160
+ ) ;
155
161
} ;
156
162
157
163
export const handleClose = ( ) => ( {
158
164
type : HANDLE_CLOSE ,
159
- payload : false ,
165
+ payload : false
160
166
} ) ;
161
167
162
168
export const handleTransform = (
163
169
componentId : number ,
164
170
childId : number ,
165
171
{
166
- x, y, width, height,
167
- } : { x : number ; y : number ; width : number ; height : number } ,
172
+ x,
173
+ y,
174
+ width,
175
+ height
176
+ } : { x : number ; y : number ; width : number ; height : number }
168
177
) => ( {
169
178
type : HANDLE_TRANSFORM ,
170
179
payload : {
@@ -173,16 +182,16 @@ export const handleTransform = (
173
182
x,
174
183
y,
175
184
width,
176
- height,
177
- } ,
185
+ height
186
+ }
178
187
} ) ;
179
188
180
189
export const createApplication = ( {
181
190
path,
182
191
components = [ ] ,
183
192
genOption,
184
193
appName = 'reactype_app' ,
185
- exportAppBool,
194
+ exportAppBool
186
195
} : {
187
196
path : string ;
188
197
components : ComponentsInt ;
@@ -197,13 +206,13 @@ exportAppBool: boolean;
197
206
appName,
198
207
path,
199
208
components,
200
- exportAppBool,
201
- } ) ,
209
+ exportAppBool
210
+ } )
202
211
) ;
203
212
} else if ( genOption ) {
204
213
exportAppBool = true ;
205
214
dispatch ( {
206
- type : CREATE_APPLICATION ,
215
+ type : CREATE_APPLICATION
207
216
} ) ;
208
217
createApplicationUtil ( {
209
218
path,
@@ -212,48 +221,54 @@ exportAppBool: boolean;
212
221
} )
213
222
. then ( ( ) => {
214
223
dispatch ( {
215
- type : CREATE_APPLICATION_SUCCESS ,
224
+ type : CREATE_APPLICATION_SUCCESS
216
225
} ) ;
217
226
dispatch (
218
227
exportFiles ( {
219
228
appName,
220
229
path,
221
230
components,
222
- exportAppBool,
223
- } ) ,
231
+ exportAppBool
232
+ } )
224
233
) ;
225
234
} )
226
- . catch ( err => dispatch ( {
227
- type : CREATE_APPLICATION_ERROR ,
228
- payload : { status : true , err } ,
229
- } ) ) ;
235
+ . catch ( err =>
236
+ dispatch ( {
237
+ type : CREATE_APPLICATION_ERROR ,
238
+ payload : { status : true , err }
239
+ } )
240
+ ) ;
230
241
}
231
242
} ;
232
243
233
244
export const openExpansionPanel = ( component : ComponentInt ) => ( {
234
245
type : OPEN_EXPANSION_PANEL ,
235
- payload : { component } ,
246
+ payload : { component }
236
247
} ) ;
237
248
238
249
export const deleteAllData = ( ) => ( {
239
- type : DELETE_ALL_DATA ,
250
+ type : DELETE_ALL_DATA
240
251
} ) ;
241
252
242
253
export const deleteProp = ( propId : number ) => ( dispatch : ( arg : Action ) => void ) => {
243
254
dispatch ( { type : DELETE_PROP , payload : propId } ) ;
244
255
} ;
245
256
257
+ export const toggleComponentState = ( index : string ) => ( dispatch : any ) => {
258
+ dispatch ( { type : TOGGLE_STATE , payload : index } ) ;
259
+ } ;
260
+
246
261
export const addProp = ( prop : PropInt ) => ( {
247
262
type : ADD_PROP ,
248
- payload : { ...prop } ,
263
+ payload : { ...prop }
249
264
} ) ;
250
265
251
266
export const updateHtmlAttr = ( { attr, value } : { attr : string ; value : string } ) => (
252
267
dispatch : ( arg : Action ) => void ,
253
268
) => {
254
269
dispatch ( {
255
270
type : UPDATE_HTML_ATTR ,
256
- payload : { attr, value } ,
271
+ payload : { attr, value }
257
272
} ) ;
258
273
} ;
259
274
0 commit comments