mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
Dashlet form in new dashboard layout
This commit is contained in:
@@ -2,18 +2,21 @@
|
||||
|
||||
namespace Combodo\iTop\Controller\Base\Layout;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Base\Component\Button\ButtonUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletWrapper;
|
||||
use Combodo\iTop\Application\UI\Base\Component\TurboForm\TurboFormUIBlockFactory;
|
||||
use Combodo\iTop\Application\UI\Base\iUIBlock;
|
||||
use Combodo\iTop\Application\WebPage\AjaxPage;
|
||||
use Combodo\iTop\Controller\AbstractController;
|
||||
use ModelReflectionRuntime;
|
||||
use utils;
|
||||
|
||||
class DashboardController extends AbstractController {
|
||||
class DashboardController extends AbstractController
|
||||
{
|
||||
public const ROUTE_NAMESPACE = 'dashboard';
|
||||
|
||||
public function OperationNewDashlet (){
|
||||
public function OperationNewDashlet()
|
||||
{
|
||||
$sDashletClass = utils::ReadParam('dashlet_class', '', false, utils::ENUM_SANITIZATION_FILTER_PHP_CLASS);
|
||||
$sDashletId = utils::ReadParam('dashlet_id', '', false, utils::ENUM_SANITIZATION_FILTER_ELEMENT_IDENTIFIER);
|
||||
$oPage = new AjaxPage('');
|
||||
@@ -27,30 +30,26 @@ class DashboardController extends AbstractController {
|
||||
$oDashletBlock = $oDashlet->DoRender($oPage, true /* bEditMode */, false /* bEnclosingDiv */);
|
||||
//$sHtml = addslashes($oPage->end_capture($offset));
|
||||
|
||||
if($oDashletBlock instanceof iUIBlock) {
|
||||
if ($oDashletBlock instanceof iUIBlock) {
|
||||
// Wrap the dashlet
|
||||
$oDashletWrapper = new DashletWrapper($oDashletBlock, $oDashlet->GetID(), $sDashletClass);
|
||||
$oPage->AddUiBlock($oDashletWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
return $oPage;
|
||||
}
|
||||
|
||||
public function OperationGetDashletForm() {
|
||||
|
||||
public function OperationGetDashletForm()
|
||||
{
|
||||
$sDashletClass = utils::ReadParam('dashlet_class', '', false, utils::ENUM_SANITIZATION_FILTER_PHP_CLASS);
|
||||
$oPage = new AjaxPage('');
|
||||
|
||||
if (is_subclass_of($sDashletClass, 'Dashlet')) {
|
||||
$oDashlet = new $sDashletClass(new ModelReflectionRuntime(), uniqid());
|
||||
$oForm = $oDashlet->GetForm(); // Rebuild the form since the values/content changed
|
||||
$oForm->SetSubmitParams(utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php', ['operation' => 'update_dashlet_property']);
|
||||
$oUIBlock = TurboFormUIBlockFactory::MakeForDashletConfiguration($sDashletClass);
|
||||
$oUIBlock->AddSubBlock(ButtonUIBlockFactory::MakeForPrimaryAction('Confirm', 'dashboard_submit', 'dashboard_submit', true));
|
||||
$oUIBlock->AddSubBlock(ButtonUIBlockFactory::MakeForSecondaryAction('Cancel', 'dashboard_cancel'));
|
||||
$oPage->AddUiBlock($oUIBlock);
|
||||
|
||||
$oForm->Render($oPage);
|
||||
}
|
||||
return $oPage;
|
||||
// $oForm = $oDashlet->GetForm(); // Rebuild the form since the values/content changed
|
||||
// ...
|
||||
// $oPage->AddUiBlock($oFormBlock);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user