/* * Copyright 2007-2017 Charles du Jeu - Abstrium SAS * This file is part of Pydio. * * Pydio is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Pydio is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with Pydio. If not, see . * * The latest code can be found at . */ 'use strict'; exports.__esModule = true; function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } var _mixinsFormMixin = require('../mixins/FormMixin'); var _mixinsFormMixin2 = _interopRequireDefault(_mixinsFormMixin); var React = require('react'); var _require = require('material-ui'); var Toggle = _require.Toggle; /** * Boolean input */ exports['default'] = React.createClass({ displayName: 'InputBoolean', mixins: [_mixinsFormMixin2['default']], getDefaultProps: function getDefaultProps() { return { skipBufferChanges: true }; }, onCheck: function onCheck(event, newValue) { this.props.onChange(newValue, this.state.value); this.setState({ dirty: true, value: newValue }); }, getBooleanState: function getBooleanState() { var boolVal = this.state.value; if (typeof boolVal === 'string') { boolVal = boolVal == "true"; } return boolVal; }, render: function render() { var boolVal = this.getBooleanState(); return React.createElement( 'span', null, React.createElement(Toggle, { toggled: boolVal, onToggle: this.onCheck, disabled: this.props.disabled, label: this.isDisplayForm() ? this.props.attributes.label : null, labelPosition: this.isDisplayForm() ? 'left' : 'right' }) ); } }); module.exports = exports['default'];