mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
fix(templating): fix for setting template variable value via url and having repeated panels or rows, fixes #2534
This commit is contained in:
parent
4f3a3329e2
commit
0d8303cf5d
@ -1,4 +1,10 @@
|
||||
# 2.1.1 (unreleased)
|
||||
# 2.1.2 (unreleased)
|
||||
|
||||
**Fixes**
|
||||
- [Issue #2534](https://github.com/grafana/grafana/issues/2534). Templating: fix for setting template variable value via url and having repeated panels or rows
|
||||
|
||||
|
||||
# 2.1.1 (2015-08-11)
|
||||
|
||||
**Fixes**
|
||||
- [Issue #2443](https://github.com/grafana/grafana/issues/2443). Templating: Fix for buggy repeat row behavior when combined with with repeat panel due to recent change before 2.1 release
|
||||
|
@ -80,9 +80,10 @@ function (angular, _, kbn) {
|
||||
|
||||
if (_.isArray(variable.current.value)) {
|
||||
variable.current.text = variable.current.value.join(' + ');
|
||||
self.selectOptionsForCurrentValue(variable);
|
||||
}
|
||||
|
||||
self.selectOptionsForCurrentValue(variable);
|
||||
|
||||
templateSrv.updateTemplateData();
|
||||
return self.updateOptionsInChildVariables(variable);
|
||||
};
|
||||
@ -130,13 +131,20 @@ function (angular, _, kbn) {
|
||||
};
|
||||
|
||||
this.selectOptionsForCurrentValue = function(variable) {
|
||||
for (var i = 0; i < variable.current.value.length; i++) {
|
||||
var value = variable.current.value[i];
|
||||
for (var y = 0; y < variable.options.length; y++) {
|
||||
var option = variable.options[y];
|
||||
if (option.value === value) {
|
||||
option.selected = true;
|
||||
var i, y, value, option;
|
||||
|
||||
for (i = 0; i < variable.options.length; i++) {
|
||||
option = variable.options[i];
|
||||
option.selected = false;
|
||||
if (_.isArray(variable.current.value)) {
|
||||
for (y = 0; y < variable.current.value.length; y++) {
|
||||
value = variable.current.value[i];
|
||||
if (option.value === value) {
|
||||
option.selected = true;
|
||||
}
|
||||
}
|
||||
} else if (option.value === variable.current.value) {
|
||||
option.selected = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -53,7 +53,7 @@ define([
|
||||
name: 'apps',
|
||||
multi: true,
|
||||
current: {text: "val1", value: "val1"},
|
||||
options: [{text: "val1", value: "val1"}, {text: 'val2', value: 'val2'}]
|
||||
options: [{text: "val1", value: "val1"}, {text: 'val2', value: 'val2'}, {text: 'val3', value: 'val3', selected: true}]
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
@ -72,8 +72,11 @@ define([
|
||||
expect(variable.options[0].selected).to.be(true);
|
||||
expect(variable.options[1].selected).to.be(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('should set options that are not in value to selected false', function() {
|
||||
expect(variable.options[2].selected).to.be(false);
|
||||
});
|
||||
});
|
||||
|
||||
function describeUpdateVariable(desc, fn) {
|
||||
describe(desc, function() {
|
||||
|
Loading…
Reference in New Issue
Block a user