N°3804 - auto refresh on group by dashlet (and dashlet badge) lost user preferences on showing obsolete data

This commit is contained in:
Eric
2021-03-16 10:25:18 +01:00
parent 168d3c5b75
commit 7c8349f4f5
3 changed files with 15 additions and 19 deletions

View File

@@ -2052,6 +2052,7 @@ class DashletHeaderDynamic extends Dashlet
$aQueryParams = array(); $aQueryParams = array();
} }
$oFilter = DBObjectSearch::FromOQL($sQuery, $aQueryParams); $oFilter = DBObjectSearch::FromOQL($sQuery, $aQueryParams);
$oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
$sClass = $oFilter->GetClass(); $sClass = $oFilter->GetClass();
$oPanel = PanelUIBlockFactory::MakeNeutral(Dict::S(str_replace('_', ':', $sTitle))) $oPanel = PanelUIBlockFactory::MakeNeutral(Dict::S(str_replace('_', ':', $sTitle)))

View File

@@ -87,7 +87,7 @@ try
case 'refreshDashletCount': case 'refreshDashletCount':
$oPage->SetContentType('application/json'); $oPage->SetContentType('application/json');
$aResult = AjaxRenderController::RefreshCount($sFilter); $aResult = AjaxRenderController::RefreshDashletCount($sFilter);
$oPage->add(json_encode($aResult)); $oPage->add(json_encode($aResult));
break; break;
@@ -102,6 +102,7 @@ try
$sExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data'); $sExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data');
$aExtraParams = json_decode($sExtraParams, true); $aExtraParams = json_decode($sExtraParams, true);
$oFilter = DBObjectSearch::FromOQL($sFilter); $oFilter = DBObjectSearch::FromOQL($sFilter);
$oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
$oSet = new CMDBObjectSet($oFilter, [], $aExtraParams); $oSet = new CMDBObjectSet($oFilter, [], $aExtraParams);
$oBlock = new displayblock($oFilter, 'summary', false, [], $oSet); $oBlock = new displayblock($oFilter, 'summary', false, [], $oSet);
$oBlock->RenderContent($oPage, $aExtraParams); $oBlock->RenderContent($oPage, $aExtraParams);
@@ -508,13 +509,13 @@ try
// ui.linkswidget // ui.linkswidget
case 'doAddObjects': case 'doAddObjects':
$oPage->SetContentType('text/html'); $oPage->SetContentType('text/html');
$sResult = AjaxRenderController::DoAddObjects($oPage, $sClass, $sFilter); AjaxRenderController::DoAddObjects($oPage, $sClass, $sFilter);
break; break;
// ui.linkswidget // ui.linkswidget
case 'doAddIndirectLinks': case 'doAddIndirectLinks':
$oPage = new JsonPage(''); $oPage = new JsonPage('');
$sResult = AjaxRenderController::DoAddIndirectLinks($oPage, $sClass, $sFilter); AjaxRenderController::DoAddIndirectLinks($oPage, $sClass, $sFilter);
break; break;
//////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////
/// WizardHelper : see the corresponding PHP class, and JS class /// WizardHelper : see the corresponding PHP class, and JS class

View File

@@ -10,13 +10,16 @@ use AjaxPage;
use ApplicationContext; use ApplicationContext;
use ApplicationMenu; use ApplicationMenu;
use AttributeLinkedSet; use AttributeLinkedSet;
use AttributeOneWayPassword;
use BinaryExpression; use BinaryExpression;
use BulkExport; use BulkExport;
use BulkExportException; use BulkExportException;
use CMDBObjectSet; use CMDBObjectSet;
use CMDBSource; use CMDBSource;
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableSettings;
use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory; use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntryFactory; use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityEntry\ActivityEntryFactory;
use Combodo\iTop\Application\UI\Base\Layout\ActivityPanel\ActivityPanelHelper;
use Combodo\iTop\Renderer\BlockRenderer; use Combodo\iTop\Renderer\BlockRenderer;
use DBObjectSearch; use DBObjectSearch;
use DBObjectSet; use DBObjectSet;
@@ -25,6 +28,8 @@ use Dict;
use Exception; use Exception;
use ExecutionKPI; use ExecutionKPI;
use Expression; use Expression;
use FieldExpression;
use FunctionExpression;
use InlineImage; use InlineImage;
use JsonPage; use JsonPage;
use MetaModel; use MetaModel;
@@ -234,10 +239,8 @@ class AjaxRenderController
// The first column is used for the selection (radio / checkbox) and is not sortable // The first column is used for the selection (radio / checkbox) and is not sortable
$iSortCol--; $iSortCol--;
} }
$bDisplayKey = utils::ReadParam('display_key', 'true') == 'true';
$aColumns = utils::ReadParam('columns', array(), false, 'raw_data'); $aColumns = utils::ReadParam('columns', array(), false, 'raw_data');
$aClassAliases = utils::ReadParam('class_aliases', array()); $aClassAliases = utils::ReadParam('class_aliases', array());
$iListId = utils::ReadParam('list_id', 0);
// Filter the list to removed linked set since we are not able to display them here // Filter the list to removed linked set since we are not able to display them here
$sIdName = ""; $sIdName = "";
@@ -329,6 +332,7 @@ class AjaxRenderController
array_push($aResult["data"], $aObj); array_push($aResult["data"], $aObj);
} }
} }
$oKPI->ComputeAndReport('Data fetch and format');
return $aResult; return $aResult;
} }
@@ -487,14 +491,12 @@ class AjaxRenderController
} }
/** /**
* @param string $sEncoding * @param string $sStyle
* @param string $sFilter * @param string $sFilter
* *
* @return array * @return array
* @throws \ArchivedObjectException * @throws \ArchivedObjectException
* @throws \CoreException * @throws \CoreException
* @throws \CoreUnexpectedValue
* @throws \DictExceptionMissingString
* @throws \MissingQueryArgument * @throws \MissingQueryArgument
* @throws \MySQLException * @throws \MySQLException
* @throws \MySQLHasGoneAwayException * @throws \MySQLHasGoneAwayException
@@ -504,17 +506,16 @@ class AjaxRenderController
{ {
$aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data'); $aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data');
$oFilter = DBObjectSearch::FromOQL($sFilter); $oFilter = DBObjectSearch::FromOQL($sFilter);
$oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
if (isset($aExtraParams['group_by'])) { if (isset($aExtraParams['group_by'])) {
$sAlias = $oFilter->GetClassAlias(); $sAlias = $oFilter->GetClassAlias();
if (isset($aExtraParams['group_by_label'])) { if (isset($aExtraParams['group_by_label'])) {
$oGroupByExp = Expression::FromOQL($aExtraParams['group_by']); $oGroupByExp = Expression::FromOQL($aExtraParams['group_by']);
$sGroupByLabel = $aExtraParams['group_by_label'];
} else { } else {
// Backward compatibility: group_by is simply a field id // Backward compatibility: group_by is simply a field id
$oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias); $oGroupByExp = new FieldExpression($aExtraParams['group_by'], $sAlias);
$sGroupByLabel = MetaModel::GetLabel($oFilter->GetClass(), $aExtraParams['group_by']);
} }
// Security filtering // Security filtering
@@ -537,9 +538,7 @@ class AjaxRenderController
$aQueryParams = $aExtraParams['query_params']; $aQueryParams = $aExtraParams['query_params'];
} }
$aFunctions = array(); $aFunctions = array();
$sAggregationFunction = 'count';
$sFctVar = '_itop_count_'; $sFctVar = '_itop_count_';
$sAggregationAttr = '';
if (isset($aExtraParams['aggregation_function']) && !empty($aExtraParams['aggregation_attribute'])) { if (isset($aExtraParams['aggregation_function']) && !empty($aExtraParams['aggregation_attribute'])) {
$sAggregationFunction = $aExtraParams['aggregation_function']; $sAggregationFunction = $aExtraParams['aggregation_function'];
$sAggregationAttr = $aExtraParams['aggregation_attribute']; $sAggregationAttr = $aExtraParams['aggregation_attribute'];
@@ -549,10 +548,6 @@ class AjaxRenderController
$aFunctions = array($sFctVar => $oFctExpr); $aFunctions = array($sFctVar => $oFctExpr);
} }
if (!empty($sAggregationAttr)) {
$sClass = $oFilter->GetClass();
$sAggregationAttr = MetaModel::GetLabel($sClass, $sAggregationAttr);
}
$iLimit = 0; $iLimit = 0;
if (isset($aExtraParams['limit'])) { if (isset($aExtraParams['limit'])) {
$iLimit = intval($aExtraParams['limit']); $iLimit = intval($aExtraParams['limit']);
@@ -636,10 +631,11 @@ class AjaxRenderController
* @throws \MySQLHasGoneAwayException * @throws \MySQLHasGoneAwayException
* @throws \OQLException * @throws \OQLException
*/ */
public static function RefreshCount(string $sFilter): array public static function RefreshDashletCount(string $sFilter): array
{ {
$aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data'); $aExtraParams = utils::ReadParam('extra_params', '', false, 'raw_data');
$oFilter = DBObjectSearch::FromOQL($sFilter); $oFilter = DBObjectSearch::FromOQL($sFilter);
$oFilter->SetShowObsoleteData(utils::ShowObsoleteData());
$oSet = new CMDBObjectSet($oFilter, [], $aExtraParams); $oSet = new CMDBObjectSet($oFilter, [], $aExtraParams);
$iCount = $oSet->Count(); $iCount = $oSet->Count();
@@ -651,7 +647,6 @@ class AjaxRenderController
/** /**
* @param string $sFilter * @param string $sFilter
* *
* @return string
* @throws \ArchivedObjectException * @throws \ArchivedObjectException
* @throws \CoreException * @throws \CoreException
* @throws \OQLException * @throws \OQLException
@@ -682,7 +677,6 @@ class AjaxRenderController
/** /**
* @param string $sFilter * @param string $sFilter
* *
* @return string
* @throws \ArchivedObjectException * @throws \ArchivedObjectException
* @throws \CoreException * @throws \CoreException
* @throws \OQLException * @throws \OQLException