import './formControls.jsx'; import React from 'react' import SelectOption from 'widgets/form_controls/selectOption.jsx'; import imgAdd from '../../../node_modules/open-iconic/svg/plus.svg' import imgRemove from '../../../node_modules/open-iconic/svg/trash.svg' import TextInput from 'widgets/form_controls/textInput.jsx'; import Input from 'widgets/form_controls/input.jsx'; export class FormSection extends React.Component { render() { let className = 'FormSection ' + this.props.className; let html = (
{this.props.title}
{this.props.children}
); return html; } } FormSection.defaultProps = { className: '' } /** * AddItemFn: */ export class InputCollection extends React.Component { constructor(props) { super(props); this.collection = props.collection; } buildTextInput(onChange, v, i) { return ( ) } buildSelectOption(initial, options, onChange, v, i) { return ( ); } showInput() { } render() { const props = this.props; let inputType; let className = "InputCollection"; if (props.className) { className = `${className} ${props.className}`; } if (props.type == 'select') { inputType = this.buildSelectOption.bind(this, props.initial, props.options, props.onChange); } else { inputType = this.buildTextInput.bind(this, props.onChange) } let html = (
{props.collection.map((v,i) => { return (
{inputType(v, i)} { props.readonly ? null : Remove}
) })} { props.readonly ? null : Add}
); return html; } } InputCollection.defaultProps = { input: Input, collection: [], onChange: function(i, e) { console.log(` Updating with: ${e.target.value} At index of: ${i} `) }, AddItemFn: function(e) { console.log(`Adding a new item to collection`) }, RemoveItemFn: function(i, e) { console.log(`Removing item from collection at index of: ${i}`) } }