@@ -25,56 +25,54 @@ import {
25
25
DELETE_PROP ,
26
26
ADD_PROP ,
27
27
DELETE_ALL_DATA ,
28
- CHANGE_IMAGE_PATH
29
- } from " ../actionTypes/index" ;
28
+ CHANGE_IMAGE_PATH ,
29
+ } from ' ../actionTypes/index' ;
30
30
31
- import { loadState } from " ../localStorage" ;
31
+ import { loadState } from ' ../localStorage' ;
32
32
33
33
// import createFiles from '../utils/createFiles.util';
34
34
// import createApplicationUtil from '../utils/createApplication.util';
35
35
36
- export const loadInitData = ( ) => dispatch => {
37
- loadState ( ) . then ( data =>
38
- dispatch ( {
39
- type : LOAD_INIT_DATA ,
40
- payload : {
41
- data : data ? data . workspace : { }
42
- }
43
- } )
44
- ) ;
36
+ export const loadInitData = ( ) => ( dispatch ) => {
37
+ loadState ( ) . then ( data => dispatch ( {
38
+ type : LOAD_INIT_DATA ,
39
+ payload : {
40
+ data : data ? data . workspace : { } ,
41
+ } ,
42
+ } ) ) ;
45
43
} ;
46
44
47
45
export const updateChildren = ( { parentIds, childIndex, childId } ) => ( {
48
46
type : UPDATE_CHILDREN ,
49
47
payload : {
50
48
parentIds,
51
49
childIndex,
52
- childId
53
- }
50
+ childId,
51
+ } ,
54
52
} ) ;
55
53
56
54
export const parentReassignment = ( { index, id, parentIds } ) => ( {
57
55
type : REASSIGN_PARENT ,
58
56
payload : {
59
57
index,
60
58
id,
61
- parentIds
62
- }
59
+ parentIds,
60
+ } ,
63
61
} ) ;
64
62
65
- export const addComponent = ( { title } ) => dispatch => {
63
+ export const addComponent = ( { title } ) => ( dispatch ) => {
66
64
dispatch ( { type : ADD_COMPONENT , payload : { title } } ) ;
67
65
} ;
68
66
69
- export const addChild = ( { title } ) => dispatch => {
67
+ export const addChild = ( { title } ) => ( dispatch ) => {
70
68
dispatch ( { type : ADD_CHILD , payload : { title } } ) ;
71
69
} ;
72
70
73
- export const deleteChild = ( { title } ) => dispatch => {
71
+ export const deleteChild = ( { title } ) => ( dispatch ) => {
74
72
dispatch ( { type : DELETE_CHILD , payload : { title } } ) ;
75
73
} ;
76
74
77
- export const deleteComponent = ( { index, id, parentIds = [ ] } ) => dispatch => {
75
+ export const deleteComponent = ( { index, id, parentIds = [ ] } ) => ( dispatch ) => {
78
76
if ( parentIds . length ) {
79
77
// Delete Component from its parent if it has a parent.
80
78
dispatch ( updateChildren ( { parentIds, childId : id , childIndex : index } ) ) ;
@@ -91,38 +89,38 @@ export const updateComponent = ({
91
89
index,
92
90
newParentId = null ,
93
91
color = null ,
94
- stateful = null
95
- } ) => dispatch => {
92
+ stateful = null ,
93
+ } ) => ( dispatch ) => {
96
94
dispatch ( {
97
95
type : UPDATE_COMPONENT ,
98
96
payload : {
99
97
id,
100
98
index,
101
99
newParentId,
102
100
color,
103
- stateful
104
- }
101
+ stateful,
102
+ } ,
105
103
} ) ;
106
104
107
105
if ( newParentId ) {
108
106
dispatch (
109
107
updateChildren ( {
110
108
parentIds : [ newParentId ] ,
111
109
childId : id ,
112
- childIndex : index
113
- } )
110
+ childIndex : index ,
111
+ } ) ,
114
112
) ;
115
113
}
116
114
117
115
dispatch ( { type : SET_SELECTABLE_PARENTS } ) ;
118
116
} ;
119
117
120
- export const changeFocusComponent = ( { title } ) => dispatch => {
118
+ export const changeFocusComponent = ( { title } ) => ( dispatch ) => {
121
119
dispatch ( { type : CHANGE_FOCUS_COMPONENT , payload : { title } } ) ;
122
120
} ;
123
121
124
122
// make sure childId is being sent in
125
- export const changeFocusChild = ( { title, childId } ) => dispatch => {
123
+ export const changeFocusChild = ( { title, childId } ) => ( dispatch ) => {
126
124
dispatch ( { type : CHANGE_FOCUS_CHILD , payload : { title, childId } } ) ;
127
125
} ;
128
126
@@ -144,23 +142,21 @@ export const changeFocusChild = ({ title, childId }) => dispatch => {
144
142
145
143
export const handleClose = ( ) => ( {
146
144
type : HANDLE_CLOSE ,
147
- payload : false
145
+ payload : false ,
148
146
} ) ;
149
147
150
- export const handleTransform = (
151
- componentId ,
152
- childId ,
153
- { x, y, width, height }
154
- ) => ( {
148
+ export const handleTransform = ( componentId , childId , {
149
+ x, y, width, height,
150
+ } ) => ( {
155
151
type : HANDLE_TRANSFORM ,
156
152
payload : {
157
153
componentId,
158
154
childId,
159
155
x,
160
156
y,
161
157
width,
162
- height
163
- }
158
+ height,
159
+ } ,
164
160
} ) ;
165
161
166
162
// export const createApplication = ({
@@ -190,7 +186,7 @@ export const handleTransform = (
190
186
191
187
export const toggleDragging = status => ( {
192
188
type : TOGGLE_DRAGGING ,
193
- payload : status
189
+ payload : status ,
194
190
} ) ;
195
191
196
192
// export const moveToBottom = componentId => ({
@@ -205,7 +201,7 @@ export const toggleDragging = status => ({
205
201
206
202
export const openExpansionPanel = component => ( {
207
203
type : OPEN_EXPANSION_PANEL ,
208
- payload : { component }
204
+ payload : { component } ,
209
205
} ) ;
210
206
211
207
// export const deleteAllData = () => ({
0 commit comments