N°1408 - Asynchronous load of dashboard tab

This commit is contained in:
Eric
2018-10-15 15:51:44 +02:00
parent db4b8b2f43
commit ebb5ede613
4 changed files with 45 additions and 19 deletions

View File

@@ -398,15 +398,13 @@ EOF
$this->aFieldsMap[$sAttCode] = $sInputId;
}
/**
* @param \iTopWebPage $oPage
* @param $bEditMode
*
* @throws \CoreException
* @throws \Exception
*/
public function DisplayDashboards($oPage, $bEditMode)
protected function DisplayDashboardTabs($oPage, $bEditMode)
{
if ($bEditMode || $this->IsNew())
{
@@ -429,24 +427,41 @@ EOF
continue;
} // Process only dashboards attributes...
$oPage->SetCurrentTab($oAttDef->GetLabel());
// Load the dashboard
$oDashboard = $oAttDef->GetDashboard();
if (is_null($oDashboard))
{
continue;
}
$bCanEdit = UserRights::IsAdministrator() || $oAttDef->IsUserEditable();
$sDivId = $oDashboard->GetId();
$oPage->add('<div class="dashboard_contents" id="'.$sDivId.'">');
$aExtraParams = array('query_params' => $this->ToArgsForQuery());
$oDashboard->Render($oPage, false, $aExtraParams, $bCanEdit);
$oPage->add('</div>');
$oPage->AddAjaxTab($oAttDef->GetLabel(), utils::GetAbsoluteUrlAppRoot().'pages/ajax.render.php?operation=dashboard&class='.get_class($this).'&id='.$this->GetKey().'&attcode='.$oAttDef->GetCode());
}
}
/**
* @param \iTopWebPage $oPage
* @param $sAttCode
*
* @throws \Exception
*/
public function DisplayDashboard($oPage, $sAttCode)
{
$sClass = get_class($this);
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if (!$oAttDef instanceof AttributeDashboard)
{
throw new CoreException(Dict::S('UI:Error:InvalidDashboard'));
}
// Load the dashboard
$oDashboard = $oAttDef->GetDashboard();
if (is_null($oDashboard))
{
throw new CoreException(Dict::S('UI:Error:InvalidDashboard'));
}
$bCanEdit = UserRights::IsAdministrator() || $oAttDef->IsUserEditable();
$sDivId = $oDashboard->GetId();
$oPage->add('<div class="dashboard_contents" id="'.$sDivId.'">');
$aExtraParams = array('query_params' => $this->ToArgsForQuery());
$oDashboard->Render($oPage, false, $aExtraParams, $bCanEdit);
$oPage->add('</div>');
}
/**
* @param \WebPage $oPage
* @param bool $bEditMode
@@ -945,7 +960,7 @@ EOF
$oPage->SetCurrentTab(Dict::S('UI:PropertiesTab'));
$this->DisplayBareProperties($oPage, $bEditMode);
$this->DisplayBareRelations($oPage, $bEditMode);
$this->DisplayDashboards($oPage, $bEditMode);
$this->DisplayDashboardTabs($oPage, $bEditMode);
//$oPage->SetCurrentTab(Dict::S('UI:HistoryTab'));
//$this->DisplayBareHistory($oPage, $bEditMode);
$oPage->AddAjaxTab(Dict::S('UI:HistoryTab'),