import React from 'react'; import PropTypes from 'prop-types'; import { Modal, ModalHeader, ModalBody, ModalFooter, } from 'reactstrap'; import geu from './GridEditorUtil'; import BootstrapGrid from '../../models/BootstrapGrid'; export default class GridEditModal extends React.Component { constructor(props) { super(props); this.state = { colsRatios: [6, 6], responsiveSize: BootstrapGrid.ResponsiveSize.XS_SIZE, 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); this.showGridPattern = this.showGridPattern.bind(this); this.checkResposiveSize = this.checkResposiveSize.bind(this); } async checkResposiveSize(rs) { await this.setState({ responsiveSize: rs }); } async checkColsRatios(cr) { await this.setState({ colsRatios: cr }); } showGridPattern() { const colsRatios = this.state.colsRatios; return colsRatios.join(' - '); } 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 convertedHTML = geu.convertRatiosAndSizeToHTML([1, 5, 6], 'sm'); const pastedGridData = `::: editable-row\n