diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index 4eb8ac215..3bbeaaf25 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -35,7 +35,8 @@ abstract class Dashboard foreach($oDashletList as $oDomNode) { $sDashletClass = $oDomNode->getAttribute('xsi:type'); - $oNewDashlet = new $sDashletClass; + $sId = $oDomNode->getAttribute('id'); + $oNewDashlet = new $sDashletClass($sId); $oNewDashlet->FromDOMNode($oDomNode); $this->aDashlets[] = $oNewDashlet; } @@ -80,6 +81,10 @@ abstract class Dashboard $oPage->add('

'.$this->sTitle.'

'); $oLayout = new $this->sLayoutClass; $oLayout->Render($oPage, $this->aDashlets, $bEditMode, $aExtraParams); + if (!$bEditMode) + { + $oPage->add_linked_script('../js/dashlet.js'); + } } public function RenderProperties($oPage) @@ -140,7 +145,10 @@ abstract class Dashboard $oPage->add('
Dashlet Properties
'); $oPage->add('
'); - $oPage->p('Not yet implemented'); + foreach($this->aDashlets as $oDashlet) + { + $oDashlet->RenderProperties($oPage); + } $oPage->add('
'); $oPage->add('
'); @@ -165,7 +173,6 @@ class RuntimeDashboard extends Dashboard <<RenderDashletsSelection($oPage); $this->RenderDashletsProperties($oPage); $oPage->add(''); + $oPage->add('
'); // For exchanging messages between the panes, same as in the designer $oPage->add('
'); $sDialogTitle = 'Dashboard Editor'; $sOkButtonLabel = Dict::S('UI:Button:Ok'); @@ -209,6 +217,24 @@ $('#dashboard_editor').dialog({ ], close: function() { $(this).remove(); } }); + +$('#event_bus').bind('dashlet-selected', function(event, data){ + var sDashletId = data.dashlet_id; + var sPropId = 'dashlet_properties_'+sDashletId; + $('.dashlet_properties').each(function() { + var sId = $(this).attr('id'); + var bShow = (sId == sPropId); + if (bShow) + { + $(this).show(); + } + else + { + $(this).hide(); + } + }); + + }); EOF ); $oPage->add_ready_script("$('#dashboard_editor').layout();"); diff --git a/application/dashboardlayout.class.inc.php b/application/dashboardlayout.class.inc.php index 3eb30cf76..56c78670c 100644 --- a/application/dashboardlayout.class.inc.php +++ b/application/dashboardlayout.class.inc.php @@ -42,7 +42,7 @@ abstract class DashboardLayoutMultiCol extends DashboardLayout if ($iDashletIdx <= count($aDashlets)) { $oDashlet = $aDashlets[$iDashletIdx]; - $oDashlet->Render($oPage, $bEditMode, $aExtraParams); + $oDashlet->DoRender($oPage, $bEditMode, $aExtraParams); } else { diff --git a/application/dashlet.class.inc.php b/application/dashlet.class.inc.php index 2d4594842..1c2d6b6aa 100644 --- a/application/dashlet.class.inc.php +++ b/application/dashlet.class.inc.php @@ -1,9 +1,11 @@ sId = $sId; } public function FromDOMNode($oDOMNode) @@ -21,8 +23,47 @@ abstract class Dashlet } + public function DoRender($oPage, $bEditMode = false, $aExtraParams = array()) + { + if ($bEditMode) + { + $sId = $this->GetID(); + $oPage->add('
'); + } + else + { + $oPage->add('
'); + } + $this->Render($oPage, $bEditMode, $aExtraParams); + $oPage->add('
'); + if ($bEditMode) + { + $sClass = get_class($this); + $oPage->add_ready_script( +<<sId; + } + abstract public function Render($oPage, $bEditMode = false, $aExtraParams = array()); + public function RenderProperties($oPage) + { + $sId = $this->GetID(); + $sClass = get_class($this); + $oPage->add(''); + } + + public function ToXml(DOMNode $oContainerNode) { @@ -50,9 +91,9 @@ abstract class Dashlet class DashletHelloWorld extends Dashlet { - public function __construct() + public function __construct($sId) { - + parent::__construct($sId); } public function FromDOMNode($oDOMNode) @@ -72,9 +113,7 @@ class DashletHelloWorld extends Dashlet public function Render($oPage, $bEditMode = false, $aExtraParams = array()) { - $oPage->add('
'); $oPage->add('
Hello World!
'); - $oPage->add('
'); } public function ToXml(DOMNode $oContainerNode) @@ -110,9 +149,9 @@ class DashletHelloWorld extends Dashlet class DashletFakeBarChart extends Dashlet { - public function __construct() + public function __construct($sId) { - + parent::__construct($sId); } public function FromDOMNode($oDOMNode) @@ -132,9 +171,7 @@ class DashletFakeBarChart extends Dashlet public function Render($oPage, $bEditMode = false, $aExtraParams = array()) { - $oPage->add('
'); $oPage->add('
Fake Bar Chart
'); - $oPage->add('
'); } public function ToXml(DOMNode $oContainerNode) @@ -170,9 +207,9 @@ class DashletFakeBarChart extends Dashlet class DashletFakePieChart extends Dashlet { - public function __construct() + public function __construct($sId) { - + parent::__construct($sId); } public function FromDOMNode($oDOMNode) @@ -192,9 +229,7 @@ class DashletFakePieChart extends Dashlet public function Render($oPage, $bEditMode = false, $aExtraParams = array()) { - $oPage->add('
'); $oPage->add('
Fake Pie Chart
'); - $oPage->add('
'); } public function ToXml(DOMNode $oContainerNode)