N°2634 / N°2735 Allow saving list prefs for all DashletObjectList

The id generated for the dashlets in the markup is the one used in the saved appUserPreferences. As no control is done during compilation nor in the Designer editor, we could have duplicates.
The first fix (081ba68a) was adding a generated suffix, but for default dashlet this was generated each time so the id was different on every page load ! For custom dashlets as their definition was saved in a XML file it was ok.
This new fix adds a prefix containing row and col id, so every time the id is the same. No duplicates should be found in the same cell.
This commit is contained in:
Pierre Goiffon
2020-02-11 17:21:22 +01:00
parent 406774aa15
commit 824d8398a3
2 changed files with 6 additions and 13 deletions

View File

@@ -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');

View File

@@ -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);
}
}