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

Data events #223

Closed
jesseleite opened this issue Feb 5, 2019 · 7 comments
Closed

Data events #223

jesseleite opened this issue Feb 5, 2019 · 7 comments

Comments

@jesseleite
Copy link
Member

jesseleite commented Feb 5, 2019

Ensure all data classes have corresponding events. ie) EntrySaving, EntrySaved, EntryDeleting, EntryDeleted, etc.

Not sure if we need to implement all of the same model events offered by Laravel, but for the events that we do wish to implement, I've already implemented EntrySaving and EntrySaved as an example.

See #55 and this doc for more info.

@jesseleite
Copy link
Member Author

Spock specifically will need access to all the same events that v2 had access to, as well as a singular EntriesMoved event for re-ordering entries (see Spock issue on the subject).

@jasonvarga
Copy link
Member

We kinda got lucky with the PagesMoved event in v2. When you reorder pages, we don't actually call any save() methods on the pages, we just move the files around.

We'll end up with the same problem in v3.

Page reordering would be done with a structure, and we'd just need to call save on that once.

Entries though...

Maybe a solution could be that the saving event could be aware that its part of a batch update, then Spock could choose to ignore it. First thing that comes to mind is something like this:

function reorderEntries($entries)
{
  Entry::batched(function () use ($entries) {
    // do the saving
  });

  event(new EntriesReordered());
}

@jesseleite
Copy link
Member Author

So Spock would have to have logic for choosing which events to ignore and when?

@jesseleite
Copy link
Member Author

What if we used structures to hold order on a reorderable collection, rather than storing the order on each individual entry. I know we're using them for nested trees, but what if you could have flat: true on a structure, so that the UI would only allow you to re-order without nesting?

@jasonvarga
Copy link
Member

Yeah, that's actually probably a better option. We could just store an array of IDs in the collection itself instead of using a structure, though.

title: My Collection
order: number
items: 
  - id-of-the-first
  - id-of-the-second
  - etc

@jesseleite
Copy link
Member Author

jesseleite commented Mar 13, 2019

Yeah the single file approach with IDs makes more sense to me, just as it makes more sense in structures 👍 That said, I still wonder about flat structures, rather than having two different places for storing these structures, and then creating completely separate drag'n'drop interfaces, if we could just disable nesting in the GUI when flat: true 🤔

On a UX note, it'd totally be possible to automate the creation of a structure if they check reorderable in the GUI when creating the collection.

@edalzell
Copy link
Contributor

@jesseleite @jasonvarga this has been done right? We can close?

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

No branches or pull requests

4 participants