mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
Make dashlet position non-random. Use their preferred width/height for now
This commit is contained in:
@@ -137,7 +137,18 @@ abstract class DashboardLayoutMultiCol extends DashboardLayout
|
||||
/** @var \Dashlet $oDashlet */
|
||||
foreach ($aDashlets as $oDashlet) {
|
||||
if ($oDashlet::IsVisible()) {
|
||||
$oDashboardGrid->AddDashlet($oDashlet->DoRender($oPage, $bEditMode, true /* bEnclosingDiv */, $aExtraParams), $oDashlet->GetID(), get_class($oDashlet), $oDashlet->GetDenormalizedProperties());
|
||||
$sDashletId = $oDashlet->GetID();
|
||||
$sDashletClass = get_class($oDashlet);
|
||||
$aDashletDenormalizedProperties = $oDashlet->GetDenormalizedProperties();
|
||||
$aDashletsInfo = $sDashletClass::GetInfo();
|
||||
|
||||
// TODO 3.3 Gather real position and height/width if any.
|
||||
// Also set minimal height/width
|
||||
$iPositionX = null;
|
||||
$iPositionY = null;
|
||||
$iWidth = array_key_exists('preferred_width', $aDashletsInfo) ? $aDashletsInfo['preferred_width'] : 1;
|
||||
$iHeight = array_key_exists('preferred_height', $aDashletsInfo) ? $aDashletsInfo['preferred_height'] : 1;
|
||||
$oDashboardGrid->AddDashlet($oDashlet->DoRender($oPage, $bEditMode, true /* bEnclosingDiv */, $aExtraParams), $sDashletId, $sDashletClass, $aDashletDenormalizedProperties, $iPositionX, $iPositionY, $iWidth, $iHeight);
|
||||
//$oDashboardColumn->AddUIBlock($oDashlet->DoRender($oPage, $bEditMode, true /* bEnclosingDiv */, $aExtraParams));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,10 +53,10 @@ class DashboardGrid extends UIBlock
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function AddDashlet(UIBlock $oDashlet, string $sDashletId, string $sDashletClass, array $aFormViewData): DashboardGrid
|
||||
public function AddDashlet(UIBlock $oDashlet, string $sDashletId, string $sDashletClass, array $aFormViewData, ?int $iPositionX = null, ?int $iPositionY = null, ?int $iWidth = null, ?int $iHeight = null): DashboardGrid
|
||||
{
|
||||
$oWrapper = new DashletWrapper($oDashlet, $sDashletClass, $sDashletId, $aFormViewData);
|
||||
$oSlot = new DashboardGridSlot(null, $oWrapper);
|
||||
$oSlot = new DashboardGridSlot(null, $oWrapper, $iPositionX, $iPositionY, $iWidth, $iHeight);
|
||||
$this->AddSlot($oSlot);
|
||||
|
||||
return $this;
|
||||
|
||||
@@ -30,10 +30,10 @@ class DashboardGridSlot extends UIBlock
|
||||
parent::__construct($sId);
|
||||
$this->oDashlet = $oDashlet;
|
||||
|
||||
$this->iPositionX = random_int(0, 10) || $iPositionX;
|
||||
$this->iPositionY = random_int(0, 8) || $iPositionY;
|
||||
$this->iWidth = random_int(1, 5) || $iWidth;
|
||||
$this->iHeight = random_int(1, 4) || $iHeight;
|
||||
$this->iPositionX = $iPositionX;
|
||||
$this->iPositionY = $iPositionY;
|
||||
$this->iWidth = $iWidth;
|
||||
$this->iHeight = $iHeight;
|
||||
}
|
||||
|
||||
public function GetSubBlocks(): array
|
||||
@@ -41,6 +41,10 @@ class DashboardGridSlot extends UIBlock
|
||||
return [$this->oUIBlock];
|
||||
}
|
||||
|
||||
public function HasPositionX(): bool
|
||||
{
|
||||
return !is_null($this->iPositionX);
|
||||
}
|
||||
public function GetPositionX(): ?int
|
||||
{
|
||||
return $this->iPositionX;
|
||||
@@ -53,6 +57,10 @@ class DashboardGridSlot extends UIBlock
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function HasPositionY(): bool
|
||||
{
|
||||
return !is_null($this->iPositionX);
|
||||
}
|
||||
public function GetPositionY(): ?int
|
||||
{
|
||||
return $this->iPositionY;
|
||||
@@ -65,6 +73,10 @@ class DashboardGridSlot extends UIBlock
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function HasWidth(): bool
|
||||
{
|
||||
return !is_null($this->iWidth);
|
||||
}
|
||||
public function GetWidth(): ?int
|
||||
{
|
||||
return $this->iWidth;
|
||||
@@ -77,6 +89,10 @@ class DashboardGridSlot extends UIBlock
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function HasHeight(): bool
|
||||
{
|
||||
return !is_null($this->iHeight);
|
||||
}
|
||||
public function GetHeight(): ?int
|
||||
{
|
||||
return $this->iHeight;
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
<ibo-dashboard-grid-slot
|
||||
gs-x="{{ random(10) }}"
|
||||
gs-y="{{ random(6) }}"
|
||||
gs-w="{{ random(5) }}"
|
||||
gs-h="{{ random(5) }}"
|
||||
{% if oUIBlock.HasPositionX() is true %}
|
||||
gs-x="{{ oUIBlock.GetPositionX() }}"
|
||||
{% endif %}
|
||||
{% if oUIBlock.HasPositionY() is true %}
|
||||
gs-y="{{ oUIBlock.GetPositionY() }}"
|
||||
{% endif %}
|
||||
{% if oUIBlock.HasWidth() is true %}
|
||||
gs-w="{{ oUIBlock.GetWidth() }}"
|
||||
{% endif %}
|
||||
{% if oUIBlock.HasHeight() is true %}
|
||||
gs-h="{{ oUIBlock.GetHeight() }}"
|
||||
{% endif %}
|
||||
{# TODO 3.3 Handle min width / height #}
|
||||
id=""
|
||||
class="grid-stack-item">
|
||||
{{ render_block(oUIBlock.GetDashlet(), {aPage: aPage}) }}
|
||||
|
||||
Reference in New Issue
Block a user