From a173c6debcf78c0588317182f5bda70cd1e6922d Mon Sep 17 00:00:00 2001 From: diosmosis <benaka@piwik.pro> Date: Sat, 20 Sep 2014 12:21:17 -0700 Subject: [PATCH] Refs #6078, fix bug where reloading report does not persist pivot and where undoing a saved pivot does nothing. --- core/ViewDataTable/Request.php | 5 +++- core/ViewDataTable/RequestConfig.php | 33 +++++++++++++++++++++-- plugins/CoreHome/javascripts/dataTable.js | 4 +-- 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/core/ViewDataTable/Request.php b/core/ViewDataTable/Request.php index 324803aa91..9493889944 100644 --- a/core/ViewDataTable/Request.php +++ b/core/ViewDataTable/Request.php @@ -74,7 +74,10 @@ class Request 'filter_column', 'filter_pattern', 'flat', - 'expanded' + 'expanded', + 'pivotBy', + 'pivotByColumn', + 'pivotByColumnLimit' ); foreach ($toSetEventually as $varToSet) { diff --git a/core/ViewDataTable/RequestConfig.php b/core/ViewDataTable/RequestConfig.php index ad77df8824..102fa68018 100644 --- a/core/ViewDataTable/RequestConfig.php +++ b/core/ViewDataTable/RequestConfig.php @@ -90,7 +90,10 @@ class RequestConfig 'filter_column', 'filter_offset', 'flat', - 'expanded' + 'expanded', + 'pivotBy', + 'pivotByColumn', + 'pivotByColumnLimit' ); /** @@ -108,7 +111,10 @@ class RequestConfig 'disable_generic_filters', 'disable_queued_filters', 'flat', - 'expanded' + 'expanded', + 'pivotBy', + 'pivotByColumn', + 'pivotByColumnLimit' ); /** @@ -232,6 +238,29 @@ class RequestConfig */ public $idSubtable = false; + /** + * Dimension ID to pivot by. See {@link Piwik\DataTable\Filter\PivotByDimension} for more info. + * + * @var string + */ + public $pivotBy = false; + + /** + * The column to display in a pivot table, eg, `'nb_visits'`. See {@link Piwik\DataTable\Filter\PivotByDimension} + * for more info. + * + * @var string + */ + public $pivotByColumn = false; + + /** + * The maximum number of columns to display in a pivot table. See {@link Piwik\DataTable\Filter\PivotByDimension} + * for more info. + * + * @var int + */ + public $pivotByColumnLimit = false; + public function getProperties() { return get_object_vars($this); diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index 1c44546803..e316804394 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -1270,8 +1270,8 @@ $.extend(DataTable.prototype, UIControl.prototype, { }) .click(generateClickCallback('pivotBy', null, function () { if (self.param.pivotBy) { - self.param.pivotBy = ''; - self.param.pivotByColumn = ''; + self.param.pivotBy = '0'; // set to '0' so it will be sent in the request and override the saved param + self.param.pivotByColumn = '0'; } else { self.param.pivotBy = self.props.pivot_by_dimension; if (self.props.pivot_by_column) { -- GitLab