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

[5.x] Ability to cut/copy/paste replicator sets #10359

Open
wants to merge 10 commits into
base: 5.x
Choose a base branch
from

Conversation

jacksleight
Copy link
Contributor

@jacksleight jacksleight commented Jun 24, 2024

This PR adds the ability to cut/copy/paste sets between different replicators/pages/tabs:

CleanShot.2024-07-12.at.16.59.51.mp4

Notes

  • Replicators use a list of set config hashes to decide whether the set being copied is compatible with the target replicator.
  • Due to its limitations this does not use the Clipboard API. Instead, within the current page the data is stored in a vue component (for reactivity), and local storage is used to persist it between pages/tabs (session storage isn’t suitable as it doesn’t work between tabs).
  • Since local storage has no expiry but you don’t want copied values hanging around forever a unique ID stored in a session cookie is attached to the data, so it can be cleared when a new session is started.
  • There's a new $clipboard object that takes care of all the data storage and tracking, this means it should be fairly straightforward to add the same feature to other fieldtypes in the future (if wanted).
  • I don't really like the fact that the paste buttons hang around (and have taken the steps above to ensure they don't stay there forever). It wouldn't make sense to clear the data on paste since you might want to paste multiple times. Maybe the paste option shouldn't be a button at all, it could be in the [5.x] Field actions #10352 menu. That would also simplify adding the same feature to other fieldtypes since there's no longer any replicator specific UI.
  • If the button does stay it needs a better icon, hopefully there's a good one in the streamline set.

Other Changes

This PR includes the same "Other Changes" as #10361, since they're related and using the same hashes.

Closes statamic/ideas#748
Closes #8572

@jacksleight jacksleight marked this pull request as ready for review July 12, 2024 15:52
@marcingajda
Copy link

marcingajda commented Dec 6, 2024

It would be very nice to have this merged 👍
Meanwhile, would it be possible to make an add-on from it?

Same with #10361

@jacksleight
Copy link
Contributor Author

Just added the option to cut/copy all sets, now that field actions is merged:

CleanShot.2024-12-06.at.09.58.26.mp4

@jacksleight
Copy link
Contributor Author

@marcingajda It's not really possible to do this (or #10361) in an addon, at least not without creating a whole custom version of the replicator fieldtype.

@marcingajda
Copy link

@jacksleight I see. Finger crossed for your PR's :)

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

Successfully merging this pull request may close these issues.

Move sets between sets
2 participants