From 824d8398a39d72e2f81bdfc30af0657f5d294de2 Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Tue, 11 Feb 2020 17:21:22 +0100 Subject: [PATCH] =?UTF-8?q?N=C2=B02634=20/=20N=C2=B02735=20Allow=20saving?= =?UTF-8?q?=20list=20prefs=20for=20all=20DashletObjectList=20The=20id=20ge?= =?UTF-8?q?nerated=20for=20the=20dashlets=20in=20the=20markup=20is=20the?= =?UTF-8?q?=20one=20used=20in=20the=20saved=20appUserPreferences.=20As=20n?= =?UTF-8?q?o=20control=20is=20done=20during=20compilation=20nor=20in=20the?= =?UTF-8?q?=20Designer=20editor,=20we=20could=20have=20duplicates.=20The?= =?UTF-8?q?=20first=20fix=20(081ba68a)=20was=20adding=20a=20generated=20su?= =?UTF-8?q?ffix,=20but=20for=20default=20dashlet=20this=20was=20generated?= =?UTF-8?q?=20each=20time=20so=20the=20id=20was=20different=20on=20every?= =?UTF-8?q?=20page=20load=20!=20For=20custom=20dashlets=20as=20their=20def?= =?UTF-8?q?inition=20was=20saved=20in=20a=20XML=20file=20it=20was=20ok.=20?= =?UTF-8?q?This=20new=20fix=20adds=20a=20prefix=20containing=20row=20and?= =?UTF-8?q?=20col=20id,=20so=20every=20time=20the=20id=20is=20the=20same.?= =?UTF-8?q?=20No=20duplicates=20should=20be=20found=20in=20the=20same=20ce?= =?UTF-8?q?ll.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/dashboard.class.inc.php | 6 ------ application/dashboardlayout.class.inc.php | 13 ++++++------- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index 98c8c9e1f..737720e86 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -176,12 +176,6 @@ abstract class Dashboard protected function InitDashletFromDOMNode($oDomNode) { $sId = $oDomNode->getAttribute('id'); - // To avoid collision with other dashlets with the same ID we suffix it. Collisions typically happen with extensions. - // Note: The check is done so we don't append it at each save of the dashboard. - if(strpos($sId, 'uniqid_') === false) - { - $sId .= '_uniqid_' . uniqid(); - } $sDashletType = $oDomNode->getAttribute('xsi:type'); diff --git a/application/dashboardlayout.class.inc.php b/application/dashboardlayout.class.inc.php index f1f2002e2..8ed7be5ec 100644 --- a/application/dashboardlayout.class.inc.php +++ b/application/dashboardlayout.class.inc.php @@ -26,14 +26,9 @@ abstract class DashboardLayout { - public function __construct() - { - - } - abstract public function Render($oPage, $aDashlets, $bEditMode = false); - static public function GetInfo() + public static function GetInfo() { return array( 'label' => '', @@ -61,7 +56,7 @@ abstract class DashboardLayoutMultiCol extends DashboardLayout { /** @var \Dashlet $oDashlet */ $oDashlet = $aDashlets[$aKeys[$idx]]; - if ($oDashlet->IsVisible()) + if ($oDashlet::IsVisible()) { $bNoVisibleFound = false; } @@ -134,6 +129,10 @@ abstract class DashboardLayoutMultiCol extends DashboardLayout { if ($oDashlet->IsVisible()) { + $sDashboardId = $oDashlet->GetID(); + // N°2634 : we must have a unique id per dashlet ! + // To avoid collision with other dashlets with the same ID we prefix it. Collisions typically happen with extensions. + $oDashlet->SetID("row$iRows-col$iCols-$sDashboardId"); $oDashlet->DoRender($oPage, $bEditMode, true /* bEnclosingDiv */, $aExtraParams); } }