From 2b06ceda711fd61ccbbc61201bd49ec0a7aea113 Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 19 May 2016 08:00:48 +0200 Subject: [PATCH 1/4] feat(panels): adds queryparameter for choose active tab in edit mode --- public/app/features/panel/panel_ctrl.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index 82e19f8681b..94de0166f61 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -90,6 +90,15 @@ export class PanelCtrl { this.addEditorTab('General', 'public/app/partials/panelgeneral.html'); this.editModeInitiated = true; this.events.emit('init-edit-mode', null); + + var route = this.$injector.get('$route'); + if (route.current.params.editorTab) { + this.editorTabs.forEach((tab, i) => { + if (tab.title === route.current.params.editorTab) { + this.editorTabIndex = i; + } + }); + } } addEditorTab(title, directiveFn, index?) { From 617d18e587153b5d4b86810164afda1eafde3bdb Mon Sep 17 00:00:00 2001 From: bergquist Date: Thu, 19 May 2016 08:42:21 +0200 Subject: [PATCH 2/4] feat(panel): active tab is now placed in querystring aswell --- public/app/features/panel/panel_ctrl.ts | 14 +++++++++++--- public/app/features/panel/panel_directive.ts | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/public/app/features/panel/panel_ctrl.ts b/public/app/features/panel/panel_ctrl.ts index 94de0166f61..994eaa5fd5b 100644 --- a/public/app/features/panel/panel_ctrl.ts +++ b/public/app/features/panel/panel_ctrl.ts @@ -91,16 +91,24 @@ export class PanelCtrl { this.editModeInitiated = true; this.events.emit('init-edit-mode', null); - var route = this.$injector.get('$route'); - if (route.current.params.editorTab) { + var routeParams = this.$injector.get('$routeParams'); + if (routeParams.editorTab) { this.editorTabs.forEach((tab, i) => { - if (tab.title === route.current.params.editorTab) { + if (tab.title === routeParams.editorTab) { this.editorTabIndex = i; } }); } } + changeTab(newIndex) { + this.editorTabIndex = newIndex; + var route = this.$injector.get('$route'); + + route.current.params.editorTab = this.editorTabs[newIndex].title; + route.updateParams(); + } + addEditorTab(title, directiveFn, index?) { var editorTab = {title, directiveFn}; diff --git a/public/app/features/panel/panel_directive.ts b/public/app/features/panel/panel_directive.ts index a9bb75760f5..7d63e620f98 100644 --- a/public/app/features/panel/panel_directive.ts +++ b/public/app/features/panel/panel_directive.ts @@ -36,7 +36,7 @@ var panelTemplate = `