Closed kinglozzer closed 6 years ago
Good idea, related to https://github.com/silverstripe/silverstripe-versioned/issues/71 also for other UX considerations.
We've got tickets for "view archived records" now as well: https://github.com/silverstripe/silverstripe-versioned/issues/38 https://github.com/silverstripe/silverstripe-versioned/issues/91
I would think its usable if, when versioned_gridfield_extensions
is detected, to replace GridFieldDeleteAction
with another that has handleAction
that simply does $item->deleteFromStage(Versioned::LIVE);
before $item->delete();
This way the convenience of a grid delete button is not lost and is consistent with non-versioned grids
Wasn't there a PR to fix this a while ago which meant that we added GridFieldVersionedState
by default to versioned gridfields?
For a temporary solution to my own project right now, can anyone supply an example of how to remove just the delete button from the gridfield columns ? I am attempting this: $conf->removeComponentsByType(GridFieldDeleteAction::class); but to no avail. I would love to just hide teh button for now.
For a temporary solution to my own project right now, can anyone supply an example of how to remove just the delete button from the gridfield columns ? I am attempting this: $conf->removeComponentsByType(GridFieldDeleteAction::class); but to no avail. I would love to just hide teh button for now.
Looks correct, did you import the class? use SilverStripe\Forms\GridField\GridFieldDeleteAction;
I've just moved this up the backlog, sorry this has dropped off the radar for so long.
Yep. Adding use SilverStripe\Forms\GridField\GridFieldDeleteAction; fixed it! thanks :-)
How about just tapping into the onBeforeDelete() on a versioned DO and archiving it in https://github.com/silverstripe/silverstripe-versioned/blob/1/src/Versioned.php ?
E.g.
public function onBeforeDelete() {
$this->owner->doArchive();
}
The problem is that archiving itself also calls a delete. It would be an infinite loop.
Bump. We should be updating GridFieldDeleteAction so that it automatically renamed the delete button as "Archive" for versioned records, and internally called archive.
This component also automatically detects unlink for many_many, so it feels natural to support a third archive mode.
I'm assuming removing GridFieldDeleteAction is still the best work around for this? That's the approach I took a few months back but now struck another case within a ModelAdmin.
I've hit this issue now too - deleted or unlinked records being removed from the CMS (eg ObjectTable
) but remaining in ObjectTable_Live
. At this point there is no way to remove those stray items. As far as I can the safest solution here is to remove GridFieldDeleteAction
but that is just a work-around, not a solution.
Nice little nugget from @tractorcow in https://github.com/silverstripe/silverstripe-versioned/issues/116. Add cascade_deletes
to help resolve those stray items on publish.
This has come up a few times on Slack recently. The default
GridFieldDeleteAction
doesn’t handle versioning and will remove records from stage but not live, meaning that records are removed from the CMS but still visible on the live site. CMS users are left with no way to recover/remove them as they don’t show up anywhere in the CMS (not sure if/how this might tie into the history viewer).The obvious solution is to omit the action entirely and force users to click to edit, then choose the appropriate delete type. But given that
GridFieldConfig_RecordEditor
(and presumably thereforeModelAdmin
, though I haven’t checked) provide that action by default, I think we should do something to help out developers as it’s not immediately obvious.Haven’t thought about it in any great detail, but perhaps if
versioned_gridfield_extensions
is set we could removeGridFieldDeleteAction
and pushGridFieldVersionedState
instead?PRs