Skip to content
Extraits de code Groupes Projets
Valider 464be65c rédigé par sgiehl's avatar sgiehl
Parcourir les fichiers

handle PivotBy within HtmlTable visualization to fix side effects

parent a4c0f65f
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -29,8 +29,7 @@ class CoreVisualizations extends \Piwik\Plugin ...@@ -29,8 +29,7 @@ class CoreVisualizations extends \Piwik\Plugin
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles', 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'AssetManager.getJavaScriptFiles' => 'getJsFiles', 'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys', 'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys',
'UsersManager.deleteUser' => 'deleteUser', 'UsersManager.deleteUser' => 'deleteUser'
'ViewDataTable.addViewDataTable' => 'addViewDataTable'
); );
} }
...@@ -39,23 +38,6 @@ class CoreVisualizations extends \Piwik\Plugin ...@@ -39,23 +38,6 @@ class CoreVisualizations extends \Piwik\Plugin
ViewDataTableManager::clearUserViewDataTableParameters($userLogin); ViewDataTableManager::clearUserViewDataTableParameters($userLogin);
} }
public function addViewDataTable(&$viewDataTable)
{
// Both are the same HtmlTable, just the Pivot one has some extra logic in case Pivot is used.
// We don't want to use the same HtmlTable twice in the UI. Therefore we always need to remove one.
if (Common::getRequestVar('pivotBy', '')) {
$tableToRemove = 'Visualizations\HtmlTable';
} else {
$tableToRemove = 'HtmlTable\PivotBy';
}
foreach ($viewDataTable as $index => $table) {
if (Common::stringEndsWith($table, $tableToRemove)) {
unset($viewDataTable[$index]);
}
}
}
public function getStylesheetFiles(&$stylesheets) public function getStylesheetFiles(&$stylesheets)
{ {
$stylesheets[] = "plugins/CoreVisualizations/stylesheets/dataTableVisualizations.less"; $stylesheets[] = "plugins/CoreVisualizations/stylesheets/dataTableVisualizations.less";
......
...@@ -70,6 +70,25 @@ class HtmlTable extends Visualization ...@@ -70,6 +70,25 @@ class HtmlTable extends Visualization
$dataTable = $request->process(); $dataTable = $request->process();
$this->assignTemplateVar('siteSummary', $dataTable); $this->assignTemplateVar('siteSummary', $dataTable);
} }
if ($this->isPivoted()) {
$this->config->columns_to_display = $this->dataTable->getColumns();
}
}
public function beforeGenericFiltersAreAppliedToLoadedDataTable()
{
if ($this->isPivoted()) {
$this->config->columns_to_display = $this->dataTable->getColumns();
$this->dataTable->applyQueuedFilters();
}
parent::beforeGenericFiltersAreAppliedToLoadedDataTable();
} }
protected function isPivoted()
{
return $this->requestConfig->pivotBy || Common::getRequestVar('pivotBy', '');
}
} }
<?php
/**
* Piwik - free/libre analytics platform
*
* @link http://piwik.org
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
*
*/
namespace Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
use Piwik\DataTable;
use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable;
use Piwik\View;
/**
* DataTable Visualization that derives from HtmlTable and sets show_extra_columns to true.
*/
class PivotBy extends HtmlTable
{
public function beforeGenericFiltersAreAppliedToLoadedDataTable()
{
$this->config->columns_to_display = $this->dataTable->getColumns();
$this->dataTable->applyQueuedFilters();
parent::beforeGenericFiltersAreAppliedToLoadedDataTable();
}
public function beforeRender()
{
parent::beforeRender();
$this->config->columns_to_display = $this->dataTable->getColumns();
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter