/** * File: header.js * Author: Markus Grigull * Date: 25.05.2018 * * This file is part of VILLASweb. * * VILLASweb is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VILLASweb 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VILLASweb. If not, see . ******************************************************************************/ import React from 'react'; import PropTypes from 'prop-types'; import { FormControl, Button } from 'react-bootstrap'; import Icon from './icon'; class EditableHeader extends React.Component { titleInput = null; constructor(props) { super(props); this.state = { editing: false, title: props.title }; } static getDerivedStateFromProps(props, state){ return { title: props.title }; } edit = () => { this.setState({ editing: true }); } save = () => { this.setState({ editing: false }); if (this.props.onChange != null) { this.props.onChange(this.state.title); } } cancel = () => { this.setState({ editing: false, title: this.props.title }); } onChange = event => { this.setState({ title: event.target.value }); } render() { const wrapperStyle= { float: 'left' }; const iconStyle = { float: 'left', marginLeft: '10px', marginTop: '25px', marginBottom: '20px' }; if (this.state.editing) { const editStyle = { maxWidth: '500px', marginTop: '10px' }; return
; } return

{this.state.title}

; } } EditableHeader.propTypes = { title: PropTypes.string.isRequired, onChange: PropTypes.func }; export default EditableHeader;