Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onClick={() => {
const newData = _.keys(prop.schema.properties).reduce(
(d, key) => {
if (prop.schema.properties[key].default) {
d[key] = prop.schema.properties[key].default;
}
// FIXME generate id if identifying property is set in editor to allow id refs
return d;
},
{}
);
const arrayPath = Paths.compose(path, prop.property);
const array = Resolve.data(rootData, arrayPath) as any[];
const selectionIndex = _.isEmpty(array) ? 0 : array.length;
const selectionPath = Paths.compose(arrayPath, selectionIndex.toString());
add(path, prop, newData);
setSelection(prop.schema, newData, selectionPath)();
closeDialog();
}}
>
onClick = (prop: Property) => {
const { add, closeDialog, defaultData, path, rootData, setSelection } = this.props;
const newData = createData(defaultData, prop);
const arrayPath = Paths.compose(path, prop.property);
const array = Resolve.data(rootData, arrayPath) as any[];
const selectionIndex = isEmpty(array) ? 0 : array.length;
const selectionPath = Paths.compose(arrayPath, selectionIndex.toString());
add(path, prop, newData);
setSelection(prop.schema, newData, selectionPath)();
closeDialog();
};
? ownProps.visible
: Runtime.isVisible(ownProps.uischema, rootData);
const enabled = ownProps.enabled !== undefined
? ownProps.enabled
: Runtime.isEnabled(ownProps.uischema, rootData);
const rootSchema = getSchema(state);
const resolvedSchema = Resolve.schema(
ownProps.schema,
ownProps.uischema.scope,
rootSchema
);
return {
rootData: getData(state),
label: get(ownProps.uischema, 'label') as string,
data: Resolve.data(rootData, path),
uischema: ownProps.uischema,
schema: resolvedSchema || rootSchema,
uischemas: state.jsonforms.uischemas,
path,
visible,
enabled,
filterPredicate: ownProps.filterPredicate,
imageProvider: ownProps.imageProvider,
labelProviders: ownProps.labelProviders,
rootSchema: getSchema(state),
id: createId('tree'),
errors: formatErrorMessage(
union(
getErrorAt(path, resolvedSchema || rootSchema)(state).map(
error => error.message
)
render() {
const {
uischema,
schema,
resolvedSchema,
visible,
path,
rootData,
addToRoot,
getStyleAsClassName
} = this.props;
const controlElement = uischema as MasterDetailLayout;
const dialogProps = {
open: this.state.dialog.open
};
const resolvedRootData = Resolve.data(rootData, path);
const handlers = {
onSelect: this.setSelection,
onAdd: this.openDialog,
};
return (
<div hidden="{!visible}">
<div>
<label>
{typeof controlElement.label === 'string' ? controlElement.label : ''}
</label>
{
Array.isArray(resolvedRootData) &&
</div></div>
const mapStateToProps = (state, ownProps) => {
const path = Paths.compose(ownProps.path, Paths.fromScopable(ownProps.uischema));
const visible = _.has(ownProps, 'visible') ?
ownProps.visible : Runtime.isVisible(ownProps, state);
const enabled = _.has(ownProps, 'enabled') ?
ownProps.enabled : Runtime.isEnabled(ownProps, state);
const rootData = getData(state);
return {
rootData: getData(state),
resolvedRootData: Resolve.data(rootData, path),
uischema: ownProps.uischema,
schema: ownProps.schema,
resolvedSchema: Resolve.schema(ownProps.schema, ownProps.uischema.scope.$ref),
path,
visible,
enabled,
getStyle: findStyle(state),
getStyleAsClassName: findStyleAsClassName(state),
};
};
): ComponentType => ({
ctx,
props
}: JsonFormsStateContext & ExpandPanelProps) => {
const dispatchProps = ctxDispatchToExpandPanelProps(ctx.dispatch);
const { childLabelProp, schema, path, index, uischemas } = props;
const childPath = composePaths(path, `${index}`);
const childData = Resolve.data(ctx.core.data, childPath);
const childLabel = childLabelProp
? get(childData, childLabelProp, '')
: get(childData, getFirstPrimitiveProp(schema), '');
return (
);
};