From 53cb0feda9ffd176c3f5700a2958606142162ab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 28 Apr 2015 17:28:34 +0200 Subject: [PATCH] Various fixes, restored search auto focus --- public/app/directives/giveFocus.js | 26 +++++++++++++++++++ .../features/dashboard/unsavedChangesSrv.js | 2 +- public/test/specs/unsavedChangesSrv-specs.js | 3 +-- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/public/app/directives/giveFocus.js b/public/app/directives/giveFocus.js index e69de29bb2d..ef395d27fbd 100644 --- a/public/app/directives/giveFocus.js +++ b/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); + }; + }); + +}); diff --git a/public/app/features/dashboard/unsavedChangesSrv.js b/public/app/features/dashboard/unsavedChangesSrv.js index fe45fbe48ba..11a806c865d 100644 --- a/public/app/features/dashboard/unsavedChangesSrv.js +++ b/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) { diff --git a/public/test/specs/unsavedChangesSrv-specs.js b/public/test/specs/unsavedChangesSrv-specs.js index 43cb3ab0e63..4ec2a8f82a1 100644 --- a/public/test/specs/unsavedChangesSrv-specs.js +++ b/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); });