mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 11:08:45 +02:00
N°1401 - External dashlet edition in the designer
SVN:trunk[5858]
This commit is contained in:
@@ -148,14 +148,10 @@ abstract class Dashboard
|
|||||||
protected function InitDashletFromDOMNode($oDomNode)
|
protected function InitDashletFromDOMNode($oDomNode)
|
||||||
{
|
{
|
||||||
$sId = $oDomNode->getAttribute('id');
|
$sId = $oDomNode->getAttribute('id');
|
||||||
$sClass = $oDomNode->getAttribute('xsi:type');
|
$sDashletType = $oDomNode->getAttribute('xsi:type');
|
||||||
|
|
||||||
// Test if dashlet can be instanciated, otherwise (uninstalled, broken, ...) we display a placeholder
|
// Test if dashlet can be instanciated, otherwise (uninstalled, broken, ...) we display a placeholder
|
||||||
$sDashletType = $sClass;
|
$sClass = static::GetDashletClassFromType($sDashletType);
|
||||||
if(!class_exists($sClass))
|
|
||||||
{
|
|
||||||
$sClass = 'DashletUnknown';
|
|
||||||
}
|
|
||||||
$oNewDashlet = new $sClass($this->oMetaModel, $sId);
|
$oNewDashlet = new $sClass($this->oMetaModel, $sId);
|
||||||
$oNewDashlet->SetDashletType($sDashletType);
|
$oNewDashlet->SetDashletType($sDashletType);
|
||||||
$oNewDashlet->FromDOMNode($oDomNode);
|
$oNewDashlet->FromDOMNode($oDomNode);
|
||||||
@@ -516,6 +512,15 @@ EOF
|
|||||||
}
|
}
|
||||||
|
|
||||||
abstract protected function SetFormParams($oForm);
|
abstract protected function SetFormParams($oForm);
|
||||||
|
|
||||||
|
public static function GetDashletClassFromType($sType, $oFactory = null)
|
||||||
|
{
|
||||||
|
if (is_subclass_of($sType, 'Dashlet'))
|
||||||
|
{
|
||||||
|
return $sType;
|
||||||
|
}
|
||||||
|
return 'DashletUnknown';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RuntimeDashboard extends Dashboard
|
class RuntimeDashboard extends Dashboard
|
||||||
|
|||||||
@@ -134,7 +134,14 @@ abstract class Dashlet
|
|||||||
public function FromXml($sXml)
|
public function FromXml($sXml)
|
||||||
{
|
{
|
||||||
$oDomDoc = new DOMDocument('1.0', 'UTF-8');
|
$oDomDoc = new DOMDocument('1.0', 'UTF-8');
|
||||||
|
libxml_clear_errors();
|
||||||
$oDomDoc->loadXml($sXml);
|
$oDomDoc->loadXml($sXml);
|
||||||
|
$aErrors = libxml_get_errors();
|
||||||
|
if (count($aErrors) > 0)
|
||||||
|
{
|
||||||
|
throw new DOMException("Malformed XML");
|
||||||
|
}
|
||||||
|
|
||||||
$this->FromDOMNode($oDomDoc->firstChild);
|
$this->FromDOMNode($oDomDoc->firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -379,7 +386,6 @@ class DashletUnknown extends Dashlet
|
|||||||
{
|
{
|
||||||
static protected $aClassList = null;
|
static protected $aClassList = null;
|
||||||
|
|
||||||
protected $sOriginalDashletClass;
|
|
||||||
protected $sOriginalDashletXML;
|
protected $sOriginalDashletXML;
|
||||||
|
|
||||||
public function __construct($oModelReflection, $sId)
|
public function __construct($oModelReflection, $sId)
|
||||||
@@ -423,8 +429,8 @@ class DashletUnknown extends Dashlet
|
|||||||
// For unknown dashlet, parameters are not parsed but passed as a raw xml
|
// For unknown dashlet, parameters are not parsed but passed as a raw xml
|
||||||
if(array_key_exists('xml', $aParams))
|
if(array_key_exists('xml', $aParams))
|
||||||
{
|
{
|
||||||
// A namspace must be present for the "xsi:type" attribute, otherwise a warning will be thrown.
|
// A namespace must be present for the "xsi:type" attribute, otherwise a warning will be thrown.
|
||||||
$sXML = '<dashlet id="'.$aParams['dashlet_id'].'" xsi:type="'.$aParams['dashlet_class'].'" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$aParams['xml'].'</dashlet>';
|
$sXML = '<dashlet id="'.$aParams['dashlet_id'].'" xsi:type="'.$aParams['dashlet_type'].'" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">'.$aParams['xml'].'</dashlet>';
|
||||||
$this->FromXml($sXML);
|
$this->FromXml($sXML);
|
||||||
}
|
}
|
||||||
$this->OnUpdate();
|
$this->OnUpdate();
|
||||||
@@ -481,7 +487,7 @@ class DashletUnknown extends Dashlet
|
|||||||
if($bHasSubProperties)
|
if($bHasSubProperties)
|
||||||
{
|
{
|
||||||
$sTmp = $oDOMNode->ownerDocument->saveXML($oDOMNode, LIBXML_NOENT);
|
$sTmp = $oDOMNode->ownerDocument->saveXML($oDOMNode, LIBXML_NOENT);
|
||||||
$sTmp = trim(preg_replace("/(<".$oDOMNode->tagName.".*>|<\/".$oDOMNode->tagName.">)/", "", $sTmp));
|
$sTmp = trim(preg_replace("/(<".$oDOMNode->tagName."[^>]*>|<\/".$oDOMNode->tagName.">)/", "", $sTmp));
|
||||||
return $sTmp;
|
return $sTmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -541,13 +547,24 @@ class DashletProxy extends DashletUnknown
|
|||||||
public function Render($oPage, $bEditMode = false, $aExtraParams = array())
|
public function Render($oPage, $bEditMode = false, $aExtraParams = array())
|
||||||
{
|
{
|
||||||
// This should never be called.
|
// This should never be called.
|
||||||
|
$oPage->add('<div class="dashlet-content">');
|
||||||
$oPage->add('<div>This dashlet is not supposed to be rendered as it is just a proxy for third-party widgets.</div>');
|
$oPage->add('<div>This dashlet is not supposed to be rendered as it is just a proxy for third-party widgets.</div>');
|
||||||
|
$oPage->add('</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array())
|
public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array())
|
||||||
{
|
{
|
||||||
// TODO
|
$aInfos = static::GetInfo();
|
||||||
$oPage->add('<div>RENDER NO DATA TO DO! (PREVIEW OR SO)</div>');
|
|
||||||
|
$sIconUrl = utils::GetAbsoluteUrlAppRoot().$aInfos['icon'];
|
||||||
|
$sExplainText = Dict::Format('UI:DashletProxy:RenderNoDataText:Edit', $this->GetDashletType());
|
||||||
|
|
||||||
|
$oPage->add('<div class="dashlet-content">');
|
||||||
|
|
||||||
|
$oPage->add('<div class="dashlet-pxy-image"><img src="'.$sIconUrl.'" /></div>');
|
||||||
|
$oPage->add('<div class="dashlet-pxy-text">'.$sExplainText.'</div>');
|
||||||
|
|
||||||
|
$oPage->add('</div>');
|
||||||
}
|
}
|
||||||
|
|
||||||
static public function GetInfo()
|
static public function GetInfo()
|
||||||
|
|||||||
@@ -2141,12 +2141,12 @@ td.prop_icon {
|
|||||||
.dashlet-content .display_block {
|
.dashlet-content .display_block {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
.dashlet-unknown .dashlet-content {
|
.dashlet-unknown .dashlet-content, .dashlet-proxy .dashlet-content {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
background-color: #f2f2f2;
|
background-color: #f2f2f2;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.dashlet-unknown .dashlet-content .dashlet-ukn-text {
|
.dashlet-unknown .dashlet-content .dashlet-ukn-text, .dashlet-proxy .dashlet-content .dashlet-ukn-text, .dashlet-unknown .dashlet-content .dashlet-pxy-text, .dashlet-proxy .dashlet-content .dashlet-pxy-text {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
.prop_apply .ui-icon-alert {
|
.prop_apply .ui-icon-alert {
|
||||||
|
|||||||
@@ -2464,13 +2464,13 @@ td.prop_icon {
|
|||||||
.dashlet-content .display_block {
|
.dashlet-content .display_block {
|
||||||
text-align:left;
|
text-align:left;
|
||||||
}
|
}
|
||||||
.dashlet-unknown {
|
.dashlet-unknown, .dashlet-proxy {
|
||||||
.dashlet-content {
|
.dashlet-content {
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
background-color: #F2F2F2;
|
background-color: #F2F2F2;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
||||||
.dashlet-ukn-text {
|
.dashlet-ukn-text, .dashlet-pxy-text {
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -478,7 +478,6 @@ Dict::Add('EN US', 'English', 'English', array(
|
|||||||
'UI:Menu:BulkDelete' => 'Delete...',
|
'UI:Menu:BulkDelete' => 'Delete...',
|
||||||
'UI:UndefinedObject' => 'undefined',
|
'UI:UndefinedObject' => 'undefined',
|
||||||
'UI:Document:OpenInNewWindow:Download' => 'Open in new window: %1$s, Download: %2$s',
|
'UI:Document:OpenInNewWindow:Download' => 'Open in new window: %1$s, Download: %2$s',
|
||||||
'UI:SelectAllToggle+' => 'Select / Deselect All',
|
|
||||||
'UI:SplitDateTime-Date' => 'date',
|
'UI:SplitDateTime-Date' => 'date',
|
||||||
'UI:SplitDateTime-Time' => 'time',
|
'UI:SplitDateTime-Time' => 'time',
|
||||||
'UI:TruncatedResults' => '%1$d objects displayed out of %2$d',
|
'UI:TruncatedResults' => '%1$d objects displayed out of %2$d',
|
||||||
@@ -1183,6 +1182,7 @@ When associated with a trigger, each action is given an "order" number, specifyi
|
|||||||
|
|
||||||
'UI:DashletProxy:Label' => 'Proxy',
|
'UI:DashletProxy:Label' => 'Proxy',
|
||||||
'UI:DashletProxy:Description' => 'Proxy dashlet',
|
'UI:DashletProxy:Description' => 'Proxy dashlet',
|
||||||
|
'UI:DashletProxy:RenderNoDataText:Edit' => 'No preview available for this third-party dashlet (class "%1$s").',
|
||||||
'UI:DashletProxy:Prop-XMLConfiguration' => 'Configuration (shown as raw XML)',
|
'UI:DashletProxy:Prop-XMLConfiguration' => 'Configuration (shown as raw XML)',
|
||||||
|
|
||||||
'UI:DashletPlainText:Label' => 'Text',
|
'UI:DashletPlainText:Label' => 'Text',
|
||||||
|
|||||||
@@ -1023,6 +1023,18 @@ Lors de l\'association à un déclencheur, on attribue à chaque action un numé
|
|||||||
'UI:Form:Property' => 'Propriété',
|
'UI:Form:Property' => 'Propriété',
|
||||||
'UI:Form:Value' => 'Valeur',
|
'UI:Form:Value' => 'Valeur',
|
||||||
|
|
||||||
|
'UI:DashletUnknown:Label' => 'Inconnu',
|
||||||
|
'UI:DashletUnknown:Description' => 'Element inconnu (est peut-être désinstallé)',
|
||||||
|
'UI:DashletUnknown:RenderText:View' => 'Impossible d\'effectuer le rendu de cet élément.',
|
||||||
|
'UI:DashletUnknown:RenderText:Edit' => 'Impossible d\'effectuer le rendu de cet élément (classe "%1$s"). Vérifiez avec votre administrateur si il est toujours disponible.',
|
||||||
|
'UI:DashletUnknown:RenderNoDataText:Edit' => 'Impossible d\'effectuer le rendu de cet élément (classe "%1$s").',
|
||||||
|
'UI:DashletUnknown:Prop-XMLConfiguration' => 'Configuration (XML)',
|
||||||
|
|
||||||
|
'UI:DashletProxy:Label' => 'Proxy',
|
||||||
|
'UI:DashletProxy:Description' => 'Proxy',
|
||||||
|
'UI:DashletProxy:RenderNoDataText:Edit' => 'Impossible d\'effectuer le rendu de cet élément externe (classe "%1$s").',
|
||||||
|
'UI:DashletProxy:Prop-XMLConfiguration' => 'Configuration (XML)',
|
||||||
|
|
||||||
'UI:DashletPlainText:Label' => 'Texte',
|
'UI:DashletPlainText:Label' => 'Texte',
|
||||||
'UI:DashletPlainText:Description' => 'Text pur (pas de mise en forme)',
|
'UI:DashletPlainText:Description' => 'Text pur (pas de mise en forme)',
|
||||||
'UI:DashletPlainText:Prop-Text' => 'Texte',
|
'UI:DashletPlainText:Prop-Text' => 'Texte',
|
||||||
|
|||||||
@@ -171,7 +171,7 @@ $(function()
|
|||||||
add_dashlet_finalize: function(options, sDashletId, sDashletClass)
|
add_dashlet_finalize: function(options, sDashletId, sDashletClass)
|
||||||
{
|
{
|
||||||
$('#dashlet_'+sDashletId)
|
$('#dashlet_'+sDashletId)
|
||||||
.dashlet({dashlet_id: sDashletId, dashlet_class: sDashletClass})
|
.dashlet({dashlet_id: sDashletId, dashlet_class: sDashletClass, dashlet_type: options.dashlet_type})
|
||||||
.dashlet('deselect_all')
|
.dashlet('deselect_all')
|
||||||
.dashlet('select')
|
.dashlet('select')
|
||||||
.draggable({
|
.draggable({
|
||||||
@@ -318,6 +318,7 @@ $(function()
|
|||||||
var sDashletClass = options.dashlet_class;
|
var sDashletClass = options.dashlet_class;
|
||||||
oParams.dashlet_class = sDashletClass;
|
oParams.dashlet_class = sDashletClass;
|
||||||
oParams.dashlet_id = sDashletId;
|
oParams.dashlet_id = sDashletId;
|
||||||
|
oParams.dashlet_type = options.dashlet_type;
|
||||||
var me = this;
|
var me = this;
|
||||||
$.post(this.options.render_to, oParams, function(data){
|
$.post(this.options.render_to, oParams, function(data){
|
||||||
me.ajax_div.html(data);
|
me.ajax_div.html(data);
|
||||||
|
|||||||
Reference in New Issue
Block a user