Make template variables work in row titles, #1956

This commit is contained in:
Torkel Ödegaard
2015-06-11 09:35:59 +02:00
parent 3675b3fcaa
commit e5280d55b3
5 changed files with 25 additions and 30 deletions

View File

@@ -105,6 +105,8 @@ function (angular, _) {
_.each(selected, function(option, index) {
copy = self.getRowClone(row, index);
copy.scopedVars = {};
copy.scopedVars[variable.name] = option;
for (i = 0; i < copy.panels.length; i++) {
panel = copy.panels[i];

View File

@@ -22,7 +22,6 @@ function (angular, app, _, config) {
$scope.init = function() {
$scope.editor = {index: 0};
$scope.reset_panel();
};
$scope.togglePanelMenu = function(posX) {
@@ -64,8 +63,18 @@ function (angular, app, _, config) {
};
$scope.add_panel_default = function(type) {
$scope.reset_panel(type);
$scope.add_panel($scope.panel);
var defaultSpan = 12;
var _as = 12 - $scope.dashboard.rowSpan($scope.row);
var panel = {
title: config.new_panel_title,
error: false,
span: _as < defaultSpan && _as > 0 ? _as : defaultSpan,
editable: true,
type: type
};
$scope.add_panel(panel);
$timeout(function() {
$scope.$broadcast('render');
@@ -105,31 +114,6 @@ function (angular, app, _, config) {
});
};
$scope.reset_panel = function(type) {
var defaultSpan = 12;
var _as = 12 - $scope.dashboard.rowSpan($scope.row);
$scope.panel = {
title: config.new_panel_title,
error: false,
span: _as < defaultSpan && _as > 0 ? _as : defaultSpan,
editable: true,
type: type
};
function fixRowHeight(height) {
if (!height) {
return '200px';
}
if (!_.isString(height)) {
return height + 'px';
}
return height;
}
$scope.row.height = fixRowHeight($scope.row.height);
};
$scope.init();
});