Skip to content

Commit af2f3f5

Browse files
cleanup
1 parent 59f36c4 commit af2f3f5

File tree

1 file changed

+37
-39
lines changed

1 file changed

+37
-39
lines changed

src/components/SortChildren.jsx

Lines changed: 37 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
import React, { Component } from 'react';
44
import { connect } from 'react-redux';
5-
import { updateChildrenSort } from '../actions/components';
65
import { width } from 'window-size';
6+
import { updateChildrenSort } from '../actions/components';
77
import cloneDeep from '../utils/cloneDeep';
88

99
const mapStateToProps = store => ({
@@ -25,9 +25,10 @@ class SortChildren extends Component {
2525
} // end constrcutor
2626

2727
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+
}));
3132
return localArray;
3233
};
3334

@@ -63,11 +64,12 @@ class SortChildren extends Component {
6364
// put back the dragge item after the dragged Over
6465
currentSortValues.splice(this.state.draggedOverIndex, 0, draggedBaby);
6566

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+
}));
6971

70-
console.log(`currentSortValues after updating the sort `, JSON.stringify(currentSortValues));
72+
console.log('currentSortValues after updating the sort ', JSON.stringify(currentSortValues));
7173

7274
this.props.updateChildrenSort({ newSortValues: currentSortValues });
7375

@@ -90,25 +92,23 @@ class SortChildren extends Component {
9092
lineHeight: 1,
9193
cursor: 'move',
9294
};
93-
//const children = this.props.focusComponent.childrenArray;
95+
// const children = this.props.focusComponent.childrenArray;
9496
// const List = children
9597
const List = cloneDeep(this.props.focusComponent.childrenArray)
9698
.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+
));
112112
return (
113113
<div
114114
style={{
@@ -123,21 +123,19 @@ class SortChildren extends Component {
123123
<ul style={ulStyle}>
124124
{cloneDeep(this.props.focusComponent.childrenArray)
125125
.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+
))}
141139

142140
{/* {List} */}
143141
</ul>

0 commit comments

Comments
 (0)