diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index 1f6836314..bc6ef3d80 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -205,9 +205,14 @@ EOF $oReflection = new ReflectionClass($sDashletClass); if (!$oReflection->isAbstract()) { - $aCallSpec = array($sDashletClass, 'GetInfo'); - $aInfo = call_user_func($aCallSpec); - $oPage->add(''); + $aCallSpec = array($sDashletClass, 'IsVisible'); + $bVisible = call_user_func($aCallSpec); + if ($bVisible) + { + $aCallSpec = array($sDashletClass, 'GetInfo'); + $aInfo = call_user_func($aCallSpec); + $oPage->add(''); + } } } } @@ -228,12 +233,14 @@ EOF { $sId = $oDashlet->GetID(); $sClass = get_class($oDashlet); - - $oPage->add(''); + if ($oDashlet->IsVisible()) + { + $oPage->add(''); + } } $oPage->add(''); @@ -343,11 +350,17 @@ $('#dashboard_editor').dialog({ $('#dashboard_editor .ui-layout-center').dashboard({ dashboard_id: '$sId', layout_class: '$sLayoutClass', title: '$sTitle', submit_to: '$sUrl', submit_parameters: {operation: 'save_dashboard'}, - render_to: '$sUrl', render_parameters: {operation: 'render_dashboard'} + render_to: '$sUrl', render_parameters: {operation: 'render_dashboard'}, + new_dashlet_parameters: {operation: 'new_dashlet'} }); -$('#dashboard_editor table').sortable({ - items: '.dashlet' +$('#select_dashlet').droppable({ + accept: '.dashlet', + drop: function(event, ui) { + $( this ).find( ".placeholder" ).remove(); + var oDashlet = ui.draggable; + oDashlet.remove(); + }, }); $('#event_bus').bind('dashlet-selected', function(event, data){ diff --git a/application/dashboardlayout.class.inc.php b/application/dashboardlayout.class.inc.php index daac6e13d..31541555d 100644 --- a/application/dashboardlayout.class.inc.php +++ b/application/dashboardlayout.class.inc.php @@ -29,6 +29,24 @@ abstract class DashboardLayoutMultiCol extends DashboardLayout public function Render($oPage, $aDashlets, $bEditMode = false, $aExtraParams = array()) { + // Trim the list of dashlets to remove the invisible ones at the end of the array + $aKeys = array_reverse(array_keys($aDashlets)); + $idx = 0; + $bNoVisibleFound = true; + while($idx < count($aKeys) && $bNoVisibleFound) + { + $oDashlet = $aDashlets[$aKeys[$idx]]; + if ($oDashlet->IsVisible()) + { + $bNoVisibleFound = false; + } + else + { + unset($aDashlets[$aKeys[$idx]]); + } + $idx++; + } + $oPage->add(''); $iDashletIdx = 0; $fColSize = 100 / $this->iNbCols; @@ -43,7 +61,14 @@ abstract class DashboardLayoutMultiCol extends DashboardLayout if (array_key_exists($iDashletIdx, $aDashlets)) { $oDashlet = $aDashlets[$iDashletIdx]; - $oDashlet->DoRender($oPage, $bEditMode, $aExtraParams); + if ($oDashlet->IsVisible()) + { + $oDashlet->DoRender($oPage, $bEditMode, $aExtraParams); + } + else + { + $oPage->add(' '); + } } else { diff --git a/application/dashlet.class.inc.php b/application/dashlet.class.inc.php index 18cb71418..9ecf38b60 100644 --- a/application/dashlet.class.inc.php +++ b/application/dashlet.class.inc.php @@ -192,6 +192,42 @@ EOF return $oForm; } + + static public function IsVisible() + { + return true; + } +} + +class DashletEmptyCell extends Dashlet +{ + public function __construct($sId) + { + parent::__construct($sId); + } + + public function Render($oPage, $bEditMode = false, $aExtraParams = array()) + { + $oPage->add(' '); + } + + public function GetPropertiesFields(DesignerForm $oForm) + { + } + + static public function GetInfo() + { + return array( + 'label' => 'Empty Cell', + 'icon' => 'images/dashlet-text.png', + 'description' => 'Empty Cell Dashlet Placeholder', + ); + } + + static public function IsVisible() + { + return false; + } } class DashletHelloWorld extends Dashlet