How to use the @jsonforms/core.update 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 / material-tree-renderer / src / tree / dnd.util.ts View on Github external
// Remove moved data from source array
  dispatch(
    update(oldParentPath, array => {
      // TODO clone necessary?
      const clonedArray = clone(array);
      clonedArray.splice(oldIndex, 1);

      console.log(`remove from ${oldParentPath}, index: ${oldIndex}`);

      return clonedArray;
    })
  );

  // Add moved data to target array
  dispatch(
    update(newParentPath, array => {
      if (array === undefined || array === null || array.length === 0) {
        return [data];
      }

      // TODO clone necessary?
      const clonedArray = clone(array);
      clonedArray.splice(newIndex, 0, data);

      console.log(`add to ${newParentPath}, index: ${newIndex}`);

      return clonedArray;
    })
  );

  return true;
};
github eclipsesource / jsonforms / packages / material-tree-renderer / src / tree / ObjectListItem.tsx View on Github external
remove() {
      dispatch(
        update(
          parentPath,
          array => {
            const clonedArray = clone(array);
            clonedArray.splice(index, 1);
            return clonedArray;
          }
        )
      );
    },
    moveListItem: moveListItem(dispatch)
github eclipsesource / jsonforms / packages / react / src / JsonFormsContext.tsx View on Github external
handleChange: useCallback((path, value) => {
    dispatch(update(path, () => value));
  }, [dispatch, update])
});
github eclipsesource / jsonforms / packages / material / src / layouts / ExpandPanelRenderer.tsx View on Github external
moveDown: (path: string, toMove: number) => (event: any): void => {
    event.stopPropagation();
    dispatch(
      update(path, array => {
        moveDown(array, toMove);
        return array;
      })
    );
  }
});
github eclipsesource / jsonforms / packages / vanilla / src / additional / tree / Dialog.tsx View on Github external
add(path, prop, newData) {
      dispatch(
        update(
          Paths.compose(path, prop.property),
          array => {
            if (_.isEmpty(array)) {
              return [newData];
            }
            array.push(newData);

            return array;
          }
        )
      );
    }
});
github eclipsesource / jsonforms / packages / material / src / layouts / ExpandPanelRenderer.tsx View on Github external
removeItems: (path: string, toDelete: number[]) => (event: any): void => {
    event.stopPropagation();
    dispatch(
      update(path, array => {
        toDelete
          .sort()
          .reverse()
          .forEach(s => array.splice(s, 1));
        return array;
      })
    );
  },
  moveUp: (path: string, toMove: number) => (event: any): void => {
github eclipsesource / jsonforms / packages / material / src / complex / table-array.control.tsx View on Github external
addNewItem(path: string) {
    const element = {};
    this.props.dispatch(
      update(
        path,
        array => {
          if (array === undefined || array === null) {
            return [element];
          }

          const clone = _.clone(array);
          clone.push(element);

          return clone;
        }
      )
    );
  }
github eclipsesource / jsonforms / packages / editor / src / tree / Dialog.tsx View on Github external
add(path, prop, newData) {
      dispatch(
        update(
          Paths.compose(path, prop.property),
          array => {
            if (_.isEmpty(array)) {
              return [newData];
            }
            array.push(newData);

            return array;
          }
        )
      );
    }
});
github eclipsesource / jsonforms / packages / material-tree-renderer / src / tree / AddItemDialog.tsx View on Github external
add(path: string, prop: Property, newData: any) {
        dispatch(
            update(
                Paths.compose(path, prop.property),
                array => {
                    if (isEmpty(array)) {
                        return [newData];
                    }
                    array.push(newData);

                    return array;
                }
            )
        );
    }
});