|
|
@@ -15,7 +15,7 @@ var template = `
|
|
|
|
|
|
/** @ngInject */
|
|
|
export function sqlPartEditorDirective($compile, templateSrv) {
|
|
|
- var paramTemplate = '<input type="text" class="hide input-medium"></input>';
|
|
|
+ var paramTemplate = '<input type="text" class="hide input-mini"></input>';
|
|
|
|
|
|
return {
|
|
|
restrict: 'E',
|
|
|
@@ -30,7 +30,6 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
|
|
var partDef = part.def;
|
|
|
var $paramsContainer = elem.find('.query-part-parameters');
|
|
|
var debounceLookup = $scope.debounce;
|
|
|
- var cancelBlur = null;
|
|
|
|
|
|
$scope.partActions = [];
|
|
|
|
|
|
@@ -54,23 +53,7 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- $scope.inputBlur = function(paramIndex) {
|
|
|
- cancelBlur = setTimeout($scope.switchToLink, 200);
|
|
|
- };
|
|
|
-
|
|
|
- $scope.updater = function(value) {
|
|
|
- if (value === part.params[paramIndex]) {
|
|
|
- clearTimeout(cancelBlur);
|
|
|
- $input.focus();
|
|
|
- }
|
|
|
- return value;
|
|
|
- setTimeout(function() {
|
|
|
- $scope.inputBlur.call($input[0], paramIndex);
|
|
|
- }, 0);
|
|
|
- return value;
|
|
|
- };
|
|
|
-
|
|
|
- $scope.switchToLink = function(paramIndex) {
|
|
|
+ function inputBlur(paramIndex) {
|
|
|
/*jshint validthis:true */
|
|
|
var $input = $(this);
|
|
|
var $link = $input.prev();
|
|
|
@@ -87,12 +70,12 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
|
|
|
|
|
$input.hide();
|
|
|
$link.show();
|
|
|
- };
|
|
|
+ }
|
|
|
|
|
|
function inputKeyPress(paramIndex, e) {
|
|
|
/*jshint validthis:true */
|
|
|
if (e.which === 13) {
|
|
|
- $scope.inputBlur.call(this, paramIndex);
|
|
|
+ inputBlur.call(this, paramIndex);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -122,12 +105,6 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
|
|
var dynamicOptions = _.map(result, function(op) {
|
|
|
return op.value;
|
|
|
});
|
|
|
-
|
|
|
- // add current value to dropdown if its not in resultset
|
|
|
- if (_.indexOf(dynamicOptions, part.params[paramIndex]) === -1) {
|
|
|
- dynamicOptions.unshift(part.params[paramIndex]);
|
|
|
- }
|
|
|
-
|
|
|
callback(dynamicOptions);
|
|
|
});
|
|
|
});
|
|
|
@@ -139,7 +116,12 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
|
|
source: typeaheadSource,
|
|
|
minLength: 0,
|
|
|
items: 1000,
|
|
|
- updater: $scope.updater,
|
|
|
+ updater: function(value) {
|
|
|
+ setTimeout(function() {
|
|
|
+ inputBlur.call($input[0], paramIndex);
|
|
|
+ }, 0);
|
|
|
+ return value;
|
|
|
+ },
|
|
|
});
|
|
|
|
|
|
var typeahead = $input.data('typeahead');
|
|
|
@@ -175,13 +157,13 @@ export function sqlPartEditorDirective($compile, templateSrv) {
|
|
|
}
|
|
|
|
|
|
var paramValue = templateSrv.highlightVariablesAsHtml(part.params[index]);
|
|
|
- var $paramLink = $('<a class="">' + paramValue + '</a>');
|
|
|
+ var $paramLink = $('<a class="graphite-func-param-link pointer">' + paramValue + '</a>');
|
|
|
var $input = $(paramTemplate);
|
|
|
|
|
|
$paramLink.appendTo($paramsContainer);
|
|
|
$input.appendTo($paramsContainer);
|
|
|
|
|
|
- $input.blur(_.partial($scope.inputBlur, index));
|
|
|
+ $input.blur(_.partial(inputBlur, index));
|
|
|
$input.keyup(inputKeyDown);
|
|
|
$input.keypress(_.partial(inputKeyPress, index));
|
|
|
$paramLink.click(_.partial(clickFuncParam, index));
|