forked from blackjk3/react-form-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemobar.js
More file actions
60 lines (50 loc) · 1.51 KB
/
Copy pathdemobar.js
File metadata and controls
60 lines (50 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import React from "react";
import ElementStore from './src/stores/ElementStore';
import ReactFormGenerator from './src/form';
export default class Demobar extends React.Component {
constructor(props) {
super(props);
this.state = {
data: [],
previewVisible: false
}
ElementStore.listen(this._onChange.bind(this));
}
showPreview() {
this.setState({
previewVisible: true
})
}
closePreview() {
this.setState({
previewVisible: false
})
}
_onChange(data) {
this.setState({
data: data
});
}
render() {
var modalClass = 'modal';
if(this.state.previewVisible) {
modalClass += ' show';
}
return(
<div className="clearfix" style={{margin:'10px', width:'70%'}}>
<h4 className="pull-left">Preview</h4>
<button className="btn btn-primary pull-right" style={{ marginRight: '10px'}} onClick={this.showPreview.bind(this)}>Preview Generated Form</button>
<div className={modalClass}>
<div className="modal-dialog">
<div className="modal-content">
<ReactFormGenerator download_path="" back_action="" answer_data={{}} form_action="/" form_method="POST" data={this.state.data} />
<div className="modal-footer">
<button type="button" className="btn btn-default" data-dismiss="modal" onClick={this.closePreview.bind(this)}>Close</button>
</div>
</div>
</div>
</div>
</div>
);
}
}