Updating modules/backend/traits
This commit is contained in:
parent
75510ed4de
commit
aa68d163a0
|
|
@ -26,12 +26,14 @@ trait CollapsableWidget
|
|||
|
||||
protected function getGroupStatuses()
|
||||
{
|
||||
if ($this->groupStatusCache !== false)
|
||||
if ($this->groupStatusCache !== false) {
|
||||
return $this->groupStatusCache;
|
||||
}
|
||||
|
||||
$groups = $this->getSession('groups', []);
|
||||
if (!is_array($groups))
|
||||
if (!is_array($groups)) {
|
||||
return $this->groupStatusCache = [];
|
||||
}
|
||||
|
||||
return $this->groupStatusCache = $groups;
|
||||
}
|
||||
|
|
@ -47,9 +49,10 @@ trait CollapsableWidget
|
|||
protected function getGroupStatus($group)
|
||||
{
|
||||
$statuses = $this->getGroupStatuses();
|
||||
if (array_key_exists($group, $statuses))
|
||||
if (array_key_exists($group, $statuses)) {
|
||||
return $statuses[$group];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,24 +17,28 @@ trait InspectableContainer
|
|||
public function onInspectableGetOptions()
|
||||
{
|
||||
$property = trim(Request::input('inspectorProperty'));
|
||||
if (!$property)
|
||||
if (!$property) {
|
||||
throw new ApplicationException('The property name is not specified.');
|
||||
}
|
||||
|
||||
$className = trim(Request::input('inspectorClassName'));
|
||||
if (!$className)
|
||||
if (!$className) {
|
||||
throw new ApplicationException('The inspectable class name is not specified.');
|
||||
}
|
||||
|
||||
$traitFound = in_array('System\Traits\PropertyContainer', class_uses_recursive($className));
|
||||
if (!$traitFound)
|
||||
if (!$traitFound) {
|
||||
throw new ApplicationException('The options cannot be loaded for the specified class.');
|
||||
}
|
||||
|
||||
$obj = new $className(null);
|
||||
|
||||
$methodName = 'get'.ucfirst($property).'Options';
|
||||
if (method_exists($obj, $methodName))
|
||||
if (method_exists($obj, $methodName)) {
|
||||
$options = $obj->$methodName();
|
||||
else
|
||||
} else {
|
||||
$options = $obj->getPropertyOptions($property);
|
||||
}
|
||||
|
||||
/*
|
||||
* Convert to array to retain the sort order in JavaScript
|
||||
|
|
@ -48,4 +52,4 @@ trait InspectableContainer
|
|||
'options' => $optionsArray
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,13 +33,15 @@ trait SearchableWidget
|
|||
{
|
||||
foreach ($words as $word) {
|
||||
$word = trim($word);
|
||||
if (!strlen($word))
|
||||
if (!strlen($word)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Str::contains(Str::lower($text), $word))
|
||||
if (Str::contains(Str::lower($text), $word)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,12 +28,14 @@ trait SelectableWidget
|
|||
|
||||
protected function getSelectedItems()
|
||||
{
|
||||
if ($this->selectedItemsCache !== false)
|
||||
if ($this->selectedItemsCache !== false) {
|
||||
return $this->selectedItemsCache;
|
||||
}
|
||||
|
||||
$items = $this->getSession('selected', []);
|
||||
if (!is_array($items))
|
||||
if (!is_array($items)) {
|
||||
return $this->selectedItemsCache = [];
|
||||
}
|
||||
|
||||
return $this->selectedItemsCache = $items;
|
||||
}
|
||||
|
|
@ -54,9 +56,10 @@ trait SelectableWidget
|
|||
protected function isItemSelected($itemId)
|
||||
{
|
||||
$selectedItems = $this->getSelectedItems();
|
||||
if (!is_array($selectedItems) || !isset($selectedItems[$itemId]))
|
||||
if (!is_array($selectedItems) || !isset($selectedItems[$itemId])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $selectedItems[$itemId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,4 +29,4 @@ trait WidgetMaker
|
|||
$widget = $manager->makeWidget($class, $controller, $configuration);
|
||||
return $widget;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue