Ignore tab update when moving TO show#activity

pull/4576/head
Oliver Günther 8 years ago
parent 7f24c3c052
commit 16dc678dd6
  1. 15
      frontend/app/components/wp-panels/keep-tab/keep-tab.service.test.ts
  2. 29
      frontend/app/components/wp-panels/keep-tab/keep-tab.service.ts

@ -107,6 +107,21 @@ describe('keepTab service', () => {
});
});
describe('when opening show#activity', () => {
beforeEach(() => {
var includes = sinon.stub($state, 'includes');
includes.withArgs('work-packages.show.*').returns(true);
includes.withArgs('work-packages.list.details.*').returns(false);
$state.current.name = 'work-packages.show.activity';
$rootScope.$emit('$stateChangeSuccess', $state.current);
});
it('should set the tab to overview', () => {
expect(keepTab.currentDetailsState).to.eq('work-packages.list.details.overview');
});
});
describe('when opening a details route', () => {
beforeEach(() => {
var includes = sinon.stub($state, 'includes');

@ -35,8 +35,8 @@ export class KeepTabService {
'ngInject';
this.updateTabs();
$rootScope.$on('$stateChangeSuccess', () => {
this.updateTabs();
$rootScope.$on('$stateChangeSuccess', (_event, toState) => {
this.updateTabs(toState);
});
}
@ -66,20 +66,33 @@ export class KeepTabService {
return this.currentTab;
}
protected notify() {
// Notify when updated
this.subject.onNext({
show: this.currentShowState,
details: this.currentDetailsState
});
}
protected updateTab(stateName:string) {
if (this.$state.includes(stateName)) {
const current = this.$state.current.name;
this.currentTab = current.split('.').pop();
// Notify when updated
this.subject.onNext({
show: this.currentShowState,
details: this.currentDetailsState
});
this.notify();
}
}
protected updateTabs() {
protected updateTabs(toState?:any) {
// Ignore the switch from show#activity to details#activity
// and show details#overview instead
if (toState && toState.name === 'work-packages.show.activity') {
this.currentTab = 'overview';
return this.notify();
}
this.updateTab('work-packages.show.*');
this.updateTab('work-packages.list.details.*');
}

Loading…
Cancel
Save