@@ -9,9 +9,22 @@ const initialState = fromJS(entity)
9
9
export default createReducer ( {
10
10
[ actions . addList ] : ( state , data ) => state . mergeDeep ( data ) ,
11
11
[ actions . addCard ] : ( state , data ) => state . mergeDeep ( data ) ,
12
- [ actions . removeCard ] : ( state , key ) => (
13
- state //.deleteIn(['card', key.get('index')]) // <-- unnecessary?
14
- . deleteIn ( [ 'list' , key . get ( 'listIndex' ) , 'card' ,
15
- state . getIn ( [ 'list' , key . get ( 'listIndex' ) , 'card' ] ) . indexOf ( key . get ( 'index' ) ) ] )
16
- )
12
+
13
+ [ actions . removeCard ] : ( state , data ) =>
14
+ state //.deleteIn(['card', data.get('index')]) // <-- unnecessary?
15
+ . deleteIn ( [ 'list' , data . get ( 'listIndex' ) , 'card' ,
16
+ state . getIn ( [ 'list' , data . get ( 'listIndex' ) , 'card' ] ) . indexOf ( data . get ( 'index' ) ) ] ) ,
17
+
18
+ [ actions . addSlot ] : ( state , data ) =>
19
+ state . setIn ( [ 'list' , data . get ( 'listIndex' ) , 'card' ] , data . get ( 'new' ) ) ,
20
+ [ actions . removeSlot ] : ( state , data ) => {
21
+ const index = state . getIn ( [ 'list' , data . get ( 'listIndex' ) , 'card' ] ) . indexOf ( 'slot' )
22
+ return index !== - 1 ? state . deleteIn ( [ 'list' , data . get ( 'listIndex' ) , 'card' , index ] ) : state
23
+ } ,
24
+
25
+
26
+ [ actions . moveCard ] : ( state , data ) =>
27
+ state . deleteIn ( [ 'list' , data . get ( 'fromListIndex' ) , 'card' ,
28
+ state . getIn ( [ 'list' , data . get ( 'fromListIndex' ) , 'card' ] ) . indexOf ( data . get ( 'index' ) ) ] )
29
+ . setIn ( [ 'list' , data . get ( 'toListIndex' ) , 'card' ] , data . get ( 'new' ) )
17
30
} , initialState )
0 commit comments