Commit ca53ae4f by Torkel Ödegaard

fix(templating): Another atempt at fixing #2534 (Init multi value template var…

fix(templating): Another atempt at fixing #2534 (Init multi value template var used in repeat panel from url), fixes #2564
parent 8f35683c
...@@ -15,6 +15,7 @@ it allows you to add queries of differnet data source types & instances to the s ...@@ -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 #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 #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 #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** **Breaking Changes**
- Notice to makers/users of custom data sources, there is a minor breaking change in 2.2 that - Notice to makers/users of custom data sources, there is a minor breaking change in 2.2 that
......
...@@ -138,7 +138,7 @@ function (angular, _, kbn) { ...@@ -138,7 +138,7 @@ function (angular, _, kbn) {
option.selected = false; option.selected = false;
if (_.isArray(variable.current.value)) { if (_.isArray(variable.current.value)) {
for (y = 0; y < variable.current.value.length; y++) { for (y = 0; y < variable.current.value.length; y++) {
value = variable.current.value[i]; value = variable.current.value[y];
if (option.value === value) { if (option.value === value) {
option.selected = true; option.selected = true;
} }
......
...@@ -59,16 +59,16 @@ define([ ...@@ -59,16 +59,16 @@ define([
beforeEach(function() { beforeEach(function() {
var dashboard = { templating: { list: [variable] } }; var dashboard = { templating: { list: [variable] } };
var urlParams = {}; var urlParams = {};
urlParams["var-apps"] = ["val1", "val2"]; urlParams["var-apps"] = ["val2", "val1"];
ctx.$location.search = sinon.stub().returns(urlParams); ctx.$location.search = sinon.stub().returns(urlParams);
ctx.service.init(dashboard); ctx.service.init(dashboard);
}); });
it('should update current value', function() { it('should update current value', function() {
expect(variable.current.value.length).to.be(2); expect(variable.current.value.length).to.be(2);
expect(variable.current.value[0]).to.be("val1"); expect(variable.current.value[0]).to.be("val2");
expect(variable.current.value[1]).to.be("val2"); expect(variable.current.value[1]).to.be("val1");
expect(variable.current.text).to.be("val1 + val2"); expect(variable.current.text).to.be("val2 + val1");
expect(variable.options[0].selected).to.be(true); expect(variable.options[0].selected).to.be(true);
expect(variable.options[1].selected).to.be(true); expect(variable.options[1].selected).to.be(true);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment