@@ -7,6 +7,7 @@ import MultiSelectBox from '@neos-project/react-ui-components/src/MultiSelectBox
7
7
import { selectors } from '@neos-project/neos-ui-redux-store' ;
8
8
import { neos } from '@neos-project/neos-ui-decorators' ;
9
9
import { shouldDisplaySearchBox , searchOptions , processSelectBoxOptions } from './SelectBoxHelpers' ;
10
+ import { createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue } from './createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue' ;
10
11
import PreviewOption from '../../Library/PreviewOption' ;
11
12
12
13
const getDataLoaderOptionsForProps = props => ( {
@@ -30,7 +31,17 @@ export default class DataSourceBasedSelectBoxEditor extends PureComponent {
30
31
className : PropTypes . string ,
31
32
value : PropTypes . oneOfType ( [
32
33
PropTypes . string ,
33
- PropTypes . arrayOf ( PropTypes . string )
34
+ PropTypes . arrayOf ( PropTypes . string ) ,
35
+ PropTypes . shape ( {
36
+ __identity : PropTypes . string . isRequired ,
37
+ __type : PropTypes . string
38
+ } ) ,
39
+ PropTypes . arrayOf (
40
+ PropTypes . shape ( {
41
+ __identity : PropTypes . string . isRequired ,
42
+ __type : PropTypes . string
43
+ } )
44
+ )
34
45
] ) ,
35
46
options : PropTypes . shape ( {
36
47
allowEmpty : PropTypes . bool ,
@@ -101,8 +112,23 @@ export default class DataSourceBasedSelectBoxEditor extends PureComponent {
101
112
} ) ;
102
113
}
103
114
115
+ get valueForSingleSelect ( ) {
116
+ const { value} = this . props ;
117
+ return createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue ( value ) ;
118
+ }
119
+
120
+ get valueForMultiSelect ( ) {
121
+ const { value} = this . props ;
122
+
123
+ if ( Array . isArray ( value ) ) {
124
+ return value . map ( createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue ) ;
125
+ }
126
+
127
+ return value ? [ createSelectBoxValueStringFromPossiblyStrangeNodePropertyValue ( value ) ] : [ ] ;
128
+ }
129
+
104
130
render ( ) {
105
- const { commit, value , i18nRegistry, className} = this . props ;
131
+ const { commit, i18nRegistry, className} = this . props ;
106
132
const options = Object . assign ( { } , this . constructor . defaultOptions , this . props . options ) ;
107
133
108
134
const processedSelectBoxOptions = processSelectBoxOptions ( i18nRegistry , this . state . selectBoxOptions ) ;
@@ -115,7 +141,7 @@ export default class DataSourceBasedSelectBoxEditor extends PureComponent {
115
141
return ( < MultiSelectBox
116
142
className = { className }
117
143
options = { processedSelectBoxOptions }
118
- values = { value || [ ] }
144
+ values = { this . valueForMultiSelect }
119
145
onValuesChange = { commit }
120
146
loadingLabel = { loadingLabel }
121
147
ListPreviewElement = { PreviewOption }
@@ -136,7 +162,7 @@ export default class DataSourceBasedSelectBoxEditor extends PureComponent {
136
162
return ( < SelectBox
137
163
className = { className }
138
164
options = { this . state . searchTerm ? searchOptions ( this . state . searchTerm , processedSelectBoxOptions ) : processedSelectBoxOptions }
139
- value = { value }
165
+ value = { this . valueForSingleSelect }
140
166
onValueChange = { commit }
141
167
loadingLabel = { loadingLabel }
142
168
ListPreviewElement = { PreviewOption }
0 commit comments