cms icon indicating copy to clipboard operation
cms copied to clipboard

[5.x] Add Nav & Collection Tree Saving and Deleting events

Open ryanmitchell opened this issue 1 year ago • 3 comments

Someone was looking for NavTreeSaving and CollectionTreeSaving in discussions earlier: https://github.com/statamic/cms/discussions/10618

This PR adds them, as well as adding *Deleting events too.

Closes statamic/ideas#1207.

ryanmitchell avatar Aug 13 '24 21:08 ryanmitchell

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 avatar Aug 14 '24 07:08 wuifdesign

changes looks good :)

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

wuifdesign avatar Aug 14 '24 09:08 wuifdesign

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

ryanmitchell avatar Aug 14 '24 09:08 ryanmitchell

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.

jasonvarga avatar Sep 25 '24 20:09 jasonvarga

Nope. Dump them if they are causingproblems.

ryanmitchell avatar Sep 25 '24 20:09 ryanmitchell