Kaynağa Gözat

Various fixes, restored search auto focus

Torkel Ödegaard 10 yıl önce
ebeveyn
işleme
53cb0feda9

+ 26 - 0
public/app/directives/giveFocus.js

@@ -0,0 +1,26 @@
+define([
+  'angular'
+],
+function (angular) {
+  'use strict';
+
+  angular.module('grafana.directives').directive('giveFocus', function() {
+    return function(scope, element, attrs) {
+      element.click(function(e) {
+        e.stopPropagation();
+      });
+
+      scope.$watch(attrs.giveFocus,function (newValue) {
+        if (!newValue) {
+          return;
+        }
+        setTimeout(function() {
+          element.focus();
+          var pos = element.val().length * 2;
+          element[0].setSelectionRange(pos, pos);
+        }, 200);
+      },true);
+    };
+  });
+
+});

+ 1 - 1
public/app/features/dashboard/unsavedChangesSrv.js

@@ -64,7 +64,7 @@ function(angular, _) {
       // ignore time and refresh
       dash.time = 0;
       dash.refresh = 0;
-      dash.version = 0;
+      dash.schemaVersion = 0;
 
       // filter row and panels properties that should be ignored
       dash.rows = _.filter(dash.rows, function(row) {

+ 1 - 2
public/test/specs/unsavedChangesSrv-specs.js

@@ -54,8 +54,7 @@ define([
     it('Should ignore a lot of changes', function() {
       dash.time = {from: '1h'};
       dash.refresh = true;
-      dash.version = 10;
-      dash.rows[0].collapse = true;
+      dash.schemaVersion = 10;
       expect(tracker.hasChanges()).to.be(false);
     });