From f3b0f79a593968c6ddb1e38d3f3286794e8239e7 Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 12 May 2021 15:42:57 +0200 Subject: [PATCH] =?UTF-8?q?N=C2=B03796=20-=20Make=20designer=20compatible?= =?UTF-8?q?=20with=20iTop=203.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/dashlet.class.inc.php | 52 ++++++++++++------- js/dashboard.js | 4 +- setup/itopdesignformat.class.inc.php | 14 ++--- .../dashlet/dashlet-header-static.html.twig | 2 +- 4 files changed, 43 insertions(+), 29 deletions(-) diff --git a/application/dashlet.class.inc.php b/application/dashlet.class.inc.php index 4b07f6463..a614cc156 100644 --- a/application/dashlet.class.inc.php +++ b/application/dashlet.class.inc.php @@ -926,24 +926,36 @@ class DashletObjectList extends Dashlet */ public function RenderNoData($oPage, $bEditMode = false, $aExtraParams = array()) { + $oDashletContainer = new DashletContainer($this->sId, ['dashlet-content']); $sTitle = $this->aProperties['title']; $sQuery = $this->aProperties['query']; $bShowMenu = $this->aProperties['menu']; - - $oPage->add('
'); - $sHtmlTitle = utils::HtmlEntities($this->oModelReflection->DictString($sTitle)); // done in the itop block + $sHtmlTitle = utils::HtmlEntities($this->oModelReflection->DictString($sTitle)); if ($sHtmlTitle != '') { - $oPage->add('

'.$sHtmlTitle.'

'); + $sHtmlTitle = '

'.$sHtmlTitle.'

'; } $oQuery = $this->oModelReflection->GetQuery($sQuery); $sClass = $oQuery->GetClass(); - $oPage->add('
'); - $oPage->p(Dict::S('UI:NoObjectToDisplay')); + $sId = $this->sId; + $sMessage = Dict::S('UI:NoObjectToDisplay'); + $sMenu = ''; if ($bShowMenu) { - $oPage->p(''.Dict::Format('UI:ClickToCreateNew', $this->oModelReflection->GetName($sClass)).''); + $sMenu = '

'.Dict::Format('UI:ClickToCreateNew', $this->oModelReflection->GetName($sClass)).'

'; } - $oPage->add('
'); - $oPage->add('
'); + + $sHtml = << +

$sHtmlTitle

+
+

$sMessage

+$sMenu +
+ +HTML; + + $oDashletContainer->AddHtml($sHtml); + + return $oDashletContainer; } public function GetDBSearch($aExtraParams = array()) @@ -2127,7 +2139,6 @@ class DashletHeaderDynamic extends Dashlet $sHtml .= ''.utils::HtmlEntities($sSubtitle).''; $sHtml .= ''; - $sHtml .= ''; $oDashletContainer->AddHtml($sHtml); @@ -2309,18 +2320,19 @@ class DashletBadge extends Dashlet $oDashletContainer = new DashletContainer($this->sId, ['dashlet-content']); $sClass = $this->aProperties['class']; - $sIconUrl = $this->oModelReflection->GetClassIcon($sClass, false); + $sIconUrl = utils::HtmlEntities($this->oModelReflection->GetClassIcon($sClass, false)); $sClassLabel = $this->oModelReflection->GetName($sClass); + $sId = $this->sId; + $sClassCreate = Dict::Format('UI:ClickToCreateNew', $sClassLabel); - $sHtml = ''; - $sHtml .= '
'; - $sHtml .= '

'; - $sHtml .= ' '.$sClassLabel.': 947'; - $sHtml .= '

'; - $sHtml .= '

'; - $sHtml .= ' '.Dict::Format('UI:ClickToCreateNew', $sClassLabel).''; - $sHtml .= '

'; - $sHtml .= '
'; + $sHtml = << +
+
+ +
+ +HTML; $oDashletContainer->AddHtml($sHtml); diff --git a/js/dashboard.js b/js/dashboard.js index dc5680732..901ebce2f 100644 --- a/js/dashboard.js +++ b/js/dashboard.js @@ -137,13 +137,13 @@ $(function() }, add_dashlet: function (options) { var $container = options.container; - var aDashletsIds = $container.closest(".ibo-dashboard--grid-row").find("div.ibo-dashlet").map(function () { + var aDashletsIds = $container.closest('[data-role="ibo-dashboard--grid"]').find('[data-role="ibo-dashlet"]').map(function () { // Note: // - At runtime a unique dashlet ID is generated (see \Dashboard::GetDashletUniqueId) to avoid JS widget collisions // - At design time, the dashlet ID is not touched (same as in the XML datamodel) var sDashletUniqueId = $(this).attr("id"); var sDashletIdParts = sDashletUniqueId.split('_'); - var sDashletOrigId = sDashletIdParts[sDashletIdParts.length - 1]; + var sDashletOrigId = sDashletIdParts[sDashletIdParts.length-1]; return isNaN(parseInt(sDashletOrigId)) ? 0 : parseInt(sDashletOrigId); }).get(); // avoid empty array for IE diff --git a/setup/itopdesignformat.class.inc.php b/setup/itopdesignformat.class.inc.php index 73950a3b5..619083ed9 100644 --- a/setup/itopdesignformat.class.inc.php +++ b/setup/itopdesignformat.class.inc.php @@ -895,13 +895,15 @@ class iTopDesignFormat $oNodeList = $oXPath->query("/itop_design/classes//class/fields/field[@xsi:type='AttributeEnum']/values/value"); foreach ($oNodeList as $oNode) { $oCodeNode = $oXPath->query('code', $oNode)->item(0); - $sCode = $oCodeNode->textContent; - $this->DeleteNode($oCodeNode); - $oStyleNode = $oXPath->query('style', $oNode)->item(0); - if ($oStyleNode) { - $this->DeleteNode($oStyleNode); + if ($oCodeNode) { + $sCode = $oCodeNode->textContent; + $this->DeleteNode($oCodeNode); + $oStyleNode = $oXPath->query('style', $oNode)->item(0); + if ($oStyleNode) { + $this->DeleteNode($oStyleNode); + } + $oNode->textContent = $sCode; } - $oNode->textContent = $sCode; } $sPath = "/itop_design/classes//class/fields/field[@xsi:type='AttributeEnum']/default_style"; diff --git a/templates/base/components/dashlet/dashlet-header-static.html.twig b/templates/base/components/dashlet/dashlet-header-static.html.twig index 8c14bdaca..17b4f36ea 100644 --- a/templates/base/components/dashlet/dashlet-header-static.html.twig +++ b/templates/base/components/dashlet/dashlet-header-static.html.twig @@ -5,7 +5,7 @@
{% if oUIBlock.GetIconUrl() is not empty %}
- {{ oUIBlock.GetTitle() }} + {{ oUIBlock.GetTitle() }}
{% endif %} {% if oUIBlock.GetTitle() is not empty %}