Commit a433e0e7 by Torkel Ödegaard

More work on variable dropdown

parent 483ef205
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment