import React from 'react';
import { Row, Col } from 'react-bootstrap';
import { Card } from '../../../components';
import { hasPerm } from '../../session';
import CrudMessage from './crud-message';
import CrudPagination from './crud-pagination';
import CrudGrid from './crud-grid';
import CrudController from './crud-controller';
import CrudForm from './crud-form';
import CrudCounter from './crud-counter';
import CrudAddButton from './crud-add-button';
/**
* Aggregate all crud component offering a full stack crud editor
*/
export default class CrudView extends React.Component {
constructor(props) {
super(props);
this.openNewForm = this.openNewForm.bind(this);
}
componentWillMount() {
// the controller options
const opts = {
pageSize: this.props.pageSize,
readOnly: !hasPerm(this.props.perm),
editorSchema: this.props.editorSchema,
refreshAll: !!this.props.refreshAll,
remoteForm: this.props.remoteForm
};
const controller = new CrudController(this.props.crud, opts);
controller.initList(this.props.queryFilters);
this.setState({ controller: controller });
}
openNewForm() {
this.state.controller.openForm();
}
headerRender() {
const controller = this.state.controller;
let size = 12;
let btn;
if (!controller.isReadOnly()) {
btn = {this.props.title}
{
controller.getCount() > 0 &&