N°3796 - Make designer compatible with iTop 3.0

This commit is contained in:
Eric
2021-05-12 15:42:57 +02:00
parent eaae79a5f0
commit f3b0f79a59
4 changed files with 43 additions and 29 deletions

View File

@@ -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('<div class="dashlet-content">');
$sHtmlTitle = utils::HtmlEntities($this->oModelReflection->DictString($sTitle)); // done in the itop block
$sHtmlTitle = utils::HtmlEntities($this->oModelReflection->DictString($sTitle));
if ($sHtmlTitle != '') {
$oPage->add('<h1>'.$sHtmlTitle.'</h1>');
$sHtmlTitle = '<h1>'.$sHtmlTitle.'</h1>';
}
$oQuery = $this->oModelReflection->GetQuery($sQuery);
$sClass = $oQuery->GetClass();
$oPage->add('<div id="block_fake_'.$this->sId.'" class="display_block">');
$oPage->p(Dict::S('UI:NoObjectToDisplay'));
$sId = $this->sId;
$sMessage = Dict::S('UI:NoObjectToDisplay');
$sMenu = '';
if ($bShowMenu) {
$oPage->p('<a>'.Dict::Format('UI:ClickToCreateNew', $this->oModelReflection->GetName($sClass)).'</a>');
$sMenu = '<p><a>'.Dict::Format('UI:ClickToCreateNew', $this->oModelReflection->GetName($sClass)).'</a></p>';
}
$oPage->add('</div>');
$oPage->add('</div>');
$sHtml = <<<HTML
<div class="dashlet-content">
<h1>$sHtmlTitle</h1>
<div id="block_fake_$sId" class="display_block">
<p>$sMessage</p>
$sMenu
</div>
</div>
HTML;
$oDashletContainer->AddHtml($sHtml);
return $oDashletContainer;
}
public function GetDBSearch($aExtraParams = array())
@@ -2127,7 +2139,6 @@ class DashletHeaderDynamic extends Dashlet
$sHtml .= '<a class="summary">'.utils::HtmlEntities($sSubtitle).'</a>';
$sHtml .= '</div>';
$sHtml .= '</div>';
$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 .= '<div id="block_fake_'.$this->sId.'" class="display_block">';
$sHtml .= '<p>';
$sHtml .= ' <a class="actions"><img src="'.utils::HtmlEntities($sIconUrl).'" style="vertical-align:middle;float;left;margin-right:10px;border:0;">'.$sClassLabel.': 947</a>';
$sHtml .= '</p>';
$sHtml .= '<p>';
$sHtml .= ' <a>'.Dict::Format('UI:ClickToCreateNew', $sClassLabel).'</a>';
$sHtml .= '</p>';
$sHtml .= '</div>';
$sHtml = <<<HTML
<div id="block_fake_$sId" class="display_block">
<div class="ibo-dashlet-badge--body" data-role="ibo-dashlet-badge--body" title="$sClassLabel">
<div class="ibo-dashlet-badge--icon-container"><img class="ibo-dashlet-badge--icon" src="$sIconUrl"></div>
<div class="ibo-dashlet-badge--actions"><a class="ibo-dashlet-badge--action-list" href="#" data-role="ibo-dashlet-badge--action-list"><span class="ibo-dashlet-badge--action-list-count">4</span><span class="ibo-dashlet-badge--action-list-label">$sClassLabel</span></a><a class="ibo-dashlet-badge--action-create" href="#"><span class="ibo-dashlet-badge--action-create-icon fas fa-plus"></span><span class="ibo-dashlet-badge--action-create-label"> $sClassCreate </span></a></div>
</div>
</div>
HTML;
$oDashletContainer->AddHtml($sHtml);

View File

@@ -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

View File

@@ -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";

View File

@@ -5,7 +5,7 @@
<div class="ibo-dashlet-header-static--body">
{% if oUIBlock.GetIconUrl() is not empty %}
<div class="ibo-dashlet-header-static--icon-container">
<img class="ibo-dashlet-header-static--icon" src="{{ oUIBlock.GetIconUrl() }}" alt="{{ oUIBlock.GetTitle() }}">
<img class="ibo-dashlet-header-static--icon" src="{{ oUIBlock.GetIconUrl()|raw }}" alt="{{ oUIBlock.GetTitle() }}">
</div>
{% endif %}
{% if oUIBlock.GetTitle() is not empty %}