diff options
author | sgiehl <stefan@piwik.org> | 2015-10-17 20:43:36 +0300 |
---|---|---|
committer | sgiehl <stefan@piwik.org> | 2015-10-17 20:43:36 +0300 |
commit | 37a3ca9221bdd8136f5374e739aac7f210c384d1 (patch) | |
tree | 0f0b925ffe7b0d4df3f86996ae7daab88f89de76 /plugins/Dashboard | |
parent | f1580505636149bec159af2f02fa101daac9e675 (diff) |
fixes #8870 improved remove dashboard behaviour for default dashboard
Diffstat (limited to 'plugins/Dashboard')
-rw-r--r-- | plugins/Dashboard/Dashboard.php | 1 | ||||
-rw-r--r-- | plugins/Dashboard/javascripts/dashboard.js | 31 | ||||
-rw-r--r-- | plugins/Dashboard/lang/en.json | 1 | ||||
-rw-r--r-- | plugins/Dashboard/stylesheets/dashboard.less | 5 |
4 files changed, 29 insertions, 9 deletions
diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php index 35b94743a3..2c118f0246 100644 --- a/plugins/Dashboard/Dashboard.php +++ b/plugins/Dashboard/Dashboard.php @@ -241,6 +241,7 @@ class Dashboard extends \Piwik\Plugin $translationKeys[] = 'Dashboard_WidgetNotFound'; $translationKeys[] = 'Dashboard_DashboardCopied'; $translationKeys[] = 'Dashboard_Dashboard'; + $translationKeys[] = 'Dashboard_RemoveDefaultDashboardNotPossible'; $translationKeys[] = 'General_Close'; $translationKeys[] = 'General_Refresh'; } diff --git a/plugins/Dashboard/javascripts/dashboard.js b/plugins/Dashboard/javascripts/dashboard.js index 4253069723..74d0080ef8 100644 --- a/plugins/Dashboard/javascripts/dashboard.js +++ b/plugins/Dashboard/javascripts/dashboard.js @@ -168,16 +168,15 @@ function copyDashboardToUser() { // on menu item click, trigger action event on this var self = this; this.$element.on('click', 'ul.submenu li[data-action]', function (e) { - self.$element.toggleClass('expanded'); - - $(self).trigger($(this).attr('data-action')); + if (!$(this).attr('disabled')) { + self.$element.removeClass('expanded'); + $(self).trigger($(this).attr('data-action')); + } }); // open manager on open this.$element.on('click', function (e) { - if ($(e.target).is('.dashboardSettings,.dashboardSettings>span')) { - self.$element.toggleClass('expanded'); - + if ($(e.target).is('.dashboardSettings') || $(e.target).closest('.dashboardSettings').length) { // fix position self.$element .find('.widgetpreview-widgetlist') @@ -280,10 +279,24 @@ function copyDashboardToUser() { $.extend(DashboardManagerControl.prototype, DashboardSettingsControlBase.prototype, { onOpen: function () { if ($('#dashboardWidgetsArea').dashboard('isDefaultDashboard')) { - $('.removeDashboardLink', this.$element).hide(); + $('[data-action=removeDashboard]', this.$element).attr('disabled', 'disabled'); + $(this.$element).tooltip({ + items: '[data-action=removeDashboard]', + show: false, + hide: false, + track: true, + content: function() { + return _pk_translate('Dashboard_RemoveDefaultDashboardNotPossible') + }, + tooltipClass: 'small' + }); } else { - $('.removeDashboardLink', this.$element).show(); - } + $('[data-action=removeDashboard]', this.$element).removeAttr('disabled'); + // try to remove tooltip if any + try { + $(this.$element).tooltip('destroy'); + } catch (e) { } + } }, hide: function () { diff --git a/plugins/Dashboard/lang/en.json b/plugins/Dashboard/lang/en.json index 89d8c994d9..68bfd22c8e 100644 --- a/plugins/Dashboard/lang/en.json +++ b/plugins/Dashboard/lang/en.json @@ -21,6 +21,7 @@ "PluginDescription": "Your Web Analytics Dashboard. Customise your dashboard by adding new widgets, drag and drop them around, and change the dashboard column layout. Each user can manage their own custom dashboard.", "RemoveDashboard": "Remove dashboard", "RemoveDashboardConfirm": "Are you sure you want to remove the dashboard \"%s\"?", + "RemoveDefaultDashboardNotPossible": "The default dashboard cannot be removed", "RenameDashboard": "Rename dashboard", "ResetDashboard": "Reset dashboard", "ResetDashboardConfirm": "Are you sure you want to reset your dashboard layout to the default Widgets selection?", diff --git a/plugins/Dashboard/stylesheets/dashboard.less b/plugins/Dashboard/stylesheets/dashboard.less index 39ad2e3ed7..b45398379c 100644 --- a/plugins/Dashboard/stylesheets/dashboard.less +++ b/plugins/Dashboard/stylesheets/dashboard.less @@ -335,6 +335,11 @@ div.widgetpreview-preview { color: @theme-color-link; } +.dashboardSettings .submenu li[disabled], +.dashboardSettings .submenu li[disabled]:hover { + color: #d3d3d3; +} + .dashboardSettings .widgetpreview-widgetlist { width: 228px; font-weight: normal; |