Bläddra i källkod

fix(templating): Another atempt at fixing #2534 (Init multi value template var used in repeat panel from url), fixes #2564

Torkel Ödegaard 10 år sedan
förälder
incheckning
ca53ae4fc5

+ 1 - 0
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

+ 1 - 1
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;
             }

+ 4 - 4
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);
       });