| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- import React from 'react';
- import PropTypes from 'prop-types';
- import {
- Modal, ModalHeader, ModalBody, ModalFooter,
- } from 'reactstrap';
- export default class GridEditModal extends React.PureComponent {
- constructor(props) {
- super(props);
- this.state = {
- show: false,
- gridHtml: '',
- };
- this.init = this.init.bind(this);
- this.show = this.show.bind(this);
- this.hide = this.hide.bind(this);
- this.cancel = this.cancel.bind(this);
- this.pasteCodedGrid = this.pasteCodedGrid.bind(this);
- }
- init(gridHtml) {
- const initGridHtml = gridHtml;
- this.setState({ gridHtml: initGridHtml }, function() {
- // display gridHtml for re-editing
- console.log(this.state.gridHtml);
- });
- }
- show(gridHtml) {
- this.init(gridHtml);
- this.setState({ show: true });
- }
- hide() {
- this.setState({ show: false });
- }
- cancel() {
- this.hide();
- }
- pasteCodedGrid() {
- // dummy data
- const pastedGridData = `::: editable-row\n<div class="container">\n <div class="row">
- <div class="col-sm-6 col-md-5 col-lg-12">dummy</div>\n </div>\n</div>\n:::`;
- if (this.props.onSave != null) {
- this.props.onSave(pastedGridData);
- }
- this.cancel();
- }
- render() {
- return (
- <Modal isOpen={this.state.show} toggle={this.cancel} size="xl">
- <ModalHeader tag="h4" toggle={this.cancel} className="bg-primary text-light">
- Create Bootstrap 4 Grid
- </ModalHeader>
- <ModalBody>
- </ModalBody>
- <ModalFooter className="grw-modal-footer">
- <div className="ml-auto">
- <button type="button" className="mr-2 btn btn-secondary" onClick={this.cancel}>Cancel</button>
- <button type="button" className="btn btn-primary" onClick={this.pasteCodedGrid}>Done</button>
- </div>
- </ModalFooter>
- </Modal>
- );
- }
- }
- GridEditModal.propTypes = {
- onSave: PropTypes.func,
- };
|