mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
More work on variable dropdown
This commit is contained in:
parent
483ef20527
commit
a433e0e79c
@ -115,7 +115,10 @@ function (angular, app, _) {
|
||||
scope.moveHighlight(-1);
|
||||
}
|
||||
if (evt.keyCode === 13) {
|
||||
scope.optionSelected(scope.search.options[scope.highlightIndex], {});
|
||||
scope.optionSelected(scope.search.options[scope.highlightIndex], {}, true, false);
|
||||
}
|
||||
if (evt.keyCode === 32) {
|
||||
scope.optionSelected(scope.search.options[scope.highlightIndex], {}, false, false);
|
||||
}
|
||||
};
|
||||
|
||||
@ -123,24 +126,34 @@ function (angular, app, _) {
|
||||
scope.highlightIndex = (scope.highlightIndex + direction) % scope.search.options.length;
|
||||
};
|
||||
|
||||
scope.optionSelected = function(option, event) {
|
||||
scope.optionSelected = function(option, event, commitChange, excludeOthers) {
|
||||
if (!option) { return; }
|
||||
|
||||
option.selected = !option.selected;
|
||||
|
||||
var hideAfter = false;
|
||||
commitChange = commitChange || false;
|
||||
excludeOthers = excludeOthers || false;
|
||||
|
||||
var setAllExceptCurrentTo = function(newValue) {
|
||||
_.each(scope.options, function(other) {
|
||||
if (option !== other) { other.selected = newValue; }
|
||||
});
|
||||
};
|
||||
|
||||
if (option.text === 'All') {
|
||||
// commit action (enter key), should not deselect it
|
||||
if (commitChange) {
|
||||
option.selected = true;
|
||||
}
|
||||
|
||||
if (option.text === 'All' || excludeOthers) {
|
||||
setAllExceptCurrentTo(false);
|
||||
commitChange = true;
|
||||
}
|
||||
else if (!variable.multi) {
|
||||
setAllExceptCurrentTo(false);
|
||||
hideAfter = true;
|
||||
commitChange = true;
|
||||
} else if (event.ctrlKey || event.metaKey || event.shiftKey) {
|
||||
hideAfter = true;
|
||||
commitChange = true;
|
||||
setAllExceptCurrentTo(false);
|
||||
}
|
||||
|
||||
@ -168,7 +181,7 @@ function (angular, app, _) {
|
||||
variable.current.value = selected[0].value;
|
||||
}
|
||||
|
||||
if (hideAfter) {
|
||||
if (commitChange) {
|
||||
scope.switchToLink();
|
||||
}
|
||||
};
|
||||
|
@ -82,6 +82,7 @@ function (angular, _) {
|
||||
};
|
||||
|
||||
$scope.update = function() {
|
||||
$scope.current.tags = [];
|
||||
if ($scope.isValid()) {
|
||||
$scope.runQuery().then(function() {
|
||||
$scope.reset();
|
||||
|
Loading…
Reference in New Issue
Block a user