Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for more robust duplication actions #554

Open
xaviemirmon opened this issue Aug 12, 2024 · 2 comments
Open

Allow for more robust duplication actions #554

xaviemirmon opened this issue Aug 12, 2024 · 2 comments

Comments

@xaviemirmon
Copy link
Contributor

          @chrisvxd  do we have any updates on this one ? 

Also is there any way to capture the duplicateEvent? The issue i'm facing is while duplicating the component it creating copy with same id value for it and hence when trying to update my db, it throws error as there is primary key constraint on the id column. I need some way to control this duplicate action.

Screenshot 2024-07-04 at 1 01 27 AM

Originally posted by @sagarchoudhary96 in #461 (comment)

@xaviemirmon
Copy link
Contributor Author

xaviemirmon commented Aug 12, 2024

In #461, @sagarchoudhary96 mentions the requirement for better handling/access to the duplication action.

I ran into problems similar to those in my implementation, which is leveraging additional metadata behind the scenes. Rather than exposing the entire Dropzone context and dispatch function, perhaps we can update the duplicate action to add a flag to the duplicated and change the ID such as isDuplicate={true}?

Then, when using the onPublish, we could alter the data/behaviour before sending the payload to the server. Are there any reasons we shouldn't just do this?

const newItem = {
  ...item,
  props: {
    ...item.props,
    id: generateId(item.type),
    // Track if the item is a duplicate
    isDuplicate: true
  },
};

@sagarchoudhary96 I am confused by the output you've provided in your screenshot. id is a string of {type}-{uuid} in the props object, not the main component object. Are you setting that value yourself somehow?

@xaviemirmon
Copy link
Contributor Author

Related to #538

I think the new onAction could solve some of these problems too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant