mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 00:28:47 +02:00
N°3123 - Changed the variables in application UIBlocks
This commit is contained in:
@@ -984,14 +984,14 @@ JS
|
||||
$aClasses = $this->m_oSet->GetSelectedClasses();
|
||||
$aAuthorizedClasses = [];
|
||||
$oBlock = new BlockList();
|
||||
$bEmptySet = false;
|
||||
$bNotAuthorized = false;
|
||||
$bCreateNew = false;
|
||||
$sLinkTarget = '';
|
||||
$sClass = '';
|
||||
$sParams = '';
|
||||
$sDefault = '';
|
||||
$sEventAttachedData = '';
|
||||
$oBlock->bEmptySet = false;
|
||||
$oBlock->bNotAuthorized = false;
|
||||
$oBlock->bCreateNew = false;
|
||||
$oBlock->sLinkTarget = '';
|
||||
$oBlock->sClass = '';
|
||||
$oBlock->sParams = '';
|
||||
$oBlock->sDefault = '';
|
||||
$oBlock->sEventAttachedData = '';
|
||||
|
||||
if (count($aClasses) > 1) {
|
||||
// Check the classes that can be read (i.e authorized) by this user...
|
||||
@@ -1010,37 +1010,36 @@ JS
|
||||
$oBlock->AddSubBlock(DataTableFactory::MakeForObject($oPage, $iListId, $this->m_oSet, $aExtraParams));
|
||||
} else {
|
||||
// Empty set
|
||||
$bEmptySet = true;
|
||||
$oBlock->bEmptySet = true;
|
||||
}
|
||||
} else {
|
||||
// Not authorized
|
||||
$bNotAuthorized = true;
|
||||
$oBlock->bNotAuthorized = true;
|
||||
}
|
||||
} else {
|
||||
// The list is made of only 1 class of objects, actions on the list are possible
|
||||
if (($this->m_oSet->CountWithLimit(1) > 0) && (UserRights::IsActionAllowed($this->m_oSet->GetClass(), UR_ACTION_READ, $this->m_oSet) == UR_ALLOWED_YES)) {
|
||||
$oBlock->AddSubBlock(cmdbAbstractObject::GetDisplaySetBlock($oPage, $this->m_oSet, $aExtraParams));
|
||||
} else {
|
||||
$bEmptySet = true;
|
||||
$sClass = $this->m_oFilter->GetClass();
|
||||
$oBlock->bEmptySet = true;
|
||||
$oBlock->sClass = $this->m_oFilter->GetClass();
|
||||
$bDisplayMenu = isset($aExtraParams['menu']) ? ($aExtraParams['menu'] == true) : true;
|
||||
if ($bDisplayMenu) {
|
||||
if ((UserRights::IsActionAllowed($sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES)) {
|
||||
$sLinkTarget = '';
|
||||
if ((UserRights::IsActionAllowed($oBlock->sClass, UR_ACTION_MODIFY) == UR_ALLOWED_YES)) {
|
||||
$oBlock->sLinkTarget = '';
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sParams = $oAppContext->GetForLink();
|
||||
$oBlock->sParams = $oAppContext->GetForLink();
|
||||
// 1:n links, populate the target object as a default value when creating a new linked object
|
||||
if (isset($aExtraParams['target_attr'])) {
|
||||
$sLinkTarget = ' target="_blank" ';
|
||||
$oBlock->sLinkTarget = ' target="_blank" ';
|
||||
$aExtraParams['default'][$aExtraParams['target_attr']] = $aExtraParams['object_id'];
|
||||
}
|
||||
$sDefault = '';
|
||||
if (!empty($aExtraParams['default'])) {
|
||||
foreach ($aExtraParams['default'] as $sKey => $sValue) {
|
||||
$sDefault .= "&default[$sKey]=$sValue";
|
||||
$oBlock->sDefault .= "&default[$sKey]=$sValue";
|
||||
}
|
||||
}
|
||||
$bCreateNew = true;
|
||||
$oBlock->bCreateNew = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1049,7 +1048,7 @@ JS
|
||||
$sSearchFilter = $this->m_oSet->GetFilter()->serialize();
|
||||
// Limit the size of the URL (N°1585 - request uri too long)
|
||||
if (strlen($sSearchFilter) < SERVER_MAX_URL_LENGTH) {
|
||||
$sEventAttachedData = json_encode(array(
|
||||
$oBlock->sEventAttachedData = json_encode(array(
|
||||
'filter' => $sSearchFilter,
|
||||
'breadcrumb_id' => "ui-search-".$this->m_oSet->GetClass(),
|
||||
'breadcrumb_label' => MetaModel::GetName($this->m_oSet->GetClass()),
|
||||
@@ -1062,18 +1061,6 @@ JS
|
||||
}
|
||||
}
|
||||
|
||||
$oBlock->AddParameter('bEmptySet', $bEmptySet);
|
||||
$oBlock->AddParameter('bNotAuthorized', $bNotAuthorized);
|
||||
$oBlock->AddParameter('bCreateNew', $bCreateNew);
|
||||
$oBlock->AddParameter('sLinkTarget', $sLinkTarget);
|
||||
$oBlock->AddParameter('sAbsoluteUrlAppRoot', utils::GetAbsoluteUrlAppRoot());
|
||||
$oBlock->AddParameter('sClass', $sClass);
|
||||
$oBlock->AddParameter('sParams', $sParams);
|
||||
if (!empty($sClass)) {
|
||||
$oBlock->AddParameter('sClassName', Metamodel::GetName($sClass));
|
||||
}
|
||||
$oBlock->AddParameter('sDefault', $sDefault);
|
||||
$oBlock->AddParameter('sEventAttachedData', $sEventAttachedData);
|
||||
|
||||
return $oBlock;
|
||||
}
|
||||
@@ -1239,8 +1226,8 @@ JS
|
||||
|
||||
$oBlock = new BlockChart();
|
||||
|
||||
$oBlock->AddParameter('iChartCounter', $iChartCounter);
|
||||
$oBlock->AddParameter('sId', $sId);
|
||||
$oBlock->iChartCounter = $iChartCounter;
|
||||
$oBlock->sId = $sId;
|
||||
|
||||
$sChartType = isset($aExtraParams['chart_type']) ? $aExtraParams['chart_type'] : 'pie';
|
||||
$sGroupBy = isset($aExtraParams['group_by']) ? $aExtraParams['group_by'] : '';
|
||||
@@ -1260,7 +1247,7 @@ JS
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot()."pages/ajax.render.php?operation=chart¶ms[group_by]=$sGroupBy{$sGroupByExpr}¶ms[chart_type]=$sChartType¶ms[currentId]=$sId{$iChartCounter}¶ms[order_direction]=$sOrderDirection¶ms[order_by]=$sOrderBy¶ms[limit]=$sLimit¶ms[aggregation_function]=$sAggregationFunction¶ms[aggregation_attribute]=$sAggregationAttr&id=$sId{$iChartCounter}&filter=".rawurlencode($sFilter).'&'.$sContextParam;
|
||||
}
|
||||
|
||||
$oBlock->AddParameter('sUrl', $sUrl);
|
||||
$oBlock->sUrl = $sUrl;
|
||||
|
||||
return $oBlock;
|
||||
}
|
||||
@@ -1311,13 +1298,11 @@ JS
|
||||
foreach ($aValues as $idx => $aValue) {
|
||||
$aNames[$idx] = $aValue['label'];
|
||||
}
|
||||
$sJSNames = json_encode($aNames);
|
||||
$sJson = json_encode($aValues);
|
||||
$oBlock = new BlockChartAjaxBars();
|
||||
$oBlock->AddParameter('sId', $sId);
|
||||
$oBlock->AddParameter('sJson', $sJson);
|
||||
$oBlock->AddParameter('sJSURLs', $sJSURLs);
|
||||
$oBlock->AddParameter('sJSNames', $sJSNames);
|
||||
$oBlock->sJSNames = json_encode($aNames);
|
||||
$oBlock->sJson = json_encode($aValues);
|
||||
$oBlock->sId = $sId;
|
||||
$oBlock->sJSURLs = $sJSURLs;
|
||||
break;
|
||||
|
||||
case 'pie':
|
||||
@@ -1327,13 +1312,11 @@ JS
|
||||
$aColumns[] = array('series_'.$idx, (int)$aValue['value']);
|
||||
$aNames['series_'.$idx] = $aValue['label'];
|
||||
}
|
||||
$sJSColumns = json_encode($aColumns);
|
||||
$sJSNames = json_encode($aNames);
|
||||
$oBlock = new BlockChartAjaxPie();
|
||||
$oBlock->AddParameter('sId', $sId);
|
||||
$oBlock->AddParameter('sJSColumns', $sJSColumns);
|
||||
$oBlock->AddParameter('sJSURLs', $sJSURLs);
|
||||
$oBlock->AddParameter('sJSNames', $sJSNames);
|
||||
$oBlock->sJSColumns = json_encode($aColumns);
|
||||
$oBlock->sJSNames = json_encode($aNames);
|
||||
$oBlock->sId = $sId;
|
||||
$oBlock->sJSURLs = $sJSURLs;
|
||||
break;
|
||||
}
|
||||
return $oBlock;
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
namespace Combodo\iTop\Application\UI\Specific\DisplayBlock\BlockChart;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\tBlockParams;
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
|
||||
/**
|
||||
@@ -22,5 +21,10 @@ class BlockChart extends UIBlock
|
||||
public const HTML_TEMPLATE_REL_PATH = 'specific/displayblock/blockchart/layout';
|
||||
public const JS_TEMPLATE_REL_PATH = 'specific/displayblock/blockchart/layout';
|
||||
|
||||
use tBlockParams;
|
||||
/** @var int */
|
||||
public $iChartCounter;
|
||||
/** @var string */
|
||||
public $sId;
|
||||
/** @var string */
|
||||
public $sUrl;
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
namespace Combodo\iTop\Application\UI\Specific\DisplayBlock\BlockChartAjaxBars;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\tBlockParams;
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
|
||||
/**
|
||||
@@ -21,5 +20,12 @@ class BlockChartAjaxBars extends UIBlock
|
||||
public const BLOCK_CODE = 'ibo-blockchartajaxbars';
|
||||
public const JS_TEMPLATE_REL_PATH = 'specific/displayblock/blockchartajaxbars/layout';
|
||||
|
||||
use tBlockParams;
|
||||
/** @var string */
|
||||
public $sJSNames;
|
||||
/** @var string */
|
||||
public $sJson;
|
||||
/** @var string */
|
||||
public $sId;
|
||||
/** @var string */
|
||||
public $sJSURLs;
|
||||
}
|
||||
@@ -7,7 +7,6 @@
|
||||
namespace Combodo\iTop\Application\UI\Specific\DisplayBlock\BlockChartAjaxPie;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\tBlockParams;
|
||||
use Combodo\iTop\Application\UI\UIBlock;
|
||||
|
||||
/**
|
||||
@@ -21,5 +20,12 @@ class BlockChartAjaxPie extends UIBlock
|
||||
public const BLOCK_CODE = 'ibo-blockchartajaxpie';
|
||||
public const JS_TEMPLATE_REL_PATH = 'specific/displayblock/blockchartajaxpie/layout';
|
||||
|
||||
use tBlockParams;
|
||||
/** @var string */
|
||||
public $sId;
|
||||
/** @var string */
|
||||
public $sJSColumns;
|
||||
/** @var string */
|
||||
public $sJSURLs;
|
||||
/** @var string */
|
||||
public $sJSNames;
|
||||
}
|
||||
@@ -8,7 +8,6 @@ namespace Combodo\iTop\Application\UI\Specific\DisplayBlock\BlockList;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\Layout\UIContentBlock;
|
||||
use Combodo\iTop\Application\UI\tBlockParams;
|
||||
|
||||
/**
|
||||
* Class BlockList
|
||||
@@ -22,5 +21,20 @@ class BlockList extends UIContentBlock
|
||||
public const HTML_TEMPLATE_REL_PATH = 'specific/displayblock/blocklist/layout';
|
||||
public const JS_TEMPLATE_REL_PATH = 'specific/displayblock/blocklist/layout';
|
||||
|
||||
use tBlockParams;
|
||||
/** @var bool */
|
||||
public $bEmptySet = false;
|
||||
/** @var bool */
|
||||
public $bNotAuthorized = false;
|
||||
/** @var bool */
|
||||
public $bCreateNew = false;
|
||||
/** @var string */
|
||||
public $sLinkTarget = '';
|
||||
/** @var string */
|
||||
public $sClass = '';
|
||||
/** @var string */
|
||||
public $sParams = '';
|
||||
/** @var string */
|
||||
public $sDefault = '';
|
||||
/** @var string */
|
||||
public $sEventAttachedData = '';
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @copyright Copyright (C) 2010-2020 Combodo SARL
|
||||
* @license http://opensource.org/licenses/AGPL-3.0
|
||||
*/
|
||||
|
||||
|
||||
namespace Combodo\iTop\Application\Specific\DisplayBlock;
|
||||
|
||||
|
||||
use Combodo\iTop\Application\UI\iUIBlock;
|
||||
use DBSearch;
|
||||
use DisplayBlock;
|
||||
use WebPage;
|
||||
|
||||
class DisplayBlockFactory
|
||||
{
|
||||
public static function GetUIBlockForList(DBSearch $oFilter, WebPage $oPage, $sId, $aFilterParams = array(), $aExtraParams = array()): iUIBlock
|
||||
{
|
||||
$oDisplayBlock = new DisplayBlock($oFilter, 'list', false, $aFilterParams);
|
||||
return $oDisplayBlock->GetDisplay($oPage, $sId, $aExtraParams);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
{# @copyright Copyright (C) 2010-2020 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
{% apply spaceless %}
|
||||
<div style="height:250px;width:100%" class="dashboard_chart" id="my_chart_{{ oUIBlock.GetParameter('sId') }}{{ oUIBlock.GetParameter('iChartCounter') }}">
|
||||
<div style="height:250px;width:100%" class="dashboard_chart" id="my_chart_{{ oUIBlock.sId }}{{ oUIBlock.iChartCounter }}">
|
||||
<div style="height:200px;line-height:200px;vertical-align:center;text-align:center;width:100%">
|
||||
<img src="../images/indicator.gif">
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{# @copyright Copyright (C) 2010-2020 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
{% apply spaceless %}
|
||||
$.post('{{ oUIBlock.GetParameter('sUrl')|escape_for_js_string|raw }}', {}, function (data) {
|
||||
$.post('{{ oUIBlock.sUrl|escape_for_js_string|raw }}', {}, function (data) {
|
||||
$('body').append(data);
|
||||
});
|
||||
{% endapply %}
|
||||
@@ -1,15 +1,15 @@
|
||||
{# @copyright Copyright (C) 2010-2020 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
var chart = c3.generate({
|
||||
bindto: d3.select('#my_chart_{{ oUIBlock.GetParameter('sId') }}'),
|
||||
bindto: d3.select('#my_chart_{{ oUIBlock.sId }}'),
|
||||
data: {
|
||||
json: {{ oUIBlock.GetParameter('sJson')|raw }},
|
||||
json: {{ oUIBlock.sJson|raw }},
|
||||
keys: {
|
||||
x: 'label',
|
||||
value: ["value"]
|
||||
},
|
||||
onclick: function (d) {
|
||||
var aURLs = {{ oUIBlock.GetParameter('sJSURLs')|raw }};
|
||||
var aURLs = {{ oUIBlock.sJSURLs|raw }};
|
||||
window.location.href = aURLs[d.index];
|
||||
},
|
||||
selection: {
|
||||
@@ -41,7 +41,7 @@ var chart = c3.generate({
|
||||
format: {
|
||||
title: function() { return '' },
|
||||
name: function (name, ratio, id, index) {
|
||||
var aNames = {{ oUIBlock.GetParameter('sJSNames')|raw }};
|
||||
var aNames = {{ oUIBlock.sJSNames|raw }};
|
||||
return aNames[index];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
|
||||
var chart = c3.generate({
|
||||
bindto: d3.select('#my_chart_{{ oUIBlock.GetParameter('sId') }}'),
|
||||
bindto: d3.select('#my_chart_{{ oUIBlock.sId }}'),
|
||||
data: {
|
||||
columns: {{ oUIBlock.GetParameter('sJSColumns')|raw }},
|
||||
columns: {{ oUIBlock.sJSColumns|raw }},
|
||||
type: 'pie',
|
||||
names: {{ oUIBlock.GetParameter('sJSNames')|raw }},
|
||||
onclick: function (d, element) {
|
||||
var aURLs = {{ oUIBlock.GetParameter('sJSURLs')|raw }};
|
||||
names: {{ oUIBlock.sJSNames|raw }},
|
||||
onclick: function (d) {
|
||||
var aURLs = {{ oUIBlock.sJSURLs|raw }};
|
||||
window.location.href= aURLs[d.index];
|
||||
},
|
||||
order: null
|
||||
|
||||
@@ -2,18 +2,14 @@
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
{% apply spaceless %}
|
||||
|
||||
{% if oUIBlock.GetParameter('bEmptySet') %}
|
||||
{% if oUIBlock.bEmptySet or oUIBlock.bNotAuthorized %}
|
||||
<p>{{ 'UI:NoObjectToDisplay'|dict_s }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if oUIBlock.GetParameter('bNotAuthorized') %}
|
||||
<p>{{ 'UI:NoObjectToDisplay'|dict_s }}</p>
|
||||
{% endif %}
|
||||
|
||||
{% if oUIBlock.GetParameter('bCreateNew') %}
|
||||
{% if oUIBlock.bCreateNew %}
|
||||
<p>
|
||||
<a{{ oUIBlock.GetParameter('sLinkTarget') }} href="{{ oUIBlock.GetParameter('sAbsoluteUrlAppRoot') }}pages/UI.php?operation=new&class={{ oUIBlock.GetParameter('sClass') }}&{{ oUIBlock.GetParameter('sParams') }}{{ oUIBlock.GetParameter('sDefault') }}">
|
||||
{{ 'UI:ClickToCreateNew'|dict_format(oUIBlock.GetParameter('sClassName')) }}
|
||||
<a{{ oUIBlock.sLinkTarget }} href="{{ oUIBlock.sAbsoluteUrlAppRoot }}pages/UI.php?operation=new&class={{ oUIBlock.sClass }}&{{ oUIBlock.sParams }}{{ oUIBlock.sDefault }}">
|
||||
{{ 'UI:ClickToCreateNew'|dict_format(oUIBlock.sClassName) }}
|
||||
</a>
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{# @copyright Copyright (C) 2010-2020 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
{% apply spaceless %}
|
||||
{% if oUIBlock.GetParameter('sEventAttachedData') is not empty %}
|
||||
$('body').trigger('update_history.itop', [{{ oUIBlock.GetParameter('sEventAttachedData')|raw }}]);
|
||||
{% if oUIBlock.sEventAttachedData is not empty %}
|
||||
$('body').trigger('update_history.itop', [{{ oUIBlock.sEventAttachedData|raw }}]);
|
||||
{% endif %}
|
||||
{% endapply %}
|
||||
Reference in New Issue
Block a user