1
1
import {
2
+ < << << << HEAD
2
3
ComponentInt , ComponentsInt , PropInt , ChildInt , Action , ApplicationStateInt , LoadInitData , AddComponent
4
+ = === ===
5
+ ComponentInt ,
6
+ ComponentsInt ,
7
+ PropInt ,
8
+ ChildInt ,
9
+ Action ,
10
+ ApplicationStateInt
11
+ > >>> >>> f83af9065420b5f7bd3ed2f414d8f7aa2045dce7
3
12
} from '../utils/Interfaces.ts' ;
4
13
5
14
import {
@@ -9,6 +18,7 @@ import {
9
18
DELETE_CHILD ,
10
19
DELETE_COMPONENT ,
11
20
TOGGLE_STATE ,
21
+ TOGGLE_CLASS ,
12
22
CHANGE_FOCUS_COMPONENT ,
13
23
CHANGE_FOCUS_CHILD ,
14
24
CHANGE_COMPONENT_FOCUS_CHILD ,
@@ -36,18 +46,24 @@ import createApplicationUtil from '../utils/createApplication.util.ts';
36
46
37
47
export const changeImagePath = ( imageSource : string ) => ( {
38
48
type : CHANGE_IMAGE_SOURCE ,
39
- payload : { imageSource } ,
40
- } )
49
+ payload : { imageSource }
50
+ } ) ;
41
51
52
+ < < < << << HEAD
42
53
export const loadInitData = ( ) => ( dispatch : any ) => {
43
54
loadState ( ) . then ( ( data : any ) => {
55
+ = === ===
56
+ export const loadInitData = ( ) => ( dispatch : ( arg : Action ) => void ) => {
57
+ loadState ( ) . then ( ( data : ApplicationStateInt ) => {
58
+ console . log ( 'data.workspace' , data . workspace ) ;
59
+ > >>> >>> f83af9065420b5f7bd3ed2f414d8f7aa2045dce7
44
60
dispatch ( {
45
- type : LOAD_INIT_DATA ,
46
- payload : {
47
- data : data ? data . workspace : { } ,
48
- } ,
61
+ type : LOAD_INIT_DATA ,
62
+ payload : {
63
+ data : data ? data . workspace : { }
64
+ }
65
+ } ) ;
49
66
} ) ;
50
- } ) ;
51
67
} ;
52
68
53
69
export const addComponent = ( { title } : { title : string } ) => ( dispatch : ( arg : AddComponent ) => void ) => {
@@ -59,9 +75,9 @@ export const addChild = ({
59
75
childType,
60
76
HTMLInfo
61
77
} : {
62
- title : string ;
63
- childType : string ;
64
- HTMLInfo : object ;
78
+ title : string ;
79
+ childType : string ;
80
+ HTMLInfo : object ;
65
81
} ) => ( dispatch : ( arg : Action ) => void ) => {
66
82
dispatch ( { type : ADD_CHILD , payload : { title, childType, HTMLInfo } } ) ;
67
83
} ;
@@ -75,8 +91,8 @@ export const deleteComponent = ({
75
91
componentId,
76
92
stateComponents
77
93
} : {
78
- componentId : number ;
79
- stateComponents : ComponentsInt ;
94
+ componentId : number ;
95
+ stateComponents : ComponentsInt ;
80
96
} ) => ( dispatch : ( arg : Action ) => void ) => {
81
97
// find all places where the "to be deleted" is a child and do what u gotta do
82
98
stateComponents . forEach ( ( parent : ComponentInt ) => {
@@ -100,21 +116,25 @@ stateComponents: ComponentsInt;
100
116
dispatch ( { type : DELETE_COMPONENT , payload : { componentId } } ) ;
101
117
} ;
102
118
103
- export const changeFocusComponent = ( { title } : { title : string } ) => ( dispatch : ( arg : Action ) => void ) => {
119
+ export const changeFocusComponent = ( { title } : { title : string } ) => (
120
+ dispatch : ( arg : Action ) => void
121
+ ) => {
104
122
dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title } } ) ;
105
123
} ;
106
124
107
125
// make sure childId is being sent in
108
- export const changeFocusChild = ( { childId } : { childId : number } ) => ( dispatch : ( arg : Action ) => void ) => {
126
+ export const changeFocusChild = ( { childId } : { childId : number } ) => (
127
+ dispatch : ( arg : Action ) => void
128
+ ) => {
109
129
dispatch ( { type : CHANGE_FOCUS_CHILD , payload : { childId } } ) ;
110
130
} ;
111
131
112
132
export const changeComponentFocusChild = ( {
113
133
componentId,
114
134
childId
115
135
} : {
116
- componentId : number ;
117
- childId : number ;
136
+ componentId : number ;
137
+ childId : number ;
118
138
} ) => ( dispatch : ( arg : Action ) => void ) => {
119
139
dispatch ( {
120
140
type : CHANGE_COMPONENT_FOCUS_CHILD ,
@@ -124,18 +144,18 @@ childId: number;
124
144
125
145
export const deleteImage = ( ) => ( {
126
146
type : DELETE_IMAGE
127
- } )
147
+ } ) ;
128
148
129
149
export const exportFiles = ( {
130
150
components,
131
151
path,
132
152
appName,
133
153
exportAppBool
134
154
} : {
135
- components : ComponentsInt ;
136
- path : string ;
137
- appName : string ;
138
- exportAppBool : boolean ;
155
+ components : ComponentsInt ;
156
+ path : string ;
157
+ appName : string ;
158
+ exportAppBool : boolean ;
139
159
} ) => ( dispatch : ( arg : Action ) => void ) => {
140
160
// this dispatch sets the global state property 'loading' to true until the createFiles call resolves below
141
161
dispatch ( {
@@ -185,11 +205,11 @@ export const createApplication = ({
185
205
appName = 'reactype_app' ,
186
206
exportAppBool
187
207
} : {
188
- path : string ;
189
- components : ComponentsInt ;
190
- genOption : number ;
191
- appName : string ;
192
- exportAppBool : boolean ;
208
+ path : string ;
209
+ components : ComponentsInt ;
210
+ genOption : number ;
211
+ appName : string ;
212
+ exportAppBool : boolean ;
193
213
} ) => ( dispatch : ( arg : Action ) => void ) => {
194
214
if ( genOption === 0 ) {
195
215
exportAppBool = false ;
@@ -209,7 +229,7 @@ exportAppBool: boolean;
209
229
createApplicationUtil ( {
210
230
path,
211
231
appName,
212
- genOption,
232
+ genOption
213
233
} )
214
234
. then ( ( ) => {
215
235
dispatch ( {
@@ -246,8 +266,12 @@ export const deleteProp = (propId: number) => (dispatch: (arg: Action) => void)
246
266
dispatch ( { type : DELETE_PROP , payload : propId } ) ;
247
267
} ;
248
268
249
- export const toggleComponentState = ( index : string ) => ( dispatch : ( arg : Action ) => void ) => {
250
- dispatch ( { type : TOGGLE_STATE , payload : index } ) ;
269
+ export const toggleComponentState = ( id : string ) => ( dispatch : ( arg : Action ) => void ) => {
270
+ dispatch ( { type : TOGGLE_STATE , payload : id } ) ;
271
+ } ;
272
+
273
+ export const toggleComponentClass = ( id : string ) => ( dispatch : ( arg : Action ) => void ) => {
274
+ dispatch ( { type : TOGGLE_CLASS , payload : id } ) ;
251
275
} ;
252
276
253
277
export const addProp = ( prop : PropInt ) => ( {
@@ -256,7 +280,7 @@ export const addProp = (prop: PropInt) => ({
256
280
} ) ;
257
281
258
282
export const updateHtmlAttr = ( { attr, value } : { attr : string ; value : string } ) => (
259
- dispatch : ( arg : Action ) => void ,
283
+ dispatch : ( arg : Action ) => void
260
284
) => {
261
285
dispatch ( {
262
286
type : UPDATE_HTML_ATTR ,
@@ -272,4 +296,4 @@ export const updateHtmlAttr = ({ attr, value }: { attr: string; value: string })
272
296
// type: UPDATE_CHILDREN_SORT,
273
297
// payload: { newSortValues },
274
298
// });
275
- // };
299
+ // };
0 commit comments