@@ -7,8 +7,12 @@ 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' ;
1013import ExpandMoreIcon from '@material-ui/icons/ExpandMore' ;
1114import Switch from '@material-ui/core/Switch' ;
15+ import Chip from '@material-ui/core/Chip' ;
1216import IconButton from '@material-ui/core/IconButton' ;
1317import DeleteIcon from '@material-ui/icons/Delete' ;
1418import FlipToBackIcon from '@material-ui/icons/FlipToBack' ;
@@ -28,6 +32,13 @@ const styles = theme => ({
2832 fontSize : theme . typography . pxToRem ( 15 ) ,
2933 fontWeight : theme . typography . fontWeightRegular ,
3034 } ,
35+ chips : {
36+ display : 'flex' ,
37+ flexWrap : 'wrap' ,
38+ } ,
39+ chip : {
40+ margin : theme . spacing . unit / 4 ,
41+ } ,
3142 panel : {
3243 backgroundColor : '#333333' ,
3344 } ,
@@ -60,6 +71,15 @@ const styles = theme => ({
6071 group : {
6172 margin : `${ theme . spacing . unit } px 0` ,
6273 } ,
74+ icon : {
75+ fontSize : '20px' ,
76+ color : '#000' ,
77+ transition : 'all .2s ease' ,
78+
79+ '&:hover' : {
80+ color : 'red' ,
81+ } ,
82+ } ,
6383} ) ;
6484
6585const LeftColExpansionPanel = ( props ) => {
@@ -79,23 +99,24 @@ const LeftColExpansionPanel = (props) => {
7999 id,
80100 stateful,
81101 color,
82- parent,
102+ parents,
103+ parentIds,
83104 selectableParents,
84105 } = component ;
85106
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- ] ;
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+ } ;
99120
100121 return (
101122 < div className = { classes . root } >
@@ -130,24 +151,35 @@ const LeftColExpansionPanel = (props) => {
130151 />
131152 </ div >
132153 < div className = { classes . column } >
133- < InputLabel className = { classes . label } htmlFor = 'parentSelect' > Parent </ InputLabel >
154+ < InputLabel className = { classes . label } htmlFor = 'parentSelect' > selectedParents </ InputLabel >
134155 < Select
135156 className = { classes . light }
136- native
137- value = { parent . id }
157+ multiple
158+ value = { parents }
138159 id = 'parentSelect'
139160 name = 'parentName'
140- onChange = { ( event ) => {
141- const newParentId = event . target . value ;
142- updateComponent ( {
143- newParentId,
144- index,
145- id,
146- parent,
147- } ) ;
148- } }
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+ ) }
149177 >
150- { parentOptions }
178+ { selectableParents . map ( parentObj => (
179+ < MenuItem key = { parentObj . id } value = { parentObj } >
180+ < ListItemText primary = { parentObj . title } />
181+ </ MenuItem >
182+ ) ) }
151183 </ Select >
152184 </ div >
153185 </ ExpansionPanelDetails >
@@ -173,7 +205,7 @@ const LeftColExpansionPanel = (props) => {
173205 className = { classes . button }
174206 onClick = { ( ) => {
175207 deleteComponent ( {
176- index, id, parent ,
208+ index, id, parentIds ,
177209 } ) ;
178210 } }
179211 aria-label = 'Delete' >
0 commit comments