@@ -7,12 +7,8 @@ import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
77import ExpansionPanelActions from '@material-ui/core/ExpansionPanelActions' ;
88import Typography from '@material-ui/core/Typography' ;
99import Input from '@material-ui/core/Input' ;
10- import MenuItem from '@material-ui/core/MenuItem' ;
11- import RemoveCircleOutlineIcon from '@material-ui/icons/RemoveCircleOutline' ;
12- import ListItemText from '@material-ui/core/ListItemText' ;
1310import ExpandMoreIcon from '@material-ui/icons/ExpandMore' ;
1411import Switch from '@material-ui/core/Switch' ;
15- import Chip from '@material-ui/core/Chip' ;
1612import IconButton from '@material-ui/core/IconButton' ;
1713import DeleteIcon from '@material-ui/icons/Delete' ;
1814import FlipToBackIcon from '@material-ui/icons/FlipToBack' ;
@@ -32,13 +28,6 @@ const styles = theme => ({
3228 fontSize : theme . typography . pxToRem ( 15 ) ,
3329 fontWeight : theme . typography . fontWeightRegular ,
3430 } ,
35- chips : {
36- display : 'flex' ,
37- flexWrap : 'wrap' ,
38- } ,
39- chip : {
40- margin : theme . spacing . unit / 4 ,
41- } ,
4231 panel : {
4332 backgroundColor : '#333333' ,
4433 } ,
@@ -71,15 +60,6 @@ const styles = theme => ({
7160 group : {
7261 margin : `${ theme . spacing . unit } px 0` ,
7362 } ,
74- icon : {
75- fontSize : '20px' ,
76- color : '#000' ,
77- transition : 'all .2s ease' ,
78-
79- '&:hover' : {
80- color : 'red' ,
81- } ,
82- } ,
8363} ) ;
8464
8565const LeftColExpansionPanel = ( props ) => {
@@ -99,24 +79,23 @@ const LeftColExpansionPanel = (props) => {
9979 id,
10080 stateful,
10181 color,
102- parents,
103- parentIds,
82+ parent,
10483 selectableParents,
10584 } = component ;
10685
107- const handleParentChange = ( event , parentId = null ) => {
108- let newParentId = parentId ;
109- if ( event ) {
110- const selectedParents = event . target . value ;
111- newParentId = selectedParents [ selectedParents . length - 1 ] . id ;
112- }
113-
114- return updateComponent ( {
115- index ,
116- id ,
117- newParentId ,
118- } ) ;
119- } ;
86+ const parentOptions = [
87+ < option value = 'null' key = '' >
88+ None
89+ </ option > ,
90+ ... selectableParents . map (
91+ selectableParent => < option
92+ value = { selectableParent . id }
93+ key = { selectableParent . id }
94+ >
95+ { selectableParent . title }
96+ </ option > ,
97+ ) ,
98+ ] ;
12099
121100 return (
122101 < div className = { classes . root } >
@@ -151,35 +130,24 @@ const LeftColExpansionPanel = (props) => {
151130 />
152131 </ div >
153132 < div className = { classes . column } >
154- < InputLabel className = { classes . label } htmlFor = 'parentSelect' > selectedParents </ InputLabel >
133+ < InputLabel className = { classes . label } htmlFor = 'parentSelect' > Parent </ InputLabel >
155134 < Select
156135 className = { classes . light }
157- multiple
158- value = { parents }
136+ native
137+ value = { parent . id }
159138 id = 'parentSelect'
160139 name = 'parentName'
161- disabled = { selectableParents . length < 1 }
162- onChange = { handleParentChange }
163- input = { < Input id = 'parentSelect' /> }
164- renderValue = { selectedP => (
165- < div className = { classes . chips } >
166- { selectedP . map ( parent => (
167- < Chip
168- key = { parent . id }
169- label = { parent . title }
170- className = { classes . chip }
171- onDelete = { ( ) => handleParentChange ( null , parent . id ) }
172- deleteIcon = { < RemoveCircleOutlineIcon className = { classes . icon } /> }
173- />
174- ) ) }
175- </ div >
176- ) }
140+ onChange = { ( event ) => {
141+ const newParentId = event . target . value ;
142+ updateComponent ( {
143+ newParentId,
144+ index,
145+ id,
146+ parent,
147+ } ) ;
148+ } }
177149 >
178- { selectableParents . map ( parentObj => (
179- < MenuItem key = { parentObj . id } value = { parentObj } >
180- < ListItemText primary = { parentObj . title } />
181- </ MenuItem >
182- ) ) }
150+ { parentOptions }
183151 </ Select >
184152 </ div >
185153 </ ExpansionPanelDetails >
@@ -205,7 +173,7 @@ const LeftColExpansionPanel = (props) => {
205173 className = { classes . button }
206174 onClick = { ( ) => {
207175 deleteComponent ( {
208- index, id, parentIds ,
176+ index, id, parent ,
209177 } ) ;
210178 } }
211179 aria-label = 'Delete' >
0 commit comments