1
- import { ComponentInt , ComponentsInt , PropInt , ChildInt , Action } from '../utils/Interfaces' ;
1
+ import {
2
+ ComponentInt ,
3
+ ComponentsInt ,
4
+ PropInt ,
5
+ ChildInt ,
6
+ Action ,
7
+ } from '../utils/Interfaces' ;
2
8
3
9
import {
4
10
LOAD_INIT_DATA ,
@@ -27,7 +33,7 @@ import {
27
33
// UPDATE_CHILDREN_SORT, --The reason why this is commented out is because of the unused reducer of the same name, for the component that is unfinished with the same name. Check out the Sort Children component to see what it does.
28
34
CHANGE_IMAGE_SOURCE ,
29
35
DELETE_IMAGE ,
30
- CHANGE_TUTORIAL
36
+ CHANGE_TUTORIAL ,
31
37
} from '../actionTypes/index' ;
32
38
33
39
import { loadState } from '../localStorage' ; //this is a warning from 'localStorage' being a .js file instead of .ts. Convert to .ts to remove this warning.
@@ -36,33 +42,35 @@ import createApplicationUtil from '../utils/createApplication.util';
36
42
37
43
export const changeTutorial = ( tutorial : number ) => ( {
38
44
type : CHANGE_TUTORIAL ,
39
- payload : { tutorial }
45
+ payload : { tutorial } ,
40
46
} ) ;
41
47
42
48
export const changeImagePath = ( imageSource : string ) => ( {
43
49
type : CHANGE_IMAGE_SOURCE ,
44
- payload : { imageSource }
50
+ payload : { imageSource } ,
45
51
} ) ;
46
52
47
53
export const loadInitData = ( ) => ( dispatch : ( arg : Action ) => void ) => {
48
54
loadState ( ) . then ( ( data : any ) => {
49
55
dispatch ( {
50
56
type : LOAD_INIT_DATA ,
51
57
payload : {
52
- data : data ? data . workspace : { }
53
- }
58
+ data : data ? data . workspace : { } ,
59
+ } ,
54
60
} ) ;
55
61
} ) ;
56
62
} ;
57
63
58
- export const addComponent = ( { title } : { title : string } ) => ( dispatch : ( arg : Action ) => void ) => {
64
+ export const addComponent = ( { title } : { title : string } ) => (
65
+ dispatch : ( arg : Action ) => void ,
66
+ ) => {
59
67
dispatch ( { type : ADD_COMPONENT , payload : { title } } ) ;
60
68
} ;
61
69
62
70
export const addChild = ( {
63
71
title,
64
72
childType,
65
- HTMLInfo
73
+ HTMLInfo,
66
74
} : {
67
75
title : string ;
68
76
childType : string ;
@@ -78,7 +86,7 @@ export const deleteChild = ({}) => (dispatch: (arg: Action) => void) => {
78
86
79
87
export const deleteComponent = ( {
80
88
componentId,
81
- stateComponents
89
+ stateComponents,
82
90
} : {
83
91
componentId : number ;
84
92
stateComponents : ComponentsInt ;
@@ -93,8 +101,8 @@ export const deleteComponent = ({
93
101
payload : {
94
102
parentId : parent . id ,
95
103
childId : child . childId ,
96
- calledFromDeleteComponent : true
97
- }
104
+ calledFromDeleteComponent : true ,
105
+ } ,
98
106
} ) ;
99
107
} ) ;
100
108
} ) ;
@@ -106,40 +114,40 @@ export const deleteComponent = ({
106
114
} ;
107
115
108
116
export const changeFocusComponent = ( { title } : { title : string } ) => (
109
- dispatch : ( arg : Action ) => void
117
+ dispatch : ( arg : Action ) => void ,
110
118
) => {
111
119
dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title } } ) ;
112
120
} ;
113
121
114
122
// make sure childId is being sent in
115
123
export const changeFocusChild = ( { childId } : { childId : number } ) => (
116
- dispatch : ( arg : Action ) => void
124
+ dispatch : ( arg : Action ) => void ,
117
125
) => {
118
126
dispatch ( { type : CHANGE_FOCUS_CHILD , payload : { childId } } ) ;
119
127
} ;
120
128
121
129
export const changeComponentFocusChild = ( {
122
130
componentId,
123
- childId
131
+ childId,
124
132
} : {
125
133
componentId : number ;
126
134
childId : number ;
127
135
} ) => ( dispatch : ( arg : Action ) => void ) => {
128
136
dispatch ( {
129
137
type : CHANGE_COMPONENT_FOCUS_CHILD ,
130
- payload : { componentId, childId }
138
+ payload : { componentId, childId } ,
131
139
} ) ;
132
140
} ;
133
141
134
142
export const deleteImage = ( ) => ( {
135
- type : DELETE_IMAGE
143
+ type : DELETE_IMAGE ,
136
144
} ) ;
137
145
138
146
export const exportFiles = ( {
139
147
components,
140
148
path,
141
149
appName,
142
- exportAppBool
150
+ exportAppBool,
143
151
} : {
144
152
components : ComponentsInt ;
145
153
path : string ;
@@ -148,32 +156,37 @@ export const exportFiles = ({
148
156
} ) => ( dispatch : ( arg : Action ) => void ) => {
149
157
// this dispatch sets the global state property 'loading' to true until the createFiles call resolves below
150
158
dispatch ( {
151
- type : EXPORT_FILES
159
+ type : EXPORT_FILES ,
152
160
} ) ;
153
161
createFiles ( components , path , appName , exportAppBool )
154
162
. then ( ( dir : any ) =>
155
163
dispatch ( {
156
164
type : EXPORT_FILES_SUCCESS ,
157
- payload : { status : true , dir : dir [ 0 ] }
158
- } )
165
+ payload : { status : true , dir : dir [ 0 ] } ,
166
+ } ) ,
159
167
)
160
168
. catch ( ( err : string ) =>
161
169
dispatch ( {
162
170
type : EXPORT_FILES_ERROR ,
163
- payload : { status : true , err }
164
- } )
171
+ payload : { status : true , err } ,
172
+ } ) ,
165
173
) ;
166
174
} ;
167
175
168
176
export const handleClose = ( ) => ( {
169
177
type : HANDLE_CLOSE ,
170
- payload : false
178
+ payload : false ,
171
179
} ) ;
172
180
173
181
export const handleTransform = (
174
182
componentId : number ,
175
183
childId : number ,
176
- { x, y, width, height } : { x : number ; y : number ; width : number ; height : number }
184
+ {
185
+ x,
186
+ y,
187
+ width,
188
+ height,
189
+ } : { x : number ; y : number ; width : number ; height : number } ,
177
190
) => ( {
178
191
type : HANDLE_TRANSFORM ,
179
192
payload : {
@@ -182,16 +195,16 @@ export const handleTransform = (
182
195
x,
183
196
y,
184
197
width,
185
- height
186
- }
198
+ height,
199
+ } ,
187
200
} ) ;
188
201
189
202
export const createApplication = ( {
190
203
path,
191
204
components = [ ] ,
192
205
genOption,
193
206
appName = 'reactype_app' ,
194
- exportAppBool
207
+ exportAppBool,
195
208
} : {
196
209
path : string ;
197
210
components : ComponentsInt ;
@@ -206,73 +219,83 @@ export const createApplication = ({
206
219
appName,
207
220
path,
208
221
components,
209
- exportAppBool
210
- } )
222
+ exportAppBool,
223
+ } ) ,
211
224
) ;
212
225
} else if ( genOption ) {
213
226
exportAppBool = true ;
214
227
dispatch ( {
215
- type : CREATE_APPLICATION
228
+ type : CREATE_APPLICATION ,
216
229
} ) ;
217
230
createApplicationUtil ( {
218
231
path,
219
232
appName,
220
- genOption
233
+ genOption,
221
234
} )
222
235
. then ( ( ) => {
223
236
dispatch ( {
224
- type : CREATE_APPLICATION_SUCCESS
237
+ type : CREATE_APPLICATION_SUCCESS ,
225
238
} ) ;
226
239
dispatch (
227
240
exportFiles ( {
228
241
appName,
229
242
path,
230
243
components,
231
- exportAppBool
232
- } )
244
+ exportAppBool,
245
+ } ) ,
233
246
) ;
234
247
} )
235
248
. catch ( ( err : string ) =>
236
249
dispatch ( {
237
250
type : CREATE_APPLICATION_ERROR ,
238
- payload : { status : true , err }
239
- } )
251
+ payload : { status : true , err } ,
252
+ } ) ,
240
253
) ;
241
254
}
242
255
} ;
243
256
244
257
export const openExpansionPanel = ( component : ComponentInt ) => ( {
245
258
type : OPEN_EXPANSION_PANEL ,
246
- payload : { component }
259
+ payload : { component } ,
247
260
} ) ;
248
261
249
262
export const deleteAllData = ( ) => ( {
250
- type : DELETE_ALL_DATA
263
+ type : DELETE_ALL_DATA ,
251
264
} ) ;
252
265
253
- export const deleteProp = ( propId : number ) => ( dispatch : ( arg : Action ) => void ) => {
266
+ export const deleteProp = ( propId : number ) => (
267
+ dispatch : ( arg : Action ) => void ,
268
+ ) => {
254
269
dispatch ( { type : DELETE_PROP , payload : propId } ) ;
255
270
} ;
256
271
257
- export const toggleComponentState = ( id : string ) => ( dispatch : ( arg : Action ) => void ) => {
272
+ export const toggleComponentState = ( id : string ) => (
273
+ dispatch : ( arg : Action ) => void ,
274
+ ) => {
258
275
dispatch ( { type : TOGGLE_STATE , payload : id } ) ;
259
276
} ;
260
277
261
- export const toggleComponentClass = ( id : string ) => ( dispatch : ( arg : Action ) => void ) => {
278
+ export const toggleComponentClass = ( id : string ) => (
279
+ dispatch : ( arg : Action ) => void ,
280
+ ) => {
262
281
dispatch ( { type : TOGGLE_CLASS , payload : id } ) ;
263
282
} ;
264
283
265
284
export const addProp = ( prop : PropInt ) => ( {
266
285
type : ADD_PROP ,
267
- payload : { ...prop }
286
+ payload : { ...prop } ,
268
287
} ) ;
269
288
270
- export const updateHtmlAttr = ( { attr, value } : { attr : string ; value : string } ) => (
271
- dispatch : ( arg : Action ) => void
272
- ) => {
289
+ export const updateHtmlAttr = ( {
290
+ attr,
291
+ value,
292
+ } : {
293
+ attr : string ;
294
+ value : string ;
295
+ } ) => ( dispatch : ( arg : Action ) => void ) => {
273
296
dispatch ( {
274
297
type : UPDATE_HTML_ATTR ,
275
- payload : { attr, value }
298
+ payload : { attr, value } ,
276
299
} ) ;
277
300
} ;
278
301
0 commit comments