Skip to content

Commit

Permalink
refs matomo-org#1915 persist selected metrics and rows in referrers e…
Browse files Browse the repository at this point in the history
…volution
  • Loading branch information
tsteur committed May 2, 2014
1 parent ce33725 commit 80d8d01
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
3 changes: 2 additions & 1 deletion plugins/CoreVisualizations/javascripts/seriesPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@

// inform dashboard widget about changed parameters (to be restored on reload)
var UI = require('piwik/UI')
var params = {columns: columns, rows: rows, columns_to_display: columns};
var params = {columns: columns, columns_to_display: columns,
rows: rows, rows_to_display: rows};
var tableNode = $('#' + this.dataTableId);
UI.DataTable.prototype.notifyWidgetParametersChange(tableNode, params);
}
Expand Down
29 changes: 22 additions & 7 deletions plugins/Referrers/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function index()
{
$view = new View('@Referrers/index');

$view->graphEvolutionReferrers = $this->getEvolutionGraph(Common::REFERRER_TYPE_DIRECT_ENTRY, array('nb_visits'));
$view->graphEvolutionReferrers = $this->getEvolutionGraph(Common::REFERRER_TYPE_DIRECT_ENTRY, array(), array('nb_visits'));
$view->nameGraphEvolutionReferrers = 'Referrers.getEvolutionGraph';

// building the referrers summary report
Expand Down Expand Up @@ -254,19 +254,28 @@ protected function getReferrersVisitorsByType($date = false)
Common::REFERRER_TYPE_CAMPAIGN => 'Referrers_Campaigns',
);

public function getEvolutionGraph($typeReferrer = false, array $columns = array())
public function getEvolutionGraph($typeReferrer = false, array $columns = array(), array $defaultColumns = array())
{
$view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Referrers.getReferrerType');

$view->config->add_total_row = true;

// configure displayed columns
if (empty($columns)) {
$columns = Common::getRequestVar('columns');
$columns = Piwik::getArrayFromApiParameter($columns);
$columns = Common::getRequestVar('columns', false);
if (false !== $columns) {
$columns = Piwik::getArrayFromApiParameter($columns);
}
}
if (false !== $columns) {
$columns = !is_array($columns) ? array($columns) : $columns;
}

if (!empty($columns)) {
$view->config->columns_to_display = $columns;
} elseif (empty($view->config->columns_to_display) && !empty($defaultColumns)) {
$view->config->columns_to_display = $defaultColumns;
}
$columns = !is_array($columns) ? array($columns) : $columns;
$view->config->columns_to_display = $columns;

// configure selectable columns
if (Common::getRequestVar('period', false) == 'day') {
Expand All @@ -291,7 +300,13 @@ public function getEvolutionGraph($typeReferrer = false, array $columns = array(
}
$label = self::getTranslatedReferrerTypeLabel($typeReferrer);
$total = Piwik::translate('General_Total');
$visibleRows = array($label, $total);

if (!empty($view->config->rows_to_display)) {
$visibleRows = $view->config->rows_to_display;
} else {
$visibleRows = array($label, $total);
}

$view->requestConfig->request_parameters_to_modify['rows'] = $label . ',' . $total;
}
$view->config->row_picker_match_rows_by = 'label';
Expand Down

0 comments on commit 80d8d01

Please sign in to comment.