From 77cfe15702cc723f08b4cd48e1ee675eca6e1a3a Mon Sep 17 00:00:00 2001 From: diosmosis <benakamoorthi@fastmail.fm> Date: Wed, 5 Mar 2014 11:57:51 +0000 Subject: [PATCH] Changed related to ComparisonDashboard: - Added piwik:dataTableLoaded event to DataTable & ActionsDataTable. - Remove server-side limiting of Dashboard menu links. - Remove use of addEventListener/removeEventListener for IE8 compatibility. - Allow viewDataTable types that are auto-maximised when widgetized to overridden. - Fix bug in segment editor update segment (search for segment by idSegment). --- plugins/Actions/javascripts/actionsDataTable.js | 3 +++ plugins/CoreHome/javascripts/dataTable.js | 2 ++ plugins/Dashboard/Dashboard.php | 11 +++++------ plugins/Dashboard/javascripts/dashboard.js | 4 ++-- plugins/Dashboard/javascripts/dashboardObject.js | 1 - plugins/Dashboard/javascripts/dashboardWidget.js | 7 +++++-- plugins/SegmentEditor/javascripts/Segmentation.js | 6 +++--- 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/plugins/Actions/javascripts/actionsDataTable.js b/plugins/Actions/javascripts/actionsDataTable.js index d48b8dc8e9..acaa7f489c 100644 --- a/plugins/Actions/javascripts/actionsDataTable.js +++ b/plugins/Actions/javascripts/actionsDataTable.js @@ -278,6 +278,9 @@ $('.datatableRelatedReports', content).replaceWith(oldReportsElem); dataTableSel.replaceWith(content); + + content.trigger('piwik:dataTableLoaded'); + piwikHelper.lazyScrollTo(content[0], 400); return content; diff --git a/plugins/CoreHome/javascripts/dataTable.js b/plugins/CoreHome/javascripts/dataTable.js index b202199e71..2884d3169f 100644 --- a/plugins/CoreHome/javascripts/dataTable.js +++ b/plugins/CoreHome/javascripts/dataTable.js @@ -252,6 +252,8 @@ $.extend(DataTable.prototype, UIControl.prototype, { dataTableSel.replaceWith(content); } + content.trigger('piwik:dataTableLoaded'); + piwikHelper.lazyScrollTo(content[0], 400); return content; diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php index 94fbbf6b86..4fe9d81f2b 100644 --- a/plugins/Dashboard/Dashboard.php +++ b/plugins/Dashboard/Dashboard.php @@ -204,12 +204,11 @@ class Dashboard extends \Piwik\Plugin $login = Piwik::getCurrentUserLogin(); $dashboards = $this->getAllDashboards($login); - if (count($dashboards) > 1) { - $pos = 0; - foreach ($dashboards AS $dashboard) { - MenuMain::getInstance()->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos); - $pos++; - } + + $pos = 0; + foreach ($dashboards as $dashboard) { + MenuMain::getInstance()->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos); + $pos++; } } } diff --git a/plugins/Dashboard/javascripts/dashboard.js b/plugins/Dashboard/javascripts/dashboard.js index d6d34269b8..5feff3c328 100644 --- a/plugins/Dashboard/javascripts/dashboard.js +++ b/plugins/Dashboard/javascripts/dashboard.js @@ -194,7 +194,7 @@ function copyDashboardToUser() { } }; - $('body')[0].addEventListener('mouseup', this.onBodyMouseUp); + $('body').on('mouseup', this.onBodyMouseUp); // setup widgetPreview this.$element.widgetPreview({ @@ -222,7 +222,7 @@ function copyDashboardToUser() { _destroy: function () { UIControl.prototype._destroy.call(this); - $('body')[0].removeEventListener('mouseup', this.onBodyMouseUp); + $('body').off('mouseup', null, this.onBodyMouseUp); } }); diff --git a/plugins/Dashboard/javascripts/dashboardObject.js b/plugins/Dashboard/javascripts/dashboardObject.js index fec02213d5..86af47f54f 100644 --- a/plugins/Dashboard/javascripts/dashboardObject.js +++ b/plugins/Dashboard/javascripts/dashboardObject.js @@ -490,7 +490,6 @@ * @param {string} [action] action to perform (defaults to saveLayout) */ function saveLayout(action) { - var columns = []; var columnNumber = 0; diff --git a/plugins/Dashboard/javascripts/dashboardWidget.js b/plugins/Dashboard/javascripts/dashboardWidget.js index 33d073d95c..ba06765026 100755 --- a/plugins/Dashboard/javascripts/dashboardWidget.js +++ b/plugins/Dashboard/javascripts/dashboardWidget.js @@ -36,7 +36,8 @@ onRemove: null, onRefresh: null, onMaximise: null, - onMinimise: null + onMinimise: null, + autoMaximiseVisualizations: ['tableAllColumns', 'tableGoals'] }, /** @@ -144,7 +145,9 @@ * @param {object} parameters */ setParameters: function (parameters) { - if (!this.isMaximised && (parameters.viewDataTable == 'tableAllColumns' || parameters.viewDataTable == 'tableGoals')) { + if (!this.isMaximised + && this.options.autoMaximiseVisualizations.indexOf(parameters.viewDataTable) !== -1 + ) { this.maximise(); } for (var name in parameters) { diff --git a/plugins/SegmentEditor/javascripts/Segmentation.js b/plugins/SegmentEditor/javascripts/Segmentation.js index c7ee63aa57..69bd5c7ca0 100644 --- a/plugins/SegmentEditor/javascripts/Segmentation.js +++ b/plugins/SegmentEditor/javascripts/Segmentation.js @@ -1072,7 +1072,7 @@ $(document).ready(function() { var idx = null; for (idx in self.props.availableSegments) { - if (self.props.availableSegments[idx].definition == params.definition) { + if (self.props.availableSegments[idx].idsegment == params.idSegment) { break; } } @@ -1170,7 +1170,7 @@ $(document).ready(function() { } }; - $('body')[0].addEventListener('mouseup', this.onMouseUp); + $('body').on('mouseup', this.onMouseUp); }; /** @@ -1194,7 +1194,7 @@ $(document).ready(function() { _destroy: function () { UIControl.prototype._destroy.call(this); - $('body')[0].removeEventListener('mouseup', this.onMouseUp); + $('body').off('mouseup', null, this.onMouseUp); } }); -- GitLab