From ca53ae4fc598e01c00dfd72b3421845f84fb8227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 21 Aug 2015 10:40:14 +0200 Subject: [PATCH] fix(templating): Another atempt at fixing #2534 (Init multi value template var used in repeat panel from url), fixes #2564 --- CHANGELOG.md | 1 + public/app/features/templating/templateValuesSrv.js | 2 +- public/test/specs/templateValuesSrv-specs.js | 8 ++++---- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 418e0583677..50623ac96dd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ it allows you to add queries of differnet data source types & instances to the s - [Issue #2490](https://github.com/grafana/grafana/issues/2490). Graphite: Dashboard import was broken in 2.1 and 2.1.1, working now - [Issue #2565](https://github.com/grafana/grafana/issues/2565). TimePicker: Fix for when you applied custom time range it did not refreh dashboard - [Issue #2563](https://github.com/grafana/grafana/issues/2563). Annotations: Fixed issue when html sanitizer failes for title to annotation body, now fallbacks to html escaping title and text +- [Issue #2564](https://github.com/grafana/grafana/issues/2564). Templating: Another atempt at fixing #2534 (Init multi value template var used in repeat panel from url) **Breaking Changes** - Notice to makers/users of custom data sources, there is a minor breaking change in 2.2 that diff --git a/public/app/features/templating/templateValuesSrv.js b/public/app/features/templating/templateValuesSrv.js index eadf5954ed6..13e85d08a33 100644 --- a/public/app/features/templating/templateValuesSrv.js +++ b/public/app/features/templating/templateValuesSrv.js @@ -138,7 +138,7 @@ function (angular, _, kbn) { option.selected = false; if (_.isArray(variable.current.value)) { for (y = 0; y < variable.current.value.length; y++) { - value = variable.current.value[i]; + value = variable.current.value[y]; if (option.value === value) { option.selected = true; } diff --git a/public/test/specs/templateValuesSrv-specs.js b/public/test/specs/templateValuesSrv-specs.js index 813b3313ef0..07f9dd570f9 100644 --- a/public/test/specs/templateValuesSrv-specs.js +++ b/public/test/specs/templateValuesSrv-specs.js @@ -59,16 +59,16 @@ define([ beforeEach(function() { var dashboard = { templating: { list: [variable] } }; var urlParams = {}; - urlParams["var-apps"] = ["val1", "val2"]; + urlParams["var-apps"] = ["val2", "val1"]; ctx.$location.search = sinon.stub().returns(urlParams); ctx.service.init(dashboard); }); it('should update current value', function() { expect(variable.current.value.length).to.be(2); - expect(variable.current.value[0]).to.be("val1"); - expect(variable.current.value[1]).to.be("val2"); - expect(variable.current.text).to.be("val1 + val2"); + expect(variable.current.value[0]).to.be("val2"); + expect(variable.current.value[1]).to.be("val1"); + expect(variable.current.text).to.be("val2 + val1"); expect(variable.options[0].selected).to.be(true); expect(variable.options[1].selected).to.be(true); });