Skip to content

Commit

Permalink
support defaults for nested objects;
Browse files Browse the repository at this point in the history
custom ExpansionPanel props
  • Loading branch information
sheppard committed Sep 29, 2022
1 parent 727231b commit 49b1af2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
13 changes: 8 additions & 5 deletions packages/app/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import outbox from '@wq/outbox';
import router from '@wq/router';
import spinner from './spinner';
import auth from './auth';
import defaults from './auth';
import defaults from './defaults';
import Mustache from 'mustache';
import deepcopy from 'deepcopy';
import { setIn } from 'formik';

var app = {
OFFLINE: 'offline',
Expand Down Expand Up @@ -908,10 +909,12 @@ async function _displayItem(ctx) {

var item;
if (mode == 'edit' && variant == 'new') {
item = {
...routeInfo.params,
...conf.defaults
};
item = {};
Object.entries({ ...routeInfo.params, ...conf.defaults }).forEach(
([key, value]) => {
item = setIn(item, key, value);
}
);
} else {
const localOnly = !app.config.loadMissingAsJson;
item = await model.find(itemid, localOnly);
Expand Down
10 changes: 8 additions & 2 deletions packages/material-web/src/components/ExpansionPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
import PropTypes from 'prop-types';

export default function ExpansionPanel({ summary, children, open, onToggle }) {
export default function ExpansionPanel({
summary,
children,
open,
onToggle,
...rest
}) {
let handleToggle;
if (onToggle) {
handleToggle = (evt, state) => onToggle(state);
}
return (
<MuiExpansionPanel expanded={open} onChange={handleToggle}>
<MuiExpansionPanel expanded={open} onChange={handleToggle} {...rest}>
<ExpansionPanelSummary expandIcon={<ExpandMoreIcon />}>
{summary}
</ExpansionPanelSummary>
Expand Down

0 comments on commit 49b1af2

Please sign in to comment.