ES6 assets/js/src/form/fields/selection.jsx

This commit is contained in:
Amine Ben hammou
2018-04-18 15:53:11 +02:00
parent bcb1f7e289
commit 788362f5b8

View File

@@ -1,16 +1,9 @@
define([ import React from 'react';
'react', import jQuery from 'jquery';
'react-dom', import _ from 'underscore';
'jquery', import 'react-dom';
'underscore', import 'select2';
'select2',
],
(
React,
ReactDOM,
jQuery,
_
) => {
const Selection = React.createClass({ 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}
@@ -265,5 +258,4 @@ define([
}, },
}); });
return Selection; export default Selection;
});