Skip to content

Commit

Permalink
ss5 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoala committed Aug 10, 2023
1 parent 4665f66 commit 1247ede
Showing 1 changed file with 25 additions and 13 deletions.
38 changes: 25 additions & 13 deletions code/SoftDeleteSecurityAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,39 @@ function updateEditForm(Form $form)

if ($memberSingl->hasExtension('SoftDeletable')) {
$gridfield = $form->Fields()->dataFieldByName('Members');
$config = $gridfield->getConfig();
//SS5 compat
if (!$gridfield) {
$gridfield = $form->Fields()->dataFieldByName('users');
}
if ($gridfield) {
$config = $gridfield->getConfig();

$config->removeComponentsByType(GridFieldDeleteAction::class);
if ($this->owner->config()->softdelete_from_list) {
$exclude = $this->owner->config()->softdelete_from_list_exclude;
if ($exclude && !in_array($this->owner->modelClass, $exclude)) {
$config->addComponent(new GridFieldSoftDeleteAction());
$config->removeComponentsByType(GridFieldDeleteAction::class);
if ($this->owner->config()->softdelete_from_list) {
$exclude = $this->owner->config()->softdelete_from_list_exclude;
if ($exclude && !in_array($this->owner->modelClass, $exclude)) {
$config->addComponent(new GridFieldSoftDeleteAction());
}
}
}

// No caution because soft :-)
$form->Fields()->removeByName('MembersCautionText');
// No caution because soft :-)
$form->Fields()->removeByName('MembersCautionText');
}
}

if ($groupSingl->hasExtension('SoftDeletable')) {
$gridfield = $form->Fields()->dataFieldByName('Groups');
$config = $gridfield->getConfig();
//SS5 compat
if (!$gridfield) {
$gridfield = $form->Fields()->dataFieldByName('groups');
}
if ($gridfield) {
$config = $gridfield->getConfig();

$config->removeComponentsByType(GridFieldDeleteAction::class);
if ($this->owner->config()->softdelete_from_list) {
$config->addComponent(new GridFieldSoftDeleteAction());
$config->removeComponentsByType(GridFieldDeleteAction::class);
if ($this->owner->config()->softdelete_from_list) {
$config->addComponent(new GridFieldSoftDeleteAction());
}
}
}
}
Expand Down

0 comments on commit 1247ede

Please sign in to comment.