2
2
3
3
import React , { Component } from 'react' ;
4
4
import { connect } from 'react-redux' ;
5
- import { updateChildrenSort } from '../actions/components' ;
6
5
import { width } from 'window-size' ;
6
+ import { updateChildrenSort } from '../actions/components' ;
7
7
import cloneDeep from '../utils/cloneDeep' ;
8
8
9
9
const mapStateToProps = store => ( {
@@ -25,9 +25,10 @@ class SortChildren extends Component {
25
25
} // end constrcutor
26
26
27
27
setLocalArray = ( ) => {
28
- const localArray = this . props . focusComponent . childrenArray . map ( ( child , idx ) => {
29
- return { childId : child . childId , childSort : child . childSort } ;
30
- } ) ;
28
+ const localArray = this . props . focusComponent . childrenArray . map ( ( child , idx ) => ( {
29
+ childId : child . childId ,
30
+ childSort : child . childSort ,
31
+ } ) ) ;
31
32
return localArray ;
32
33
} ;
33
34
@@ -63,11 +64,12 @@ class SortChildren extends Component {
63
64
// put back the dragge item after the dragged Over
64
65
currentSortValues . splice ( this . state . draggedOverIndex , 0 , draggedBaby ) ;
65
66
66
- currentSortValues = currentSortValues . map ( ( child , idx ) => {
67
- return { childId : child . childId , childSort : idx + 1 } ;
68
- } ) ;
67
+ currentSortValues = currentSortValues . map ( ( child , idx ) => ( {
68
+ childId : child . childId ,
69
+ childSort : idx + 1 ,
70
+ } ) ) ;
69
71
70
- console . log ( ` currentSortValues after updating the sort ` , JSON . stringify ( currentSortValues ) ) ;
72
+ console . log ( ' currentSortValues after updating the sort ' , JSON . stringify ( currentSortValues ) ) ;
71
73
72
74
this . props . updateChildrenSort ( { newSortValues : currentSortValues } ) ;
73
75
@@ -90,25 +92,23 @@ class SortChildren extends Component {
90
92
lineHeight : 1 ,
91
93
cursor : 'move' ,
92
94
} ;
93
- //const children = this.props.focusComponent.childrenArray;
95
+ // const children = this.props.focusComponent.childrenArray;
94
96
// const List = children
95
97
const List = cloneDeep ( this . props . focusComponent . childrenArray )
96
98
. sort ( ( a , b ) => a . childSort - b . childSort )
97
- . map ( ( child , idx ) => {
98
- return (
99
- < li style = { liStyle } id = { child . childId } key = { idx } >
100
- < div
101
- className = "drag"
102
- draggable
103
- onDragStart = { e => this . onDragStart ( e , idx ) }
104
- onDragOver = { e => this . onDragOver ( idx ) }
105
- onDragEnd = { e => this . onDragEnd ( ) }
106
- >
107
- { child . componentName + child . childId }
108
- </ div >
109
- </ li >
110
- ) ;
111
- } ) ;
99
+ . map ( ( child , idx ) => (
100
+ < li style = { liStyle } id = { child . childId } key = { idx } >
101
+ < div
102
+ className = "drag"
103
+ draggable
104
+ onDragStart = { e => this . onDragStart ( e , idx ) }
105
+ onDragOver = { e => this . onDragOver ( idx ) }
106
+ onDragEnd = { e => this . onDragEnd ( ) }
107
+ >
108
+ { child . componentName + child . childId }
109
+ </ div >
110
+ </ li >
111
+ ) ) ;
112
112
return (
113
113
< div
114
114
style = { {
@@ -123,21 +123,19 @@ class SortChildren extends Component {
123
123
< ul style = { ulStyle } >
124
124
{ cloneDeep ( this . props . focusComponent . childrenArray )
125
125
. sort ( ( a , b ) => a . childSort - b . childSort )
126
- . map ( ( child , idx ) => {
127
- return (
128
- < li style = { liStyle } id = { child . childId } key = { idx } >
129
- < div
130
- className = "drag"
131
- draggable
132
- onDragStart = { e => this . onDragStart ( e , idx ) }
133
- onDragOver = { e => this . onDragOver ( idx ) }
134
- onDragEnd = { e => this . onDragEnd ( ) }
135
- >
136
- { child . componentName + child . childId }
137
- </ div >
138
- </ li >
139
- ) ;
140
- } ) }
126
+ . map ( ( child , idx ) => (
127
+ < li style = { liStyle } id = { child . childId } key = { idx } >
128
+ < div
129
+ className = "drag"
130
+ draggable
131
+ onDragStart = { e => this . onDragStart ( e , idx ) }
132
+ onDragOver = { e => this . onDragOver ( idx ) }
133
+ onDragEnd = { e => this . onDragEnd ( ) }
134
+ >
135
+ { child . componentName + child . childId }
136
+ </ div >
137
+ </ li >
138
+ ) ) }
141
139
142
140
{ /* {List} */ }
143
141
</ ul >
0 commit comments