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([
'react',
'react-dom',
'jquery',
'underscore',
'select2',
],
(
React,
ReactDOM,
jQuery,
_
) => {
import React from 'react';
import jQuery from 'jquery';
import _ from 'underscore';
import 'react-dom';
import 'select2';
const Selection = React.createClass({
allowMultipleValues: function allowMultipleValues() {
return (this.props.field.multiple === true);
@@ -230,14 +223,14 @@ define([
render: function render() {
const items = this.getItems(this.props.field);
const selectedValues = this.getSelectedValues();
const options = items.map((item, index) => {
const options = items.map((item) => {
const label = this.getLabel(item);
const searchLabel = this.getSearchLabel(item);
const value = this.getValue(item);
return (
<option
key={`option-${index}`}
key={`option-${item.id}`}
className="default"
value={value}
title={searchLabel}
@@ -265,5 +258,4 @@ define([
},
});
return Selection;
});
export default Selection;