mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-18 16:18:47 +02:00
User editable dashboards... implementation in progress
SVN:trunk[2017]
This commit is contained in:
@@ -205,9 +205,14 @@ EOF
|
||||
$oReflection = new ReflectionClass($sDashletClass);
|
||||
if (!$oReflection->isAbstract())
|
||||
{
|
||||
$aCallSpec = array($sDashletClass, 'GetInfo');
|
||||
$aInfo = call_user_func($aCallSpec);
|
||||
$oPage->add('<span class="dashlet_icon ui-widget-content ui-corner-all" id="dashlet_'.$sDashletClass.'" title="'.$aInfo['label'].'" style="width:34px; height:34px; display:inline-block; margin:2px;"><img src="'.$sUrl.$aInfo['icon'].'" /></span>');
|
||||
$aCallSpec = array($sDashletClass, 'IsVisible');
|
||||
$bVisible = call_user_func($aCallSpec);
|
||||
if ($bVisible)
|
||||
{
|
||||
$aCallSpec = array($sDashletClass, 'GetInfo');
|
||||
$aInfo = call_user_func($aCallSpec);
|
||||
$oPage->add('<span dashlet_class="'.$sDashletClass.'" class="dashlet_icon ui-widget-content ui-corner-all" id="dashlet_'.$sDashletClass.'" title="'.$aInfo['label'].'" style="width:34px; height:34px; display:inline-block; margin:2px;"><img src="'.$sUrl.$aInfo['icon'].'" /></span>');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,12 +233,14 @@ EOF
|
||||
{
|
||||
$sId = $oDashlet->GetID();
|
||||
$sClass = get_class($oDashlet);
|
||||
|
||||
$oPage->add('<div class="dashlet_properties" id="dashlet_properties_'.$sId.'" style="display:none">');
|
||||
$oForm = $oDashlet->GetForm();
|
||||
$this->SetFormParams($oForm);
|
||||
$oForm->RenderAsPropertySheet($oPage);
|
||||
$oPage->add('</div>');
|
||||
if ($oDashlet->IsVisible())
|
||||
{
|
||||
$oPage->add('<div class="dashlet_properties" id="dashlet_properties_'.$sId.'" style="display:none">');
|
||||
$oForm = $oDashlet->GetForm();
|
||||
$this->SetFormParams($oForm);
|
||||
$oForm->RenderAsPropertySheet($oPage);
|
||||
$oPage->add('</div>');
|
||||
}
|
||||
}
|
||||
$oPage->add('</div>');
|
||||
|
||||
@@ -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){
|
||||
|
||||
@@ -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('<table style="width:100%"><tbody>');
|
||||
$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
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user