How to use the @bentley/ui-components.DropEffects.Copy function in @bentley/ui-components

To help you get started, we’ve selected a few @bentley/ui-components 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 imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / widgets / demodataproviders / demoTreeDataProvider.ts View on Github external
export const treeCanDropTargetDropCallback = (args: DropTargetArguments) => {
  // Ensure all important properties exist on dataObject
  if ("id" in args.dataObject && "type" in args.dataObject) {
    let id = ""; // keeps empty string if copying so it doesn't do ID checks for canDrop since the ID will change.
    const { id: originalId, label, description, icon, children, type, parentId } = args.dataObject;
    if (args.dropEffect !== DropEffects.Copy) {
      id = originalId; // Link means keep ID and old node, Move means keep ID and delete old node.
    }
    const dragNode: DelayLoadedTreeNodeItem = {
      id, label, description, hasChildren: children !== undefined && children.length > 0,
      parentId: typeof parentId === "string" ? parentId : undefined,
      extendedData: { id, label, description, icon, parentId: typeof parentId === "string" ? parentId : undefined, type, children },
    };
    if (args.dropLocation) {
      if ("id" in args.dropLocation && "extendedData" in args.dropLocation) {
        const dropNode: DelayLoadedTreeNodeItem = args.dropLocation;
        const exists = demoMutableTreeDataProvider.getNodeIndex(dropNode, dragNode) !== -1;
        if (!demoMutableTreeDataProvider.isDescendent(dragNode, dropNode)) {
          if (args.row !== undefined) {
            if (exists && parentId === args.dropLocation.id && args.dropEffect === DropEffects.Move) {
              return true;
            } else if (!exists) {
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / widgets / demodataproviders / demoTreeDataProvider.ts View on Github external
export const treeDropTargetDropCallback = (args: DropTargetArguments): DropTargetArguments => {
  // Ensure all important properties exist on dataObject
  if (args.dataObject && "id" in args.dataObject && "type" in args.dataObject) {
    const { id: originalId, label, description, icon, children, type, parentId, dataProvider } = args.dataObject;
    let id = "";
    if (args.dropEffect === DropEffects.Copy) {
      id = Math.round(Math.random() * 1e14) + ""; // Copy means new ID, don't delete old.
    } else {
      id = originalId; // Link means keep ID and old node, Move means keep ID and delete old node.
    }
    const dragNode: DelayLoadedTreeNodeItem = {
      id, label, description, icon, hasChildren: children !== undefined && children.length > 0,
      parentId: typeof parentId === "string" ? parentId : undefined,
      extendedData: { id, label, description, icon, parentId: typeof parentId === "string" ? parentId : undefined, type, children },
    };
    if (args.dropLocation) {
      let dropNode: DelayLoadedTreeNodeItem | undefined;
      if ("id" in args.dropLocation && "extendedData" in args.dropLocation)
        dropNode = args.dropLocation;
      const exists = dataProvider === demoMutableTreeDataProvider;
      if (!dropNode || ("id" in dropNode && !demoMutableTreeDataProvider.isDescendent(dragNode, dropNode))) {
        if (exists && args.dropEffect === DropEffects.Move) {
github imodeljs / imodeljs / test-apps / ui-test-app / src / frontend / appui / widgets / demodataproviders / demoTableDataProvider.ts View on Github external
export const onDropTargetDrop = (args: DropTargetArguments) => {
  if (args.dataObject && "type" in args.dataObject && "label" in args.dataObject && "description" in args.dataObject) {
    const { type, label, description, parentId, dataProvider, children, icon, ...rest } = args.dataObject;
    let id = "";
    if (args.dropEffect === DropEffects.Copy) {
      id = Math.round(Math.random() * 1e14) + "";
    } else if ((args.dropEffect === DropEffects.Move || args.dropEffect === DropEffects.Link) &&
      "id" in args.dataObject && args.dataObject.id !== undefined) {
      id = args.dataObject.id;
    }

    const dragRow: RowItem = {
      key: id,
      extendedData: {
        id, label, icon, type, description, parentId, dataProvider, ...rest,
      },
      cells: [
        {
          key: "label", record: new PropertyRecord(
            {
              value: label,