1
1
import {
2
- ComponentInt , ComponentsInt , PropInt , ChildInt , Action , ApplicationStateInt
2
+ ComponentInt ,
3
+ ComponentsInt ,
4
+ PropInt ,
5
+ ChildInt ,
6
+ Action ,
7
+ ApplicationStateInt
3
8
} from '../utils/Interfaces.ts' ;
4
9
5
10
import {
@@ -9,6 +14,7 @@ import {
9
14
DELETE_CHILD ,
10
15
DELETE_COMPONENT ,
11
16
TOGGLE_STATE ,
17
+ TOGGLE_CLASS ,
12
18
CHANGE_FOCUS_COMPONENT ,
13
19
CHANGE_FOCUS_CHILD ,
14
20
CHANGE_COMPONENT_FOCUS_CHILD ,
@@ -36,18 +42,19 @@ import createApplicationUtil from '../utils/createApplication.util.ts';
36
42
37
43
export const changeImagePath = ( imageSource : string ) => ( {
38
44
type : CHANGE_IMAGE_SOURCE ,
39
- payload : { imageSource } ,
40
- } )
45
+ payload : { imageSource }
46
+ } ) ;
41
47
42
48
export const loadInitData = ( ) => ( dispatch : ( arg : Action ) => void ) => {
43
49
loadState ( ) . then ( ( data : ApplicationStateInt ) => {
50
+ console . log ( 'data.workspace' , data . workspace ) ;
44
51
dispatch ( {
45
- type : LOAD_INIT_DATA ,
46
- payload : {
47
- data : data ? data . workspace : { } ,
48
- } ,
52
+ type : LOAD_INIT_DATA ,
53
+ payload : {
54
+ data : data ? data . workspace : { }
55
+ }
56
+ } ) ;
49
57
} ) ;
50
- } ) ;
51
58
} ;
52
59
53
60
export const addComponent = ( { title } : { title : string } ) => ( dispatch : ( arg : Action ) => void ) => {
@@ -59,9 +66,9 @@ export const addChild = ({
59
66
childType,
60
67
HTMLInfo
61
68
} : {
62
- title : string ;
63
- childType : string ;
64
- HTMLInfo : object ;
69
+ title : string ;
70
+ childType : string ;
71
+ HTMLInfo : object ;
65
72
} ) => ( dispatch : ( arg : Action ) => void ) => {
66
73
dispatch ( { type : ADD_CHILD , payload : { title, childType, HTMLInfo } } ) ;
67
74
} ;
@@ -75,8 +82,8 @@ export const deleteComponent = ({
75
82
componentId,
76
83
stateComponents
77
84
} : {
78
- componentId : number ;
79
- stateComponents : ComponentsInt ;
85
+ componentId : number ;
86
+ stateComponents : ComponentsInt ;
80
87
} ) => ( dispatch : ( arg : Action ) => void ) => {
81
88
// find all places where the "to be deleted" is a child and do what u gotta do
82
89
stateComponents . forEach ( ( parent : ComponentInt ) => {
@@ -100,21 +107,25 @@ stateComponents: ComponentsInt;
100
107
dispatch ( { type : DELETE_COMPONENT , payload : { componentId } } ) ;
101
108
} ;
102
109
103
- export const changeFocusComponent = ( { title } : { title : string } ) => ( dispatch : ( arg : Action ) => void ) => {
110
+ export const changeFocusComponent = ( { title } : { title : string } ) => (
111
+ dispatch : ( arg : Action ) => void
112
+ ) => {
104
113
dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title } } ) ;
105
114
} ;
106
115
107
116
// make sure childId is being sent in
108
- export const changeFocusChild = ( { childId } : { childId : number } ) => ( dispatch : ( arg : Action ) => void ) => {
117
+ export const changeFocusChild = ( { childId } : { childId : number } ) => (
118
+ dispatch : ( arg : Action ) => void
119
+ ) => {
109
120
dispatch ( { type : CHANGE_FOCUS_CHILD , payload : { childId } } ) ;
110
121
} ;
111
122
112
123
export const changeComponentFocusChild = ( {
113
124
componentId,
114
125
childId
115
126
} : {
116
- componentId : number ;
117
- childId : number ;
127
+ componentId : number ;
128
+ childId : number ;
118
129
} ) => ( dispatch : ( arg : Action ) => void ) => {
119
130
dispatch ( {
120
131
type : CHANGE_COMPONENT_FOCUS_CHILD ,
@@ -124,18 +135,18 @@ childId: number;
124
135
125
136
export const deleteImage = ( ) => ( {
126
137
type : DELETE_IMAGE
127
- } )
138
+ } ) ;
128
139
129
140
export const exportFiles = ( {
130
141
components,
131
142
path,
132
143
appName,
133
144
exportAppBool
134
145
} : {
135
- components : ComponentsInt ;
136
- path : string ;
137
- appName : string ;
138
- exportAppBool : boolean ;
146
+ components : ComponentsInt ;
147
+ path : string ;
148
+ appName : string ;
149
+ exportAppBool : boolean ;
139
150
} ) => ( dispatch : ( arg : Action ) => void ) => {
140
151
// this dispatch sets the global state property 'loading' to true until the createFiles call resolves below
141
152
dispatch ( {
@@ -185,11 +196,11 @@ export const createApplication = ({
185
196
appName = 'reactype_app' ,
186
197
exportAppBool
187
198
} : {
188
- path : string ;
189
- components : ComponentsInt ;
190
- genOption : number ;
191
- appName : string ;
192
- exportAppBool : boolean ;
199
+ path : string ;
200
+ components : ComponentsInt ;
201
+ genOption : number ;
202
+ appName : string ;
203
+ exportAppBool : boolean ;
193
204
} ) => ( dispatch : ( arg : Action ) => void ) => {
194
205
if ( genOption === 0 ) {
195
206
exportAppBool = false ;
@@ -209,7 +220,7 @@ exportAppBool: boolean;
209
220
createApplicationUtil ( {
210
221
path,
211
222
appName,
212
- genOption,
223
+ genOption
213
224
} )
214
225
. then ( ( ) => {
215
226
dispatch ( {
@@ -246,8 +257,12 @@ export const deleteProp = (propId: number) => (dispatch: (arg: Action) => void)
246
257
dispatch ( { type : DELETE_PROP , payload : propId } ) ;
247
258
} ;
248
259
249
- export const toggleComponentState = ( index : string ) => ( dispatch : any ) => {
250
- dispatch ( { type : TOGGLE_STATE , payload : index } ) ;
260
+ export const toggleComponentState = ( id : string ) => ( dispatch : any ) => {
261
+ dispatch ( { type : TOGGLE_STATE , payload : id } ) ;
262
+ } ;
263
+
264
+ export const toggleComponentClass = ( id : string ) => ( dispatch : any ) => {
265
+ dispatch ( { type : TOGGLE_CLASS , payload : id } ) ;
251
266
} ;
252
267
253
268
export const addProp = ( prop : PropInt ) => ( {
@@ -256,7 +271,7 @@ export const addProp = (prop: PropInt) => ({
256
271
} ) ;
257
272
258
273
export const updateHtmlAttr = ( { attr, value } : { attr : string ; value : string } ) => (
259
- dispatch : ( arg : Action ) => void ,
274
+ dispatch : ( arg : Action ) => void
260
275
) => {
261
276
dispatch ( {
262
277
type : UPDATE_HTML_ATTR ,
@@ -272,4 +287,4 @@ export const updateHtmlAttr = ({ attr, value }: { attr: string; value: string })
272
287
// type: UPDATE_CHILDREN_SORT,
273
288
// payload: { newSortValues },
274
289
// });
275
- // };
290
+ // };
0 commit comments