import React, { Component } from 'react'; import { Form } from 'react-bootstrap'; import ReactDOM from 'react-dom'; export default class SettingsInput extends Component { constructor(props) { super(props) this.state = { type: this.props.type, name: this.props.name, displayName: (this.props.name) ? this.formatName(this.props.name) : '', value: (this.props.value) ? this.props.value : '', classes: this.props.classes, id: this.props.id, label: (this.props.label) ? this.props.label : false, readonly: true, description: (this.props.description) ? this.props.description : false, options: this.props.options ? this.props.options : [], hideDescription: this.props.hideDescription ? true : false, min: this.props.min ? this.props.min : null, max: this.props.max ? this.props.max : null, url: this.props.url, inline: this.props.inline ? 'd-inline-block' : 'd-block', btnType: this.props.btnType, earlyReturn: this.props.earlyReturn ? true : false, autoComplete: String(this.props.autoComplete ? true : Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 7)), } } componentDidMount() { this.setState({ readonly: this.isReadOnly() }); } formatName(name) { name = name.split('_').join(' '); return name.charAt(0).toUpperCase() + name.slice(1); } handleInput = (evt) => { var val = evt.target.value; if(this.state.type === 'checkbox') { val = evt.target.checked; } this.props.handler( this.state.name, val ); this.setState({ value: val }); } isReadOnly = () => { if(window.config.editable[this.state.name] == false) { return true; } return false; } generateNumberInput(disabled) { return