From fe0bf876d92bb618f648d098cb7e4bc99c50bb44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Wed, 29 Apr 2015 15:34:14 +0200 Subject: [PATCH] Style changes and polish to multi variable value selection, #1144 --- .../app/directives/templateParamSelector.js | 34 ++++++++++++++----- .../partials/variableValueSelect.html | 6 ++-- public/css/less/submenu.less | 32 +++++++++-------- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/public/app/directives/templateParamSelector.js b/public/app/directives/templateParamSelector.js index 629c3ececcc..1f1cf9faf5f 100644 --- a/public/app/directives/templateParamSelector.js +++ b/public/app/directives/templateParamSelector.js @@ -42,26 +42,38 @@ function (angular, app, _) { }, 0, false); }; - scope.optionSelected = function(option) { + scope.optionSelected = function(option, event) { option.selected = !option.selected; - if (!variable.multi || option.text === 'All') { + var hideAfter = true; + var setAllExceptCurrentTo = function(newValue) { _.each(scope.options, function(other) { - if (option !== other) { - other.selected = false; - } + if (option !== other) { other.selected = newValue; } }); + }; + + if (option.text === 'All') { + setAllExceptCurrentTo(false); + } + else if (!variable.multi) { + setAllExceptCurrentTo(false); + } else { + if (event.ctrlKey || event.metaKey || event.shiftKey) { + hideAfter = false; + } + else { + setAllExceptCurrentTo(false); + } } var selected = _.filter(scope.options, {selected: true}); - // enfore the first selected if no option is selected if (selected.length === 0) { - scope.options[0].selected = true; - selected = [scope.options[0]]; + option.selected = true; + selected = [option]; } - if (selected.length > 1) { + if (selected.length > 1 && selected.length !== scope.options.length) { if (selected[0].text === 'All') { selected[0].selected = false; selected = selected.slice(1, selected.length); @@ -80,6 +92,10 @@ function (angular, app, _) { scope.updateLinkText(); scope.onUpdated(); + + if (hideAfter) { + scope.hide(); + } }; scope.hide = function() { diff --git a/public/app/features/dashboard/partials/variableValueSelect.html b/public/app/features/dashboard/partials/variableValueSelect.html index ffa5b46ada9..a556b57a72d 100644 --- a/public/app/features/dashboard/partials/variableValueSelect.html +++ b/public/app/features/dashboard/partials/variableValueSelect.html @@ -14,11 +14,9 @@
- - - + {{option.text}} +
diff --git a/public/css/less/submenu.less b/public/css/less/submenu.less index cdf231cbd9f..35cf84022cb 100644 --- a/public/css/less/submenu.less +++ b/public/css/less/submenu.less @@ -26,40 +26,42 @@ .variable-value-dropdown { position: absolute; - top: 43px; - min-width: 200px; + top: 35px; + min-width: 150px; max-height: 400px; background: @grafanaPanelBackground; box-shadow: 0px 0px 55px 0px black; border: 1px solid @grafanaTargetFuncBackground; z-index: 1000; font-size: @baseFontSize; - padding: 4px 4px 8px 4px; + padding: 0; + border-radius: 3px 3px 0 0; } .variable-options-container { max-height: 350px; overflow: auto; display: block; - line-height: 28px; + line-height: 26px; } .variable-option { display: block; - .fa { - font-size: 130%; - position: relative; - top: 2px; - padding-right: 4px; + padding: 0 8px; + + &:hover { + background-color: @blueDark; + } + + .fa { + line-height: 26px; + float: right; + padding-left: 4px; } - .fa-check-square-o { display: none; } &.selected { - .fa-square-o { - display: none; - } - .fa-check-square-o { - display: inline-block; + .variable-option-icon:before { + content: "\f00c"; } } }