Просмотр исходного кода

focus first input param after adding function

Torkel Ödegaard 11 лет назад
Родитель
Сommit
e3e6f511e7
2 измененных файлов с 14 добавлено и 3 удалено
  1. 7 3
      src/app/controllers/graphiteTarget.js
  2. 7 0
      src/app/directives/graphiteFuncEditor.js

+ 7 - 3
src/app/controllers/graphiteTarget.js

@@ -10,7 +10,7 @@ function (angular, _, config, gfunc, Parser) {
 
   var module = angular.module('kibana.controllers');
 
-  module.controller('GraphiteTargetCtrl', function($scope, $http, filterSrv) {
+  module.controller('GraphiteTargetCtrl', function($scope, $http, filterSrv, $timeout) {
 
     $scope.init = function() {
       parseTarget();
@@ -223,7 +223,9 @@ function (angular, _, config, gfunc, Parser) {
     };
 
     $scope.addFunction = function(funcDef) {
-      $scope.functions.push(gfunc.createFuncInstance(funcDef));
+      var newFunc = gfunc.createFuncInstance(funcDef);
+      newFunc.added = true;
+      $scope.functions.push(newFunc);
 
       var aliasFunc = _.find($scope.functions, function(func) {
         return func.def.name === 'alias';
@@ -234,7 +236,9 @@ function (angular, _, config, gfunc, Parser) {
         $scope.functions.push(aliasFunc);
       }
 
-      $scope.targetChanged();
+      if (!funcDef.params) {
+        $scope.targetChanged();
+      }
     };
 
     $scope.duplicate = function() {

+ 7 - 0
src/app/directives/graphiteFuncEditor.js

@@ -121,6 +121,13 @@ function (angular, _, $) {
           $('<span>)</span>').appendTo(elem);
 
           $compile(elem.contents())($scope);
+
+          if ($scope.func.added) {
+            $scope.func.added = false;
+            setTimeout(function() {
+              elem.find('a').click();
+            }, 10);
+          }
         }
       };