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
\n\t
\n${convertedHTML}\n\t
\n
\n:::`; // display converted html on console console.log(convertedHTML); if (this.props.onSave != null) { this.props.onSave(pastedGridData); } this.cancel(); } gridDivisionMenu() { const gridDivisions = geu.mappingAllGridDivisionPatterns; return (
{gridDivisions.map((gridDivion, i) => { return (
{gridDivion.numberOfGridDivisions}分割
{gridDivion.mapping.map((gridOneDivision) => { return ( ); })}
); })}
); } render() { return ( Create Bootstrap 4 Grid
{this.gridDivisionMenu()}
{/* TODO unite radio button style with that of AppSetting.jsx by GW-3342 */} { this.checkResposiveSize(e.target.value) }} checked={this.state.responsiveSize === BootstrapGrid.ResponsiveSize.XS_SIZE} />
{ this.checkResposiveSize(e.target.value) }} checked={this.state.responsiveSize === BootstrapGrid.ResponsiveSize.SM_SIZE} />
{ this.checkResposiveSize(e.target.value) }} checked={this.state.responsiveSize === BootstrapGrid.ResponsiveSize.MD_SIZE} />

Preview

); } } GridEditModal.propTypes = { onSave: PropTypes.func, };