ES6 assets/js/src/form/fields/selection.jsx
This commit is contained in:
@@ -1,17 +1,10 @@
|
|||||||
define([
|
import React from 'react';
|
||||||
'react',
|
import jQuery from 'jquery';
|
||||||
'react-dom',
|
import _ from 'underscore';
|
||||||
'jquery',
|
import 'react-dom';
|
||||||
'underscore',
|
import 'select2';
|
||||||
'select2',
|
|
||||||
],
|
const Selection = React.createClass({
|
||||||
(
|
|
||||||
React,
|
|
||||||
ReactDOM,
|
|
||||||
jQuery,
|
|
||||||
_
|
|
||||||
) => {
|
|
||||||
const Selection = React.createClass({
|
|
||||||
allowMultipleValues: function allowMultipleValues() {
|
allowMultipleValues: function allowMultipleValues() {
|
||||||
return (this.props.field.multiple === true);
|
return (this.props.field.multiple === true);
|
||||||
},
|
},
|
||||||
@@ -230,14 +223,14 @@ define([
|
|||||||
render: function render() {
|
render: function render() {
|
||||||
const items = this.getItems(this.props.field);
|
const items = this.getItems(this.props.field);
|
||||||
const selectedValues = this.getSelectedValues();
|
const selectedValues = this.getSelectedValues();
|
||||||
const options = items.map((item, index) => {
|
const options = items.map((item) => {
|
||||||
const label = this.getLabel(item);
|
const label = this.getLabel(item);
|
||||||
const searchLabel = this.getSearchLabel(item);
|
const searchLabel = this.getSearchLabel(item);
|
||||||
const value = this.getValue(item);
|
const value = this.getValue(item);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<option
|
<option
|
||||||
key={`option-${index}`}
|
key={`option-${item.id}`}
|
||||||
className="default"
|
className="default"
|
||||||
value={value}
|
value={value}
|
||||||
title={searchLabel}
|
title={searchLabel}
|
||||||
@@ -263,7 +256,6 @@ define([
|
|||||||
</select>
|
</select>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
});
|
|
||||||
|
|
||||||
return Selection;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export default Selection;
|
||||||
|
Reference in New Issue
Block a user