import React from 'react'; import ReactCSSTransitionGroup from 'react-addons-css-transition-group'; import { MenuBar } from './menubar'; import { Container, FormBuilder, NgIf, Icon, Fab } from '../../components/'; import './formviewer.scss'; export class FormViewer extends React.Component { constructor(props){ super(props); this.state = { form: {} }; } componentDidMount(){ this.setState({form: JSON.parse(this.props.content)}); } onChange(){ this.setState({refresh: Math.random()}); if(JSON.stringify(this.state.form) === this.props.content){ this.props.needSavingUpdate(false); } else { this.props.needSavingUpdate(true); } } save(){ if(this.props.needSaving === false) return; let blob = new window.Blob([JSON.stringify(this.state.form)], {type : 'text/plain'}); return this.props .onSave(blob) .then(() => this.props.needSavingUpdate(false)); } render(){ return (
{ return ( ); }}/>
); } }