/* Usage: <%= react_component("PageLookupSidebar", {}) %> */ import React from "react" import PropTypes from "prop-types" import { makeStyles } from '@material-ui/core/styles'; import Drawer from '@material-ui/core/Drawer'; import List from '@material-ui/core/List'; import Divider from '@material-ui/core/Divider'; import ListItem from '@material-ui/core/ListItem'; import ListItemIcon from '@material-ui/core/ListItemIcon'; import ListItemText from '@material-ui/core/ListItemText'; import InboxIcon from '@material-ui/icons/MoveToInbox'; import MailIcon from '@material-ui/icons/Mail'; import Button from '@material-ui/core/Button'; import ListSubheader from '@material-ui/core/ListSubheader'; import ExpandLess from '@material-ui/icons/ExpandLess'; import ExpandMore from '@material-ui/icons/ExpandMore'; import StarBorder from '@material-ui/icons/StarBorder'; import Collapse from '@material-ui/core/Collapse'; class PageLookupSidebar extends React.Component { constructor(props) { super(props); this.state = { open: false, loading: false, show_data: false, category_open: {} }; } loadPage(page_type, page_id) { this.setDrawerVisible(true); // show loading icon // make api request // hide loading icon // load response into list this.setState({ page_data: { name: page_type + ' ' + 'Bob', categories: [ { id: 1, label: 'General', fields: [ { label: 'Name', value: 'Bob', type: 'text' }, { label: 'Age', value: '55', type: 'text' } ] }, { id: 2, label: 'Family', fields: [ { label: 'Mom', value: 'Robin', type: 'link', link: ['Character', 534] } ] } ] } }); console.log("setting show_data = true"); this.setState({ show_data: true }); // this.state.show_data = true; console.log("show data? " + this.state.show_data); }; setDrawerVisible(open) { this.setState({ open: open }); }; toggleCategoryOpen(category) { this.setState({ category_open: { [category]: !this.state.category_open[category] }}); } pageData() { if (this.state.show_data) { return (