From 35c8cdf3a55c76ecc81fa749833c1d3b4c065c30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 12 Dec 2017 12:10:19 +0100 Subject: [PATCH] refactor: minor change to panel json fix PR #10156 --- public/app/features/panel/panel_ctrl.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index 0eff9ad43db..695beee307b 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -191,9 +191,8 @@ export class PanelCtrl { duplicate() { this.dashboard.duplicatePanel(this.panel); - let self = this; this.$timeout(() => { - self.$scope.$root.$broadcast('render'); + this.$scope.$root.$broadcast('render'); }); } @@ -240,18 +239,16 @@ export class PanelCtrl { let index = _.findIndex(dashboard.panels, (panel) => { return panel.id === oldPanel.id; }); + let deletedPanel = dashboard.panels.splice(index, 1); this.dashboard.events.emit('panel-removed', deletedPanel); - // adding it back needs to be done in next digest - this.$timeout(() => { - newPanel = new PanelModel(newPanel); - newPanel.id = oldPanel.id; + newPanel = new PanelModel(newPanel); + newPanel.id = oldPanel.id; - dashboard.panels.splice(index, 0, newPanel); - dashboard.sortPanelsByGridPos(); - dashboard.events.emit('panel-added', newPanel); - }); + dashboard.panels.splice(index, 0, newPanel); + dashboard.sortPanelsByGridPos(); + dashboard.events.emit('panel-added', newPanel); } sharePanel() {