namespace Combodo\iTop\Application\Dashlet\Base; use Combodo\iTop\Application\Dashlet\Dashlet; use Combodo\iTop\Application\UI\Base\Component\Dashlet\DashletContainer; use DBObjectSearch; use DesignerBooleanField; use DesignerForm; use DesignerHiddenField; use DesignerLongTextField; use DesignerTextField; use Dict; use DisplayBlock; use MetaModel; use utils; class DashletObjectList extends Dashlet { /** * @inheritdoc */ public function __construct($oModelReflection, $sId) { parent::__construct($oModelReflection, $sId); $this->aProperties['title'] = ''; $this->aProperties['query'] = 'SELECT Contact'; $this->aProperties['menu'] = false; } /** * @inheritdoc * * @throws \OQLException * @throws \CoreException * @throws \ArchivedObjectException */ public function Render($oPage, $bEditMode = false, $aExtraParams = []) { $sTitle = $this->aProperties['title']; $sShowMenu = $this->aProperties['menu'] ? '1' : '0'; $oFilter = $this->GetDBSearch($aExtraParams); $sClass = $oFilter->GetClass(); //$oPanel = PanelUIBlockFactory::MakeForClass($sClass, Dict::S($sTitle)) // ->AddCSSClass('ibo-datatable-panel'); $oBlock = new DisplayBlock($oFilter, 'list'); $aParams = [ 'menu' => $sShowMenu, 'table_id' => self::APP_USER_PREFERENCES_PREFIX.$this->sId, 'surround_with_panel' => true, 'max_height' => '500px', "panel_title" => Dict::S($sTitle), "panel_class" => $sClass, ]; $sBlockId = 'block_'.$this->sId.($bEditMode ? '_edit' : ''); // make a unique id (edition occurring in the same DOM) //$oBlock->DisplayIntoContentBlock($oPanel, $oPage, $sBlockId, array_merge($aExtraParams, $aParams)); $oPanel = $oBlock->GetDisplay($oPage, $sBlockId, array_merge($aExtraParams, $aParams)); return $oPanel; } public function GetDBSearch($aExtraParams = []) { $sQuery = $this->aProperties['query']; if (isset($aExtraParams['query_params'])) { $aQueryParams = $aExtraParams['query_params']; } elseif (isset($aExtraParams['this->class']) && isset($aExtraParams['this->id'])) { $oObj = MetaModel::GetObject($aExtraParams['this->class'], $aExtraParams['this->id']); $aQueryParams = $oObj->ToArgsForQuery(); } else { $aQueryParams = []; } return DBObjectSearch::FromOQL($sQuery, $aQueryParams); } /** * @inheritdoc */ public static function CanCreateFromOQL() { return true; } }