fix(panels): avoid deep copy problem for panel defaults

Moves the defaults to be an instance property. This solves
the problem of lodash defaults function not doing a deep
copy. The symptom of this is that new deep properties for
a panel are assigned to every panel of the same type by
the defaults function in the constructor.
This commit is contained in:
Daniel Lee
2016-04-22 15:29:33 +02:00
parent be19f8888e
commit 16dbf3166d
5 changed files with 161 additions and 163 deletions

View File

@@ -3,23 +3,21 @@
import _ from 'lodash';
import {PanelCtrl} from 'app/plugins/sdk';
// Set and populate defaults
var panelDefaults = {
mode : "markdown", // 'html', 'markdown', 'text'
content : "# title",
};
export class TextPanelCtrl extends PanelCtrl {
static templateUrl = `public/app/plugins/panel/text/module.html`;
remarkable: any;
content: string;
// Set and populate defaults
panelDefaults = {
mode : "markdown", // 'html', 'markdown', 'text'
content : "# title",
};
/** @ngInject */
constructor($scope, $injector, private templateSrv, private $sce) {
super($scope, $injector);
_.defaults(this.panel, panelDefaults);
_.defaults(this.panel, this.panelDefaults);
this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
this.events.on('refresh', this.onRender.bind(this));