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] Add Nav & Collection Tree Saving events #10625

Conversation

ryanmitchell
Copy link
Contributor

@ryanmitchell ryanmitchell commented Aug 13, 2024

Someone was looking for NavTreeSaving and CollectionTreeSaving in discussions earlier: #10618

This PR adds them.

Closes statamic/ideas#1207.

@wuifdesign
Copy link
Contributor

i think you are missing the changes to handle the false state.

// CollectionTreeController.php
$saved = $tree->tree($contents)->save();

return [
  'saved' => $saved,
];

something like:

// PageTree.vue
if (! response.data.saved) {
  return this.$toast.error(__(`Couldn't save tree`));
}

and return true at the end of the save function in the Tree.php

same changes for the delete part.

@wuifdesign
Copy link
Contributor

changes looks good :)

no idea but is this change also needed for delete? And also for NavTree to work correctly with NavTree Events?

@ryanmitchell
Copy link
Contributor Author

Deleting in the CP only happens by deleting the whole nav, so it shouldn't need UI.

@jasonvarga
Copy link
Member

Do you really need the Deleting events at the moment?

This can prevent the tree from being deleted, but that doesn't stop the nav from being deleted.

@ryanmitchell
Copy link
Contributor Author

Nope. Dump them if they are causingproblems.

@jasonvarga jasonvarga changed the title [5.x] Add Nav & Collection Tree Saving and Deleting events [5.x] Add Nav & Collection Tree Saving events Sep 25, 2024
@jasonvarga jasonvarga merged commit 69c1fff into statamic:5.x Sep 25, 2024
16 checks passed
@ryanmitchell ryanmitchell deleted the feature/add-nav-and-collection-tree-saving-deleting-events branch September 26, 2024 04:51
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.

Add a CollectionTreeSaving Event
3 participants