Add current tab name to keepTabService

pull/4643/head
Oliver Günther 8 years ago
parent 501f93eef1
commit aa6b750136
  1. 28
      frontend/app/components/wp-panels/keep-tab/keep-tab.service.ts

@ -44,6 +44,17 @@ export class KeepTabService {
return this.subject;
}
/**
* Return the last active tab.
*/
public get lastActiveTab():string {
if (this.isCurrentState('show')) {
return this.currentShowTab;
}
return this.currentDetailsTab;
}
public get currentShowState():string {
return 'work-packages.show.' + this.currentShowTab;
}
@ -69,13 +80,14 @@ export class KeepTabService {
protected notify() {
// Notify when updated
this.subject.onNext({
active: this.lastActiveTab,
show: this.currentShowState,
details: this.currentDetailsState
});
}
protected updateTab(stateName:string) {
if (this.$state.includes(stateName)) {
if (this.isCurrentState(stateName)) {
const current = this.$state.current.name;
this.currentTab = current.split('.').pop();
@ -83,6 +95,16 @@ export class KeepTabService {
}
}
protected isCurrentState(stateName:string) {
if (stateName === 'show') {
return this.$state.includes('work-packages.show.*');
}
if (stateName === 'details') {
return this.$state.includes('work-packages.list.details.*');
}
}
protected updateTabs(toState?:any) {
// Ignore the switch from show#activity to details#activity
@ -93,8 +115,8 @@ export class KeepTabService {
return this.notify();
}
this.updateTab('work-packages.show.*');
this.updateTab('work-packages.list.details.*');
this.updateTab('show');
this.updateTab('details');
}
}

Loading…
Cancel
Save