Skip to content

Commit

Permalink
Merge branch 'release/1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Severin Hauser committed Aug 9, 2023
2 parents 7cb3712 + 4c0c7be commit c304203
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions src/TreeView.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ public function setValue($value, $data = null)
* this because the default behavior would write a NULL value into the relation.
*/
public function saveInto(DataObjectInterface $record)
{}
{
}

/**
* Recursively opens an item
Expand Down Expand Up @@ -121,7 +122,7 @@ private function pre($request)
$this->httpError(400, _t(
"SilverStripe\\Forms\\Form.CSRF_FAILED_MESSAGE",
"There seems to have been a technical problem. Please click the back button, " .
"refresh your browser, and try again."
"refresh your browser, and try again."
));
return;
}
Expand Down Expand Up @@ -417,7 +418,6 @@ public function delete($request)
if ($parent) {
$parent->Children()->removeByID($itemId);
}

}

// Delete the element
Expand Down Expand Up @@ -492,7 +492,7 @@ public function doSearch($data, $form)
$list = $this->context->getQuery([
'ClassName' => $data['ClassName'],
'Name' => $data['Name'],
], false, false);
], false, null);
$allowed = $this->getTarget($data['itemId'])->getAllowedPageElements();
// Remove all disallowed classes
$list = $list->filter(["ClassName" => $allowed, "Name:not" => [null, '']]);
Expand Down Expand Up @@ -525,13 +525,13 @@ public function DetailForm(PageElement $item, bool $loadData = true)
$actions = new FieldList();
if ($canEdit) {
$actions->push(FormAction::create('doSave', _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Save', 'Save'))
->setUseButtonTag(true)
->addExtraClass('btn-primary font-icon-save'));
->setUseButtonTag(true)
->addExtraClass('btn-primary font-icon-save'));
}
if ($canDelete) {
$actions->push(FormAction::create('doDelete', _t('SilverStripe\\Forms\\GridField\\GridFieldDetailForm.Delete', 'Delete'))
->setUseButtonTag(true)
->addExtraClass('btn-outline-danger btn-hide-outline font-icon-trash-bin action-delete'));
->setUseButtonTag(true)
->addExtraClass('btn-outline-danger btn-hide-outline font-icon-trash-bin action-delete'));
}

$fields = $item->getCMSFields();
Expand Down Expand Up @@ -755,15 +755,15 @@ private function renderTree($item, $parents, $opens, $isFirst)
// Get the list of parents of this element as an array of ids
// (already converted to json/a string)
$tree = "[" .
implode(
',',
array_map(
function ($item) {
return $item->ID;
},
$parents
)
) .
implode(
',',
array_map(
function ($item) {
return $item->ID;
},
$parents
)
) .
"]";

// Construct the array of all allowed child elements
Expand All @@ -775,8 +775,8 @@ function ($item) {

// Construct the array of all allowed child elements in parent slot
$parentClasses = count($parents) > 0
? $parents[count($parents) - 1]->getAllowedPageElements()
: $this->section->getAllowedPageElements();
? $parents[count($parents) - 1]->getAllowedPageElements()
: $this->section->getAllowedPageElements();
$parentElems = [];
foreach ($parentClasses as $class) {
$parentElems[$class] = singleton($class)->singular_name();
Expand Down Expand Up @@ -952,4 +952,5 @@ private function closeItem($path)
}

class TreeView_Readonly extends TreeView
{}
{
}

0 comments on commit c304203

Please sign in to comment.