How to use the @jsonforms/core.Resolve.data function in @jsonforms/core

To help you get started, we’ve selected a few @jsonforms/core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eclipsesource / jsonforms / packages / editor / src / tree / Dialog.tsx View on Github external
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();
                }}
              >
github eclipsesource / jsonforms / packages / material-tree-renderer / src / tree / AddItemDialog.tsx View on Github external
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();
    };
github eclipsesource / jsonforms / packages / material-tree-renderer / src / tree / TreeWithDetailRenderer.tsx View on Github external
? 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
        )
github eclipsesource / jsonforms / packages / vanilla / src / additional / tree / TreeRenderer.tsx View on Github external
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) &amp;&amp;
            </div></div>
github eclipsesource / jsonforms / packages / vanilla / src / additional / tree / TreeRenderer.tsx View on Github external
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),
  };
};
github eclipsesource / jsonforms / packages / material / src / layouts / ExpandPanelRenderer.tsx View on Github external
): ComponentType =&gt; ({
  ctx,
  props
}: JsonFormsStateContext &amp; ExpandPanelProps) =&gt; {
  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 (
    
  );
};