mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-19 07:12:26 +02:00
Fix default dashlet
This commit is contained in:
@@ -29,8 +29,6 @@ use OQLException;
|
||||
use UnknownClassOqlException;
|
||||
use utils;
|
||||
|
||||
require_once(APPROOT.'application/forms.class.inc.php');
|
||||
|
||||
/**
|
||||
* Base class for all 'dashlets' (i.e. widgets to be inserted into a dashboard)
|
||||
*
|
||||
|
||||
@@ -37,7 +37,8 @@ class DashletFactory
|
||||
public function CreateDashlet(string $sClass, string $sId): Dashlet
|
||||
{
|
||||
if (!DashletService::GetInstance()->IsDashletAvailable($sClass)) {
|
||||
throw new DashletException("Dashlet ".json_encode($sClass)." is not available");
|
||||
$sClass = 'DashletUnknown';
|
||||
//throw new DashletException("Dashlet ".json_encode($sClass)." is not available");
|
||||
}
|
||||
|
||||
/** @var Dashlet $oDashlet */
|
||||
|
||||
@@ -36,11 +36,34 @@ class DashletService
|
||||
* @throws \Combodo\iTop\Application\Dashlet\DashletException
|
||||
* @throws \DOMFormatException
|
||||
*/
|
||||
public function GetAvailableDashlets(): array
|
||||
public function GetAvailableDashlets(string $sCategory = ''): array
|
||||
{
|
||||
$this->InitDashletDefinitions();
|
||||
$aFilteredDashlets = [];
|
||||
|
||||
return $this->aDashlets;
|
||||
switch ($sCategory) {
|
||||
case 'can_be_created':
|
||||
foreach ($this->aDashlets as $aDashlet) {
|
||||
if ($aDashlet['can_be_created']) {
|
||||
$aFilteredDashlets[] = $aDashlet;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'can_create_by_oql':
|
||||
foreach ($this->aDashlets as $aDashlet) {
|
||||
if ($aDashlet['can_create_by_oql']) {
|
||||
$aFilteredDashlets[] = $aDashlet;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
$aFilteredDashlets = $this->aDashlets;
|
||||
break;
|
||||
}
|
||||
|
||||
return $aFilteredDashlets;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -131,6 +154,7 @@ class DashletService
|
||||
'preferred_width' => intval($oDashletNode->GetChildText('preferred_width', '2')),
|
||||
'preferred_height' => intval($oDashletNode->GetChildText('preferred_height', '1')),
|
||||
'can_create_by_oql' => boolval($oDashletNode->GetChildText('can_create_by_oql', 'false')),
|
||||
'can_be_created' => boolval($oDashletNode->GetChildText('can_be_created', 'true')),
|
||||
];
|
||||
$this->aDashlets[$sType] = $aInfo;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user