Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[37107] render tabs in component (#9236)

Oliver Günther5956ede03059
diff --git a/frontend/src/app/angular4-modules.ts b/frontend/src/app/angular4-modules.ts
index e6267795d83..4b0ce74f60b 100644
--- a/frontend/src/app/angular4-modules.ts
+++ b/frontend/src/app/angular4-modules.ts
@@ -79,6 +79,7 @@ import { OpenprojectModalModule } from "core-app/modules/modal/modal.module";
import { RevitAddInSettingsButtonService } from "core-app/modules/bim/revit_add_in/revit-add-in-settings-button.service";
import { OpenprojectAutocompleterModule } from "core-app/modules/autocompleter/openproject-autocompleter.module";
import { OpenProjectBackupService } from './components/api/op-backup/op-backup.service';
+import { OpenprojectTabsModule } from "core-app/modules/common/tabs/openproject-tabs.module";
@NgModule({
imports: [
@@ -149,6 +150,9 @@ import { OpenProjectBackupService } from './components/api/op-backup/op-backup.s
// Autocompleters
OpenprojectAutocompleterModule,
+
+ // Tabs
+ OpenprojectTabsModule,
],
providers: [
{ provide: States, useValue: new States() },
diff --git a/frontend/src/app/components/angular/tracking-functions.ts b/frontend/src/app/components/angular/tracking-functions.ts
index 718fe9db5b7..8f8d5e554c4 100644
--- a/frontend/src/app/components/angular/tracking-functions.ts
+++ b/frontend/src/app/components/angular/tracking-functions.ts
@@ -20,12 +20,12 @@ export namespace AngularTrackingHelpers {
return _.get(item, 'name');
}
- export function trackByHref(i:number, item:HalResource) {
+ export function trackByHref(i:number, item:{ href?:unknown }) {
return _.get(item, 'href');
}
export function trackByProperty(prop:string) {
- return (i:number, item:HalResource) => _.get(item, prop);
+ return (i:number, item:unknown) => _.get(item, prop);
}
export function trackByHrefAndProperty(propertyName:string) {
diff --git a/frontend/src/app/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts b/frontend/src/app/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts
index a531ecbf29b..a6fa435cb56 100644
--- a/frontend/src/app/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts
+++ b/frontend/src/app/components/op-context-menu/wp-context-menu/wp-view-context-menu.directive.ts
@@ -187,8 +187,8 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {
icon: 'icon-view-split',
class: 'detailsViewMenuItem',
href: this.$state.href(
- splitViewRoute(this.$state) + '.overview',
- { workPackageId: this.workPackageId }),
+ splitViewRoute(this.$state) + '.tabs',
+ { workPackageId: this.workPackageId, tabIdentifier: 'overview' }),
linkText: I18n.t('js.button_open_details'),
onClick: ($event:JQuery.TriggeredEvent) => {
if (LinkHandling.isClickedWithModifier($event)) {
@@ -196,8 +196,8 @@ export class WorkPackageViewContextMenu extends OpContextMenuHandler {
}
this.$state.go(
- splitViewRoute(this.$state) + '.overview',
- { workPackageId: this.workPackageId }
+ splitViewRoute(this.$state) + '.tabs',
+ { workPackageId: this.workPackageId, tabIdentifier: 'overview' }
);
return true;
}
diff --git a/frontend/src/app/components/work-packages/wp-relations-count/wp-relations-count.component.ts b/frontend/src/app/components/work-packages/wp-relations-count/wp-relations-count.component.ts
deleted file mode 100644
index 2624f640c45..00000000000
--- a/frontend/src/app/components/work-packages/wp-relations-count/wp-relations-count.component.ts
+++ /dev/null
@@ -1,42 +0,0 @@
-import { Component, Input, OnInit } from '@angular/core';
-import { WorkPackageRelationsService } from '../../wp-relations/wp-relations.service';
-import { combineLatest } from 'rxjs';
-import { UntilDestroyedMixin } from "core-app/helpers/angular/until-destroyed.mixin";
-import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
-
-@Component({
- templateUrl: './wp-relations-count.html',
- selector: 'wp-relations-count',
-})
-export class WorkPackageRelationsCountComponent extends UntilDestroyedMixin implements OnInit {
- @Input('wpId') wpId:string;
- public count = 0;
-
- constructor(protected apiV3Service:APIV3Service,
- protected wpRelations:WorkPackageRelationsService) {
- super();
- }
-
- ngOnInit():void {
- this.wpRelations.require(this.wpId.toString());
-
- combineLatest([
- this
- .wpRelations
- .state(this.wpId.toString())
- .values$(),
- this
- .apiV3Service
- .work_packages
- .id(this.wpId)
- .requireAndStream()
- ]).pipe(
- this.untilDestroyed()
- ).subscribe(([relations, workPackage]) => {
- const relationCount = _.size(relations);
- const childrenCount = _.size(workPackage.children);
-
- this.count = relationCount + childrenCount;
- });
- }
-}
diff --git a/frontend/src/app/components/work-packages/wp-relations-count/wp-relations-count.html b/frontend/src/app/components/work-packages/wp-relations-count/wp-relations-count.html
deleted file mode 100644
index 81c52049283..00000000000
--- a/frontend/src/app/components/work-packages/wp-relations-count/wp-relations-count.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<span class="wp-tabs-count"
- *ngIf="count > 0"
- [textContent]="count"></span>
diff --git a/frontend/src/app/components/work-packages/wp-relations-count/wp-watchers-count.component.ts b/frontend/src/app/components/work-packages/wp-relations-count/wp-watchers-count.component.ts
deleted file mode 100644
index d14a3c80aef..00000000000
--- a/frontend/src/app/components/work-packages/wp-relations-count/wp-watchers-count.component.ts
+++ /dev/null
@@ -1,39 +0,0 @@
-import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit } from '@angular/core';
-import { UntilDestroyedMixin } from "core-app/helpers/angular/until-destroyed.mixin";
-import { WorkPackageWatchersService } from 'core-app/components/wp-single-view-tabs/watchers-tab/wp-watchers.service';
-import { HalResource } from 'core-app/modules/hal/resources/hal-resource';
-import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
-
-@Component({
- templateUrl: './wp-relations-count.html',
- selector: 'wp-watchers-count',
- changeDetection: ChangeDetectionStrategy.OnPush
-})
-export class WorkPackageWatchersCountComponent extends UntilDestroyedMixin implements OnInit {
- @Input('wpId') wpId:string;
- public count = 0;
-
- constructor(protected apiV3Service:APIV3Service,
- protected wpWatcherService:WorkPackageWatchersService,
- protected cdRef:ChangeDetectorRef) {
- super();
- }
-
- ngOnInit():void {
- this
- .apiV3Service
- .work_packages
- .id(this.wpId)
- .requireAndStream()
- .pipe(
- this.untilDestroyed()
- ).subscribe((workPackage) => {
- this.wpWatcherService
- .require(workPackage)
- .then((watchers:HalResource[]) => {
- this.count = watchers.length;
- this.cdRef.detectChanges();
- });
- });
- }
-}
diff --git a/frontend/src/app/components/wp-buttons/wp-details-view-button/wp-details-view-button.component.ts b/frontend/src/app/components/wp-buttons/wp-details-view-button/wp-details-view-button.component.ts
index ca81979b58c..ebaedf4f4b7 100644
--- a/frontend/src/app/components/wp-buttons/wp-details-view-button/wp-details-view-button.component.ts
+++ b/frontend/src/app/components/wp-buttons/wp-details-view-button/wp-details-view-button.component.ts
@@ -91,28 +91,20 @@ export class WorkPackageDetailsViewButtonComponent extends AbstractWorkPackageBu
public performAction(event:Event) {
if (this.isActive) {
- this.openListView();
+ this.$state.go(this.listState);
} else {
this.openDetailsView();
}
}
- public openListView() {
- var params = {
- projectPath: this.projectIdentifier
- };
-
- _.extend(params, this.$state.params);
- this.$state.go(this.listState, params);
+ public openListView():void {
}
- public openDetailsView() {
- var params = {
- workPackageId: this.wpTableFocus.focusedWorkPackage,
- projectPath: this.projectIdentifier,
+ public openDetailsView():void {
+ const params = {
+ workPackageId: this.wpTableFocus.focusedWorkPackage
};
- _.extend(params, this.$state.params);
- this.$state.go(this.keepTab.currentDetailsState, params);
+ this.keepTab.goCurrentDetailsState(params);
}
}
diff --git a/frontend/src/app/components/wp-card-view/wp-single-card/wp-single-card.component.ts b/frontend/src/app/components/wp-card-view/wp-single-card/wp-single-card.component.ts
index 9f9dd24cdb8..6909a1bed94 100644
--- a/frontend/src/app/components/wp-card-view/wp-single-card/wp-single-card.component.ts
+++ b/frontend/src/app/components/wp-card-view/wp-single-card/wp-single-card.component.ts
@@ -74,7 +74,7 @@ export class WorkPackageSingleCardComponent extends UntilDestroyedMixin implemen
public emitStateLinkClicked(wp:WorkPackageResource, detail?:boolean) {
const classIdentifier = this.classIdentifier(wp);
- const stateToEmit = detail ? splitViewRoute(this.$state) : 'work-packages.show';
+ const stateToEmit = detail ? 'split' : 'show';
this.wpTableSelection.setSelection(wp.id!, this.cardView.findRenderedCard(classIdentifier));
this.wpTableFocus.updateFocus(wp.id!);
diff --git a/frontend/src/app/components/wp-fast-table/builders/ui-state-link-builder.ts b/frontend/src/app/components/wp-fast-table/builders/ui-state-link-builder.ts
index 323d6ed234c..41628024028 100644
--- a/frontend/src/app/components/wp-fast-table/builders/ui-state-link-builder.ts
+++ b/frontend/src/app/components/wp-fast-table/builders/ui-state-link-builder.ts
@@ -4,9 +4,6 @@ import { StateService } from '@uirouter/core';
export const uiStateLinkClass = '__ui-state-link';
export const checkedClassName = '-checked';
-export const currentDetailsState = 'currentDetailsState';
-export const currentShowState = 'currentShowState';
-
export class UiStateLinkBuilder {
constructor(public readonly $state:StateService,
@@ -14,22 +11,30 @@ export class UiStateLinkBuilder {
}
public linkToDetails(workPackageId:string, title:string, content:string) {
- return this.build(workPackageId, currentDetailsState, title, content);
+ return this.build(workPackageId, 'split', title, content);
}
public linkToShow(workPackageId:string, title:string, content:string) {
- return this.build(workPackageId, currentShowState, title, content);
+ return this.build(workPackageId, 'show', title, content);
}
- private build(workPackageId:string, state:string, title:string, content:string) {
+ private build(workPackageId:string, state:'show'|'split', title:string, content:string) {
const a = document.createElement('a');
- const selectedTabIdentifier = this.$state.params?.tabIdentifier;
-
+ let tabState:string;
+ let tabIdentifier:string;
+
+ if (state === 'show') {
+ tabState = 'work-packages.show.tabs';
+ tabIdentifier = this.keepTab.currentShowTab;
+ } else {
+ tabState = 'work-packages.partitioned.list.details.tabs';
+ tabIdentifier = this.keepTab.currentDetailsTab;
+ }
a.href = this.$state.href(
- (this.keepTab as any)[state],
+ tabState,
{
workPackageId: workPackageId,
- ...selectedTabIdentifier && {tabIdentifier: selectedTabIdentifier},
+ tabIdentifier: tabIdentifier
}
);
a.classList.add(uiStateLinkClass);
diff --git a/frontend/src/app/components/wp-relations/wp-relation-row/wp-relation-row.template.html b/frontend/src/app/components/wp-relations/wp-relation-row/wp-relation-row.template.html
index 8b45382f745..766a2ade34a 100644
--- a/frontend/src/app/components/wp-relations/wp-relation-row/wp-relation-row.template.html
+++ b/frontend/src/app/components/wp-relations/wp-relation-row/wp-relation-row.template.html
@@ -33,8 +33,8 @@
<div class="grid-content medium-5 collapse"
*ngIf="relatedWorkPackage">
- <a uiSref="work-packages.show.relations"
- [uiParams]="{ workPackageId: relatedWorkPackage.id }"
+ <a uiSref="work-packages.show.tabs"
+ [uiParams]="{ workPackageId: relatedWorkPackage.id, tabIdentifier: 'relations' }"
class="wp-relations--subject-field"
[textContent]="relatedWorkPackage.subjectWithId()"
[attr.aria-label]="normalizedRelationType + ' ' + relatedWorkPackage.subjectWithId()">
diff --git a/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.spec.ts b/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.spec.ts
index 969fb93be05..e7b0e3f630a 100644
--- a/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.spec.ts
+++ b/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.spec.ts
@@ -33,6 +33,7 @@ describe('keepTab service', () => {
const includes = (path:string) => false;
let $state:any;
let $transitions:any;
+ let uiRouterGlobals:any;
let keepTab:KeepTabService;
let defaults:any;
@@ -48,22 +49,24 @@ describe('keepTab service', () => {
onSuccess: (criteria:any, cb:(transition:any) => void) => callback = cb
};
- keepTab = new KeepTabService($state, $transitions);
+ uiRouterGlobals = {
+ params: { tabIdentifier: 'activity' }
+ };
+
+ keepTab = new KeepTabService($state, uiRouterGlobals, $transitions);
defaults = {
- showTab: 'work-packages.show.activity',
- detailsTab: 'work-packages.partitioned.list.details.overview'
+ showTab: 'work-packages.show.tabs',
+ detailsTab: 'work-packages.partitioned.list.details.tabs'
};
});
describe('when initially invoked, or when an unsupported route is opened', () => {
it('should have the correct default value for the currentShowTab', () => {
- expect(keepTab.currentShowState).toEqual(defaults.showTab);
expect(keepTab.currentShowTab).toEqual('activity');
});
it('should have the correct default value for the currentDetailsTab', () => {
- expect(keepTab.currentDetailsState).toEqual(defaults.detailsTab);
expect(keepTab.currentDetailsTab).toEqual('overview');
});
});
@@ -76,16 +79,17 @@ describe('keepTab service', () => {
return path === currentPathPrefix;
});
- $state.current.name = 'work-packages.show.relations';
+ $state.current.name = 'work-packages.show.tabs';
+ uiRouterGlobals.params.tabIdentifier = 'relations';
keepTab.updateTabs();
});
it('should update the currentShowTab value', () => {
- expect(keepTab.currentShowState).toEqual('work-packages.show.relations');
+ expect(keepTab.currentShowTab).toEqual('relations');
});
it('should also update the value of currentDetailsTab', () => {
- expect(keepTab.currentDetailsState).toEqual('work-packages.partitioned.list.details.relations');
+ expect(keepTab.currentShowTab).toEqual('relations');
});
it('should propagate the previous change', () => {
@@ -93,8 +97,8 @@ describe('keepTab service', () => {
var expected = {
active: 'relations',
- show: 'work-packages.show.relations',
- details: 'work-packages.partitioned.list.details.relations'
+ show: 'relations',
+ details: 'relations'
};
keepTab.observable.subscribe(cb);
@@ -104,12 +108,10 @@ describe('keepTab service', () => {
it('should correctly change when switching back', () => {
currentPathPrefix = '**.details.*';
- $state.current.name = 'work-packages.partitioned.list.details.overview';
+ uiRouterGlobals.params.tabIdentifier = 'overview';
keepTab.updateTabs();
- expect(keepTab.currentShowState).toEqual('work-packages.show.activity');
expect(keepTab.currentShowTab).toEqual('activity');
- expect(keepTab.currentDetailsState).toEqual('work-packages.partitioned.list.details.overview');
expect(keepTab.currentDetailsTab).toEqual('overview');
});
});
@@ -120,12 +122,13 @@ describe('keepTab service', () => {
return path === 'work-packages.show.*';
});
- $state.current.name = 'work-packages.show.activity';
- keepTab.updateTabs('work-packages.show.activity');
+ uiRouterGlobals.params.tabIdentifier = 'activity';
+ $state.current.name = 'work-packages.show.tabs';
+ keepTab.updateTabs('activity');
});
it('should set the tab to overview', () => {
- expect(keepTab.currentDetailsState).toEqual('work-packages.partitioned.list.details.overview');
+ expect(keepTab.currentDetailsTab).toEqual('overview');
});
});
@@ -135,17 +138,16 @@ describe('keepTab service', () => {
return path === '**.details.*';
});
- $state.current.name = 'work-packages.partitioned.list.details.activity';
+ uiRouterGlobals.params.tabIdentifier = 'activity';
+ $state.current.name = 'work-packages.partitioned.list.details.tabs';
keepTab.updateTabs();
});
it('should update the currentShowTab value', () => {
- expect(keepTab.currentDetailsState).toEqual('work-packages.partitioned.list.details.activity');
expect(keepTab.currentDetailsTab).toEqual('activity');
});
it('should also update the value of currentDetailsTab', () => {
- expect(keepTab.currentShowState).toEqual('work-packages.show.activity');
expect(keepTab.currentShowTab).toEqual('activity');
});
@@ -154,8 +156,8 @@ describe('keepTab service', () => {
var expected = {
active: 'activity',
- details: 'work-packages.partitioned.list.details.activity',
- show: 'work-packages.show.activity'
+ details: 'activity',
+ show: 'activity'
};
keepTab.observable.subscribe(cb);
diff --git a/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.ts b/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.ts
index a6470b4594e..cc8c261ede2 100644
--- a/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.ts
+++ b/frontend/src/app/components/wp-single-view-tabs/keep-tab/keep-tab.service.ts
@@ -26,9 +26,10 @@
// See docs/COPYRIGHT.rdoc for more details.
//++
-import { StateService, Transition, TransitionService } from '@uirouter/core';
+import { StateService, Transition, TransitionService, UIRouterGlobals } from '@uirouter/core';
import { ReplaySubject } from 'rxjs';
import { Injectable } from "@angular/core";
+import { splitViewRoute } from "core-app/modules/work_packages/routing/split-view-routes.helper";
@Injectable({ providedIn: 'root' })
export class KeepTabService {
@@ -37,11 +38,12 @@ export class KeepTabService {
protected subject = new ReplaySubject<{ [tab:string]:string; }>(1);
constructor(protected $state:StateService,
+ protected uiRouterGlobals:UIRouterGlobals,
protected $transitions:TransitionService) {
this.updateTabs();
$transitions.onSuccess({}, (transition:Transition) => {
- this.updateTabs(transition.to().name);
+ this.updateTabs(transition.params('to').tabIdentifier);
});
}
@@ -60,19 +62,31 @@ export class KeepTabService {
return this.currentDetailsTab;
}
- public get currentShowState():string {
- return 'work-packages.show.' + this.currentShowTab;
+ public goCurrentShowState(params:Record<string, unknown> = {}):void {
+ this.$state.go(
+ 'work-packages.show.tabs',
+ {
+ ...this.uiRouterGlobals.params,
+ ...params,
+ tabIdentifier: this.currentShowTab,
+ },
+ );
}
- public get currentDetailsState():string {
- return 'work-packages.partitioned.list.details.' + this.currentDetailsTab;
+ public goCurrentDetailsState(params:Record<string, unknown> = {}):void {
+ const route = splitViewRoute(this.$state);
+
+ this.$state.go(
+ route + '.tabs',
+ {
+ ...this.uiRouterGlobals.params,
+ ...params,
+ tabIdentifier: this.currentDetailsTab,
+ },
+ );
}
- public get currentDetailsSubState():string {
- return '.details.' + this.currentDetailsTab;
- }
-
- public isDetailsState(stateName:string) {
+ public isDetailsState(stateName:string):boolean {
return !!stateName && stateName.includes('.details');
}
@@ -94,15 +108,14 @@ export class KeepTabService {
// Notify when updated
this.subject.next({
active: this.lastActiveTab,
- show: this.currentShowState,
- details: this.currentDetailsState
+ show: this.currentShowTab,
+ details: this.currentDetailsTab,
});
}
protected updateTab(stateName:string) {
if (this.isCurrentState(stateName)) {
- const current = this.$state.current.name as string;
- this.currentTab = (current.split('.') as any[]).pop();
+ this.currentTab = this.uiRouterGlobals.params.tabIdentifier;
this.notify();
}
@@ -119,10 +132,10 @@ export class KeepTabService {
return false;
}
- public updateTabs(stateName?:string) {
+ public updateTabs(currentTab?:string) {
// Ignore the switch from show#activity to details#activity
// and show details#overview instead
- if (stateName === 'work-packages.show.activity') {
+ if (this.isCurrentState('show') && currentTab === 'activity') {
this.currentTab = 'overview';
return this.notify();
}
diff --git a/frontend/src/app/components/wp-single-view-tabs/wp-linked-resource-cache.service.ts b/frontend/src/app/components/wp-single-view-tabs/wp-linked-resource-cache.service.ts
index d14351c6538..a55c7622142 100644
--- a/frontend/src/app/components/wp-single-view-tabs/wp-linked-resource-cache.service.ts
+++ b/frontend/src/app/components/wp-single-view-tabs/wp-linked-resource-cache.service.ts
@@ -29,6 +29,7 @@
import { WorkPackageResource } from 'core-app/modules/hal/resources/work-package-resource';
import { input, InputState } from 'reactivestates';
import { take } from 'rxjs/operators';
+import { Observable, of } from "rxjs";
export abstract class WorkPackageLinkedResourceCache<T> {
@@ -50,7 +51,7 @@ export abstract class WorkPackageLinkedResourceCache<T> {
* @param {WorkPackageResource} workPackage
* @returns {Promise<T>}
*/
- public require(workPackage:WorkPackageResource, force = false):Promise<T> {
+ public requireAndStream(workPackage:WorkPackageResource, force = false):Observable<T> {
const id = workPackage.id!;
const state = this.cache.state;
@@ -61,16 +62,22 @@ export abstract class WorkPackageLinkedResourceCache<T> {
// Return cached value if id matches and value is present
if (this.isCached(id)) {
- return Promise.resolve(state.value!);
+ return of(state.value!);
}
// Ensure value is loaded only once
this.cache.id = id;
this.cache.state.putFromPromiseIfPristine(() => this.load(workPackage));
- return this.cache.state
- .values$()
- .pipe(take(1))
+ return this.cache.state.values$();
+ }
+
+ public require(workPackage:WorkPackageResource, force = false):Promise<T> {
+ return this
+ .requireAndStream(workPackage, force)
+ .pipe(
+ take(1)
+ )
.toPromise();
}
diff --git a/frontend/src/app/components/wp-table/configuration-modal/tab-portal-outlet.ts b/frontend/src/app/components/wp-table/configuration-modal/tab-portal-outlet.ts
index 72de9d56d82..2509831e79d 100644
--- a/frontend/src/app/components/wp-table/configuration-modal/tab-portal-outlet.ts
+++ b/frontend/src/app/components/wp-table/configuration-modal/tab-portal-outlet.ts
@@ -10,11 +10,9 @@ import {
EmbeddedViewRef,
Injector
} from '@angular/core';
+import { TabDefinition } from "core-app/modules/common/tabs/tab.interface";
-export interface TabInterface {
- name:string;
- title:string;
- disableBecause?:string;
+export interface TabInterface extends TabDefinition {
componentClass:{ new(...args:any[]):TabComponent };
}
@@ -22,8 +20,7 @@ export interface TabComponent {
onSave:() => void;
}
-export interface ActiveTabInterface {
- name:string;
+export interface ActiveTabInterface extends TabDefinition {
portal:ComponentPortal<TabComponent>;
componentRef:ComponentRef<TabComponent>;
dispose:() => void;
@@ -50,15 +47,9 @@ export class TabPortalOutlet {
return tabs.map((tab:ActiveTabInterface) => tab.componentRef.instance);
}
- public switchTo(name:string) {
- const tab = _.find(this.availableTabs, tab => tab.name === name);
-
- if (!tab) {
- throw(`Trying to switch to unknown tab ${name}.`);
- }
-
- if (tab.disableBecause != null) {
- return false;
+ public switchTo(tab:TabInterface):void {
+ if (tab.disable !== undefined) {
+ return;
}
// Detach any current instance
@@ -71,10 +62,10 @@ export class TabPortalOutlet {
// where we want it to be rendered.
this.outletElement.innerHTML = '';
this.outletElement.appendChild(this._getComponentRootNode(instance.componentRef));
- this.outletElement.dataset.tabName = tab.title;
+ this.outletElement.dataset.tabName = tab.name;
this.currentTab = instance;
- return false;
+ return;
}
public detach():void {
@@ -115,7 +106,7 @@ export class TabPortalOutlet {
this.appRef.attachView(componentRef.hostView);
return {
- name: tab.name,
+ ...tab,
portal: portal,
componentRef: componentRef,
dispose: () => {
diff --git a/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.html b/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.html
index c16cac040fe..812b1859e3a 100644
--- a/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.html
+++ b/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.html
@@ -1,6 +1,6 @@
<div
- class="op-modal op-modal_wide wp-table--configuration-modal loading-indicator--location"
- data-indicator-name="modal"
+ class="op-modal op-modal_wide wp-table--configuration-modal loading-indicator--location"
+ data-indicator-name="modal"
>
<op-modal-header (close)="closeMe($event)">{{text.title}}</op-modal-header>
@@ -10,33 +10,28 @@
<ng-container *ngComponentOutlet="prependModalComponent; injector: injector"></ng-container>
</ng-container>
- <div *ngIf="!!tabPortalHost"
- class="content--tabs scrollable-tabs">
- <ul class="tabrow">
- <li *ngFor="let tab of availableTabs"
- [ngClass]="{ 'selected': currentTab && tab.name === currentTab.name, '-disabled': tab.disableBecause != null }">
- <a
- class="tab-show"
- role="button"
- [ngClass]="{ 'selected': currentTab && tab.name === currentTab.name }"
- [attr.title]="tab.disableBecause || tab.title"
- [textContent]="tab.title"
- (click)="switchTo(tab.name)"
- href
- ></a>
- </ul>
- </div>
+ <op-scrollable-tabs
+ *ngIf="tabPortalHost"
+ [tabs]="availableTabs"
+ [currentTabId]="tabPortalHost.currentTab?.id"
+ (tabSelected)="switchTo($event)"
+ >
+ </op-scrollable-tabs>
<div class="tab-content" #tabContentOutlet></div>
</div>
<div class="op-modal--footer">
- <button class="button -highlight"
- [textContent]="text.applyButton"
- (click)="saveChanges()">
+ <button
+ class="button -highlight"
+ [textContent]="text.applyButton"
+ (click)="saveChanges()"
+ >
</button>
- <button class="button"
- [textContent]="text.cancelButton"
- (click)="closeMe($event)">
+ <button
+ class="button"
+ [textContent]="text.cancelButton"
+ (click)="closeMe($event)"
+ >
</button>
</div>
</div>
diff --git a/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.ts b/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.ts
index 6c8fe0f0d3e..0a6568fb226 100644
--- a/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.ts
+++ b/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.modal.ts
@@ -106,8 +106,9 @@ export class WpTableConfigurationModalComponent extends OpModalComponent impleme
this.loadingIndicator.indicator('modal').promise = this.loadForm()
.then(() => {
- const initialTab = this.locals['initialTab'] || this.availableTabs[0].name;
- this.switchTo(initialTab);
+ const initialTabName = this.locals['initialTab'];
+ const initialTab = this.availableTabs.find(el => el.id === initialTabName);
+ this.switchTo(initialTab || this.availableTabs[0]);
});
}
@@ -124,8 +125,8 @@ export class WpTableConfigurationModalComponent extends OpModalComponent impleme
return this.tabPortalHost.currentTab;
}
- public switchTo(name:string) {
- this.tabPortalHost.switchTo(name);
+ public switchTo(tab:TabInterface) {
+ this.tabPortalHost.switchTo(tab);
}
public saveChanges():void {
diff --git a/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.service.ts b/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.service.ts
index 96180a7f90b..16eb8fc0560 100644
--- a/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.service.ts
+++ b/frontend/src/app/components/wp-table/configuration-modal/wp-table-configuration.service.ts
@@ -13,33 +13,33 @@ export class WpTableConfigurationService {
protected _tabs:TabInterface[] = [
{
- name: 'columns',
- title: this.I18n.t('js.label_columns'),
+ id: 'columns',
+ name: this.I18n.t('js.label_columns'),
componentClass: WpTableConfigurationColumnsTab,
},
{
- name: 'filters',
- title: this.I18n.t('js.work_packages.query.filters'),
+ id: 'filters',
+ name: this.I18n.t('js.work_packages.query.filters'),
componentClass: WpTableConfigurationFiltersTab,
},
{
- name: 'sort-by',
- title: this.I18n.t('js.label_sort_by'),
+ id: 'sort-by',
+ name: this.I18n.t('js.label_sort_by'),
componentClass: WpTableConfigurationSortByTab,
},
{
- name: 'display-settings',
- title: this.I18n.t('js.work_packages.table_configuration.display_settings'),
+ id: 'display-settings',
+ name: this.I18n.t('js.work_packages.table_configuration.display_settings'),
componentClass: WpTableConfigurationDisplaySettingsTab,
},
{
- name: 'highlighting',
- title: this.I18n.t('js.work_packages.table_configuration.highlighting'),
+ id: 'highlighting',
+ name: this.I18n.t('js.work_packages.table_configuration.highlighting'),
componentClass: WpTableConfigurationHighlightingTab,
},
{
- name: 'timelines',
- title: this.I18n.t('js.timelines.gantt_chart'),
+ id: 'timelines',
+ name: this.I18n.t('js.timelines.gantt_chart'),
componentClass: WpTableConfigurationTimelinesTab
}
];
diff --git a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
index 5c04bfb451d..8f72521b2c0 100644
--- a/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
+++ b/frontend/src/app/components/wp-table/embedded/wp-embedded-table.component.ts
@@ -194,10 +194,16 @@ export class WorkPackageEmbeddedTableComponent extends WorkPackageEmbeddedBaseCo
}
}
- openStateLink(event:{ workPackageId:string; requestedState:string }) {
- this.$state.go(
- (this.keepTab as any)[event.requestedState] || event.requestedState,
- { workPackageId: event.workPackageId, focus: true }
- );
+ openStateLink(event:{ workPackageId:string; requestedState:'show'|'split' }) {
+ const params = {
+ workPackageId: event.workPackageId,
+ focus: true,
+ };
+
+ if (event.requestedState === 'split') {
+ this.keepTab.goCurrentDetailsState(params);
+ } else {
+ this.keepTab.goCurrentShowState(params);
+ }
}
}
diff --git a/frontend/src/app/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts b/frontend/src/app/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts
index 16186da6e65..579b7b39b5d 100644
--- a/frontend/src/app/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts
+++ b/frontend/src/app/components/wp-table/external-configuration/restricted-wp-table-configuration.service.ts
@@ -19,9 +19,9 @@ export class RestrictedWpTableConfigurationService extends WpTableConfigurationS
return this
._tabs
.map(el => {
- const reason = disabledTabs[el.name];
+ const reason = disabledTabs[el.id];
if (reason != null) {
- el.disableBecause = reason;
+ el.disable = reason;
}
return el;
diff --git a/frontend/src/app/components/wp-tabs/components/wp-tab-wrapper/tab.ts b/frontend/src/app/components/wp-tabs/components/wp-tab-wrapper/tab.ts
index cb2a92b3dd8..cef75c9aa82 100644
--- a/frontend/src/app/components/wp-tabs/components/wp-tab-wrapper/tab.ts
+++ b/frontend/src/app/components/wp-tabs/components/wp-tab-wrapper/tab.ts
@@ -1,15 +1,19 @@
-import {Type, Component} from '@angular/core';
+import { Component, Injector, Type } from '@angular/core';
-import {WorkPackageBaseResource, WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';
+import { WorkPackageResource } from 'core-app/modules/hal/resources/work-package-resource';
+import { StateDeclaration } from "@uirouter/core";
+import { StateParams } from "@uirouter/core/lib/params/stateParams";
+import { Observable } from "rxjs";
+import { StateService } from "@uirouter/angular";
+import { TabDefinition } from "core-app/modules/common/tabs/tab.interface";
export interface TabComponent extends Component {
workPackage:WorkPackageResource;
}
-export class Tab {
- constructor(
- public component:Type<TabComponent>,
- public displayName:string,
- public identifier:string,
- public displayable:(work_package:WorkPackageBaseResource) => boolean
- ) {}
+
+export interface WpTabDefinition extends TabDefinition {
+ component:Type<TabComponent>;
+ displayable?:(workPackage:WorkPackageResource, $state:StateService) => boolean;
+ count?:(workPackage:WorkPackageResource, injector:Injector) => Observable<number>;
}
+
diff --git a/frontend/src/app/components/wp-tabs/components/wp-tab-wrapper/wp-tab-wrapper.component.ts b/frontend/src/app/components/wp-tabs/components/wp-tab-wrapper/wp-tab-wrapper.component.ts
index d32986dec71..fd77fb2dfd0 100644
--- a/frontend/src/app/components/wp-tabs/components/wp-tab-wrapper/wp-tab-wrapper.component.ts
+++ b/frontend/src/app/components/wp-tabs/components/wp-tab-wrapper/wp-tab-wrapper.component.ts
@@ -26,25 +26,25 @@
// See docs/COPYRIGHT.rdoc for more details.
// ++
-import {Transition} from '@uirouter/core';
-import {Component, OnInit} from '@angular/core';
-import {I18nService} from 'core-app/modules/common/i18n/i18n.service';
-import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';
-import {APIV3Service} from 'core-app/modules/apiv3/api-v3.service';
-import {Tab} from './tab';
-import {WpTabsService} from "core-components/wp-tabs/services/wp-tabs/wp-tabs.service";
-import {Observable} from "rxjs";
-import {map} from "rxjs/operators";
+import { Transition } from '@uirouter/core';
+import { Component, OnInit } from '@angular/core';
+import { I18nService } from 'core-app/modules/common/i18n/i18n.service';
+import { WorkPackageResource } from 'core-app/modules/hal/resources/work-package-resource';
+import { APIV3Service } from 'core-app/modules/apiv3/api-v3.service';
+import { WorkPackageTabsService } from "core-components/wp-tabs/services/wp-tabs/wp-tabs.service";
+import { Observable } from "rxjs";
+import { map } from "rxjs/operators";
+import { WpTabDefinition } from "core-components/wp-tabs/components/wp-tab-wrapper/tab";
@Component({
templateUrl: './wp-tab-wrapper.html',
- selector: 'wp-tab',
+ selector: 'op-wp-tab',
})
export class WpTabWrapperComponent implements OnInit {
workPackage:WorkPackageResource;
ndcDynamicInputs$:Observable<{
workPackage:WorkPackageResource;
- tab:Tab | undefined;
+ tab:WpTabDefinition | undefined;
}>;
get workPackageId() {
@@ -54,7 +54,7 @@ export class WpTabWrapperComponent implements OnInit {
constructor(readonly I18n:I18nService,
readonly $transition:Transition,
readonly apiV3Service:APIV3Service,
- readonly wpTabsService:WpTabsService) {}
+ readonly wpTabsService:WorkPackageTabsService) {}
ngOnInit() {
this.ndcDynamicInputs$ = this
@@ -70,7 +70,7 @@ export class WpTabWrapperComponent implements OnInit {
);
}
- findTab(workPackage:WorkPackageResource):Tab | undefined {
+ findTab(workPackage:WorkPackageResource):WpTabDefinition | undefined {
const tabIdentifier = this.$transition.params('to').tabIdentifier;
return this.wpTabsService.getTab(tabIdentifier, workPackage);
diff --git a/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.html b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.html
index 76ab629e09b..9001276f010 100644
--- a/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.html
+++ b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.html
@@ -1,5 +1,26 @@
-<li *ngFor="let tab of tabs" [uiSref]="uiSref"
- [uiParams]="{workPackageId: workPackage.id, tabIdentifier: tab.identifier}"
- uiSrefActive="selected">
- <a href="" [textContent]="tab.displayName"></a>
-</li>
+<op-scrollable-tabs
+ [tabs]="tabs"
+ class="op-work-package-tabs">
+ <ng-container slot="actions" *ngIf="view === 'split'">
+ <li class="tab-icon">
+ <accessible-by-keyboard
+ (execute)="switchToFullscreen()"
+ [linkAriaLabel]="text.details.goToFullScreen"
+ [linkTitle]="text.details.goToFullScreen"
+ linkClass="work-packages--details-fullscreen-icon"
+ spanClass="icon-context icon-to-fullscreen"
+ >
+ </accessible-by-keyboard>
+ </li>
+ <li class="tab-icon">
+ <accessible-by-keyboard
+ (execute)="close()"
+ [linkAriaLabel]="text.details.close"
+ [linkTitle]="text.details.close"
+ linkClass="work-packages--details-close-icon"
+ spanClass="icon-context icon-close"
+ >
+ </accessible-by-keyboard>
+ </li>
+ </ng-container>
+</op-scrollable-tabs>
diff --git a/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.sass b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.sass
new file mode 100644
index 00000000000..458209a7018
--- /dev/null
+++ b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.sass
@@ -0,0 +1,3 @@
+.op-work-package-tabs
+ position: relative
+ width: 100%
\ No newline at end of file
diff --git a/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.scss b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.scss
deleted file mode 100644
index e69de29bb2d..00000000000
diff --git a/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.spec.ts b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.spec.ts
index a5a30e87380..55303c8b067 100644
--- a/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.spec.ts
+++ b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.spec.ts
@@ -1,56 +1,66 @@
-import { HttpClientModule } from '@angular/common/http';
-import { Injector } from '@angular/core';
-import {Input} from '@angular/core';
-import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing';
+import { Input } from '@angular/core';
+import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
import { By } from '@angular/platform-browser';
-import { OpenProjectDirectFileUploadService } from 'core-app/components/api/op-file-upload/op-direct-file-upload.service';
-import { OpenProjectFileUploadService } from 'core-app/components/api/op-file-upload/op-file-upload.service';
-import { States } from 'core-app/components/states.service';
import { WorkPackageResource } from 'core-app/modules/hal/resources/work-package-resource';
-import { HalResourceNotificationService } from 'core-app/modules/hal/services/hal-resource-notification.service';
-import { HalResourceService } from 'core-app/modules/hal/services/hal-resource.service';
-import { HookService } from 'core-app/modules/plugins/hook-service';
-import { Tab, TabComponent } from '../wp-tab-wrapper/tab';
+import { TabComponent } from '../wp-tab-wrapper/tab';
import { WpTabsComponent } from './wp-tabs.component';
+import { WorkPackageTabsService } from "core-components/wp-tabs/services/wp-tabs/wp-tabs.service";
+import { StateService } from "@uirouter/angular";
+import { UIRouterGlobals } from "@uirouter/core";
+import { KeepTabService } from "core-components/wp-single-view-tabs/keep-tab/keep-tab.service";
+import { ScrollableTabsComponent } from "core-app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component";
describe('WpTabsComponent', () => {
class TestComponent implements TabComponent {
@Input() public workPackage:WorkPackageResource;
}
- const displayableTab = new Tab(TestComponent, 'Displayable TestTab', 'displayable-test-tab', (_) => true)
- const notDisplayableTab = new Tab(TestComponent, 'NotDisplayable TestTab', 'not-displayable-test-tab', (_) => false)
+ const displayableTab = {
+ component: TestComponent,
+ name: 'Displayable TestTab',
+ id: 'displayable-test-tab',
+ displayable: () => true
+ };
- const HookServiceStub = {
- getWorkPackageTabs: () => [displayableTab, notDisplayableTab]
+ const notDisplayableTab = {
+ component: TestComponent,
+ name: 'NotDisplayable TestTab',
+ id: 'not-displayable-test-tab',
+ displayable: () => false
};
- let component: WpTabsComponent;
- let fixture: ComponentFixture<WpTabsComponent>;
+ let component:WpTabsComponent;
+ let service:WorkPackageTabsService;
+ let fixture:ComponentFixture<WpTabsComponent>;
beforeEach(async () => {
await TestBed.configureTestingModule({
- declarations: [ WpTabsComponent ],
+ declarations: [WpTabsComponent, ScrollableTabsComponent],
providers: [
- { provide: HookService, useValue: HookServiceStub }
- ]
+ { provide: StateService, useValue: { includes: () => false } },
+ { provide: UIRouterGlobals, useValue: {} },
+ { provide: KeepTabService, useValue: {} },
+ WorkPackageTabsService,
+ ],
})
- .compileComponents();
+ .compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(WpTabsComponent);
+ service = TestBed.inject(WorkPackageTabsService);
+ (service as any).registeredTabs = [];
+ service.register(displayableTab, notDisplayableTab);
+
component = fixture.componentInstance;
component.workPackage = {} as WorkPackageResource;
fixture.detectChanges();
});
- it('displays the visible tab', waitForAsync(() => {
- fixture.whenStable().then(() => {
- const tabLink:HTMLElement = fixture.debugElement.query(By.css('li a')).nativeElement;
- expect(tabLink.innerText).toContain('Displayable TestTab');
- });
+ it('displays the visible tab', fakeAsync(() => {
+ const tabLink:HTMLElement = fixture.debugElement.query(By.css('[data-qa-tab-id="displayable-test-tab"]')).nativeElement;
+ expect(tabLink.innerText).toContain('Displayable TestTab');
}));
});
diff --git a/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.ts b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.ts
index 326c719965c..641814b34fd 100644
--- a/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.ts
+++ b/frontend/src/app/components/wp-tabs/components/wp-tabs/wp-tabs.component.ts
@@ -1,28 +1,71 @@
-import {Component, Input} from '@angular/core';
-import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";
-import {WpTabsService} from "core-components/wp-tabs/services/wp-tabs/wp-tabs.service";
-import {Tab} from "core-app/components/wp-tabs/components/wp-tab-wrapper/tab";
+import { ChangeDetectionStrategy, Component, Injector, Input, OnInit } from '@angular/core';
+import { WorkPackageResource } from "core-app/modules/hal/resources/work-package-resource";
+import { WorkPackageTabsService } from "core-components/wp-tabs/services/wp-tabs/wp-tabs.service";
+import { I18nService } from "core-app/modules/common/i18n/i18n.service";
+import { StateService } from "@uirouter/angular";
+import { KeepTabService } from "core-components/wp-single-view-tabs/keep-tab/keep-tab.service";
+import { UIRouterGlobals } from "@uirouter/core";
+import { AngularTrackingHelpers } from "core-components/angular/tracking-functions";
+import { TabDefinition } from "core-app/modules/common/tabs/tab.interface";
@Component({
selector: 'op-wp-tabs',
templateUrl: './wp-tabs.component.html',
- styleUrls: ['./wp-tabs.component.scss']
+ styleUrls: ['./wp-tabs.component.sass'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class WpTabsComponent {
- @Input()
- workPackage:WorkPackageResource;
- @Input()
- set view(uiSref:'full' | 'split') {
- this.uiSref = uiSref === 'split' ? '.tabs' : 'work-packages.show.tabs';
+export class WpTabsComponent implements OnInit {
+ @Input() workPackage:WorkPackageResource;
+ @Input() view:'full'|'split';
+
+ public tabs:TabDefinition[];
+ public uiSrefBase:string;
+ public canViewWatchers = false;
+
+ text = {
+ details: {
+ close: this.I18n.t('js.button_close_details'),
+ goToFullScreen: this.I18n.t('js.work_packages.message_successful_show_in_fullscreen'),
+ },
+ };
+
+ constructor(
+ readonly wpTabsService:WorkPackageTabsService,
+ readonly I18n:I18nService,
+ readonly injector:Injector,
+ readonly $state:StateService,
+ readonly uiRouterGlobals:UIRouterGlobals,
+ readonly keepTab:KeepTabService,
+ ) {
}
- get tabs():Tab[] {
- return this.wpTabsService.getDisplayableTabs(this.workPackage);
+ ngOnInit():void {
+ this.uiSrefBase = this.view === 'split' ? '' : 'work-packages.show';
+ this.canViewWatchers = !!(this.workPackage && this.workPackage.watchers);
+ this.tabs = this.getDisplayableTabs();
}
- uiSref:string;
+ private getDisplayableTabs() {
+ return this
+ .wpTabsService
+ .getDisplayableTabs(this.workPackage)
+ .map(tab => {
+ return {
+ ...tab,
+ route: this.uiSrefBase + '.tabs',
+ routeParams: { workPackageId: this.workPackage.id, tabIdentifier: tab.id }
+ };
+ });
+ }
- constructor(
- readonly wpTabsService:WpTabsService,
- ) { }
+ public switchToFullscreen():void {
+ this.keepTab.goCurrentShowState();
+ }
+
+ public close():void {
+ this.$state.go(
+ this.uiRouterGlobals.current.data.baseRoute,
+ this.uiRouterGlobals.params
+ );
+ }
}
diff --git a/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-relations-count.function.ts b/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-relations-count.function.ts
new file mode 100644
index 00000000000..34f2132b6f0
--- /dev/null
+++ b/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-relations-count.function.ts
@@ -0,0 +1,36 @@
+import { Component, Injector, Input, OnInit } from '@angular/core';
+import { combineLatest, Observable } from 'rxjs';
+import { UntilDestroyedMixin } from "core-app/helpers/angular/until-destroyed.mixin";
+import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
+import { WorkPackageRelationsService } from "core-components/wp-relations/wp-relations.service";
+import { WorkPackageResource } from "core-app/modules/hal/resources/work-package-resource";
+import { map } from "rxjs/operators";
+
+export function workPackageRelationsCount(
+ workPackage:WorkPackageResource,
+ injector:Injector,
+):Observable<number> {
+ const wpRelations = injector.get(WorkPackageRelationsService);
+ const apiV3Service = injector.get(APIV3Service);
+ const wpId = workPackage.id!.toString();
+
+ wpRelations.require(wpId);
+
+ return combineLatest([
+ wpRelations
+ .state(wpId.toString())
+ .values$(),
+ apiV3Service
+ .work_packages
+ .id(wpId)
+ .requireAndStream(),
+ ])
+ .pipe(
+ map(([relations, workPackage]) => {
+ const relationCount = _.size(relations);
+ const childrenCount = _.size(workPackage.children);
+
+ return relationCount + childrenCount;
+ }),
+ );
+}
diff --git a/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-tabs.service.spec.ts b/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-tabs.service.spec.ts
index e4a8e713010..150855664c2 100644
--- a/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-tabs.service.spec.ts
+++ b/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-tabs.service.spec.ts
@@ -1,71 +1,62 @@
import { HttpClientModule } from '@angular/common/http';
-import { Injector } from '@angular/core';
-import { Input } from '@angular/core';
+import { Injector, Input } from '@angular/core';
import { TestBed } from '@angular/core/testing';
-import { OpenProjectDirectFileUploadService } from 'core-app/components/api/op-file-upload/op-direct-file-upload.service';
-import { OpenProjectFileUploadService } from 'core-app/components/api/op-file-upload/op-file-upload.service';
-import { States } from 'core-app/components/states.service';
import { WorkPackageResource } from 'core-app/modules/hal/resources/work-package-resource';
-import { HalResourceNotificationService } from 'core-app/modules/hal/services/hal-resource-notification.service';
import { HalResourceService } from 'core-app/modules/hal/services/hal-resource.service';
-import { HookService } from 'core-app/modules/plugins/hook-service';
-import { Tab, TabComponent } from '../../components/wp-tab-wrapper/tab';
+import { TabComponent } from '../../components/wp-tab-wrapper/tab';
-import { WpTabsService } from './wp-tabs.service';
+import { WorkPackageTabsService } from './wp-tabs.service';
+import { StateService } from "@uirouter/angular";
describe('WpTabsService', () => {
- let service: WpTabsService;
- let workPackage:WorkPackageResource;
+ let service:WorkPackageTabsService;
+ let workPackage:any = { id: 1234 };
let injector:Injector;
let halResourceService:HalResourceService;
- let source = {
- _type: 'WorkPackage',
- id: '1234',
- _links: {}
- };
-
class TestComponent implements TabComponent {
@Input() public workPackage:WorkPackageResource;
}
- const displayableTab = new Tab(TestComponent, 'Displayable TestTab', 'displayable-test-tab', (_) => true)
- const nonDisplayableTab = new Tab(TestComponent, 'NotDisplayable TestTab', 'non-displayable-test-tab', (_) => false)
+ const displayableTab = {
+ component: TestComponent,
+ name: 'Displayable TestTab',
+ id: 'displayable-test-tab',
+ displayable: () => true,
+ };
- const HookServiceStub = {
- getWorkPackageTabs: () => [displayableTab, nonDisplayableTab]
+ const notDisplayableTab = {
+ component: TestComponent,
+ name: 'NotDisplayable TestTab',
+ id: 'not-displayable-test-tab',
+ displayable: () => false,
};
beforeEach(() => {
TestBed.configureTestingModule({
imports: [
- HttpClientModule
+ HttpClientModule,
],
providers: [
- { provide: HookService, useValue: HookServiceStub },
- OpenProjectFileUploadService,
- OpenProjectDirectFileUploadService,
- HalResourceService,
- HalResourceNotificationService,
- States
+ { provide: StateService, useValue: { includes: () => false } }
]
});
- service = TestBed.inject(WpTabsService);
+ service = TestBed.inject(WorkPackageTabsService);
+ (service as any).registeredTabs = [];
+ service.register(displayableTab, notDisplayableTab);
injector = TestBed.inject(Injector);
- halResourceService = injector.get(HalResourceService);
- workPackage = halResourceService.createHalResourceOfClass(WorkPackageResource, source, true);
});
- describe('displayableTabs()', () =>{
+ describe('displayableTabs()', () => {
it('returns just the displayable tab', () => {
expect(service.getDisplayableTabs(workPackage)).toEqual([displayableTab]);
});
});
- describe('getTab()', () =>{
+ describe('getTab()', () => {
it('returns the displayable tab whith the correct identifier', () => {
- expect(service.getTab('displayable-test-tab', workPackage)).toEqual(displayableTab);
+ expect(service.getTab('displayable-test-tab', workPackage)?.id).toEqual('displayable-test-tab');
expect(service.getTab('non-existing-tab', workPackage)).toEqual(undefined);
expect(service.getTab('non-displayable-test-tab', workPackage)).toEqual(undefined);
});
diff --git a/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-tabs.service.ts b/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-tabs.service.ts
index 1e56252cfc7..7e051ffd568 100644
--- a/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-tabs.service.ts
+++ b/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-tabs.service.ts
@@ -1,25 +1,85 @@
-import { Injectable } from '@angular/core';
-import {HookService} from "core-app/modules/plugins/hook-service";
-import {WorkPackageResource} from "core-app/modules/hal/resources/work-package-resource";
-import {Tab} from "core-components/wp-tabs/components/wp-tab-wrapper/tab";
+import { Injectable, Injector } from '@angular/core';
+import { WorkPackageResource } from "core-app/modules/hal/resources/work-package-resource";
+import { WpTabDefinition } from "core-components/wp-tabs/components/wp-tab-wrapper/tab";
+import { WorkPackageActivityTabComponent } from "core-components/wp-single-view-tabs/activity-panel/activity-tab.component";
+import { WorkPackageRelationsTabComponent } from "core-components/wp-single-view-tabs/relations-tab/relations-tab.component";
+import { WorkPackageWatchersTabComponent } from "core-components/wp-single-view-tabs/watchers-tab/watchers-tab.component";
+import { workPackageRelationsCount } from "core-components/wp-tabs/services/wp-tabs/wp-relations-count.function";
+import { workPackageWatchersCount } from "core-components/wp-tabs/services/wp-tabs/wp-watchers-count.function";
+import { StateService } from "@uirouter/angular";
+import { WorkPackageOverviewTabComponent } from "core-components/wp-single-view-tabs/overview-tab/overview-tab.component";
+import { I18nService } from "core-app/modules/common/i18n/i18n.service";
+import { TabDefinition } from "core-app/modules/common/tabs/tab.interface";
@Injectable({
- providedIn: 'root'
+ providedIn: 'root',
})
-export class WpTabsService {
- get tabs() {
- return this.hookService.getWorkPackageTabs();
- }
+export class WorkPackageTabsService {
+ private registeredTabs:WpTabDefinition[];
constructor(
- private hookService:HookService,
- ) { }
+ private $state:StateService,
+ private I18n:I18nService,
+ private injector:Injector,
+ ) {
+ this.registeredTabs = this.buildDefaultTabs();
+ }
+
+ get tabs():WpTabDefinition[] {
+ return [...this.registeredTabs];
+ }
+
+ register(...tabs:WpTabDefinition[]) {
+ this.registeredTabs = [
+ ...this.registeredTabs,
+ ...tabs,
+ ];
+ }
+
+ getDisplayableTabs(workPackage:WorkPackageResource):WpTabDefinition[] {
+ return this
+ .tabs
+ .filter(
+ tab => !tab.displayable || tab.displayable(workPackage, this.$state),
+ )
+ .map(
+ tab => ({
+ ...tab,
+ ...!!tab.count && { counter: tab.count(workPackage, this.injector) },
+ }),
+ );
+ }
- getDisplayableTabs(workPackage:WorkPackageResource):Tab[] {
- return this.tabs.filter(tab => tab.displayable(workPackage));
+ getTab(tabId:string, workPackage:WorkPackageResource):WpTabDefinition|undefined {
+ return this.getDisplayableTabs(workPackage).find(({ id: id }) => id === tabId);
}
- getTab(tabId:string, workPackage:WorkPackageResource):Tab | undefined {
- return this.getDisplayableTabs(workPackage).find(({identifier:id}) => id === tabId);
+ private buildDefaultTabs():WpTabDefinition[] {
+ return [
+ {
+ component: WorkPackageOverviewTabComponent,
+ name: this.I18n.t('js.work_packages.tabs.overview'),
+ id: 'overview',
+ displayable: (_, $state) => $state.includes('**.details.*'),
+ },
+ {
+ id: 'activity',
+ component: WorkPackageActivityTabComponent,
+ name: I18n.t('js.work_packages.tabs.activity'),
+ },
+ {
+ id: 'relations',
+ component: WorkPackageRelationsTabComponent,
+ name: I18n.t('js.work_packages.tabs.relations'),
+ count: workPackageRelationsCount,
+ },
+ {
+ id: 'watchers',
+ component: WorkPackageWatchersTabComponent,
+ name: I18n.t('js.work_packages.tabs.watchers'),
+ displayable: (workPackage) => !!workPackage.watchers,
+ count: workPackageWatchersCount,
+ },
+ ];
}
}
diff --git a/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-watchers-count.function.ts b/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-watchers-count.function.ts
new file mode 100644
index 00000000000..a153ebee46d
--- /dev/null
+++ b/frontend/src/app/components/wp-tabs/services/wp-tabs/wp-watchers-count.function.ts
@@ -0,0 +1,18 @@
+import { Injector } from '@angular/core';
+import { from, Observable } from 'rxjs';
+import { WorkPackageResource } from "core-app/modules/hal/resources/work-package-resource";
+import { map } from "rxjs/operators";
+import { HalResource } from "core-app/modules/hal/resources/hal-resource";
+import { WorkPackageWatchersService } from "core-components/wp-single-view-tabs/watchers-tab/wp-watchers.service";
+
+export function workPackageWatchersCount(
+ workPackage:WorkPackageResource,
+ injector:Injector,
+):Observable<number> {
+ const watcherService = injector.get(WorkPackageWatchersService);
+ return watcherService
+ .requireAndStream(workPackage)
+ .pipe(
+ map((watchers:HalResource[]) => watchers.length),
+ );
+}
diff --git a/frontend/src/app/components/wp-tabs/wp-tabs.module.ts b/frontend/src/app/components/wp-tabs/wp-tabs.module.ts
index 977f5c7f725..aeffb7a91b8 100644
--- a/frontend/src/app/components/wp-tabs/wp-tabs.module.ts
+++ b/frontend/src/app/components/wp-tabs/wp-tabs.module.ts
@@ -1,9 +1,11 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { WpTabsComponent } from './components/wp-tabs/wp-tabs.component';
-import {UIRouterModule} from "@uirouter/angular";
-import {WpTabWrapperComponent} from "core-components/wp-tabs/components/wp-tab-wrapper/wp-tab-wrapper.component";
-import {DynamicModule} from "ng-dynamic-component";
+import { UIRouterModule } from "@uirouter/angular";
+import { WpTabWrapperComponent } from "core-components/wp-tabs/components/wp-tab-wrapper/wp-tab-wrapper.component";
+import { DynamicModule } from "ng-dynamic-component";
+import { OpenprojectAccessibilityModule } from "core-app/modules/a11y/openproject-a11y.module";
+import { OpenprojectTabsModule } from "core-app/modules/common/tabs/openproject-tabs.module";
@NgModule({
declarations: [
@@ -14,10 +16,13 @@ import {DynamicModule} from "ng-dynamic-component";
CommonModule,
UIRouterModule,
DynamicModule,
+ OpenprojectAccessibilityModule,
+ OpenprojectTabsModule
],
exports: [
WpTabsComponent,
WpTabWrapperComponent,
- ]
+ ],
})
-export class OpWpTabsModule { }
+export class OpWpTabsModule {
+}
diff --git a/frontend/src/app/modules/autocompleter/te-work-package-autocompleter/te-work-package-autocompleter.component.html b/frontend/src/app/modules/autocompleter/te-work-package-autocompleter/te-work-package-autocompleter.component.html
index 47485fdee79..4dcc2b618ce 100644
--- a/frontend/src/app/modules/autocompleter/te-work-package-autocompleter/te-work-package-autocompleter.component.html
+++ b/frontend/src/app/modules/autocompleter/te-work-package-autocompleter/te-work-package-autocompleter.component.html
@@ -1,37 +1,55 @@
-<ng-select #ngSelectComponent
- [(ngModel)]="model"
- [items]="availableValues"
- [ngClass]="classes"
- [addTag]="createAllowed"
- [virtualScroll]="true"
- [required]="required"
- [clearable]="!required"
- [disabled]="disabled"
- [typeahead]="typeahead"
- [clearOnBackspace]="false"
- [appendTo]="appendTo"
- [hideSelected]="hideSelected"
- [loading]="finishedLoading | async"
- [id]="id"
- (change)="changeModel($event)"
- (open)="opened()"
- (close)="closed()"
- (keydown)="keyPressed($event)"
- bindLabel="name">
+<ng-select
+ #ngSelectComponent
+ [(ngModel)]="model"
+ [items]="availableValues"
+ [ngClass]="classes"
+ [addTag]="createAllowed"
+ [virtualScroll]="true"
+ [required]="required"
+ [clearable]="!required"
+ [disabled]="disabled"
+ [typeahead]="typeahead"
+ [clearOnBackspace]="false"
+ [appendTo]="appendTo"
+ [hideSelected]="hideSelected"
+ [loading]="finishedLoading | async"
+ [id]="id"
+ (change)="changeModel($event)"
+ (open)="opened()"
+ (close)="closed()"
+ (keydown)="keyPressed($event)"
+ bindLabel="name"
+>
<ng-template ng-header-tmp>
- <div class="scrollable-tabs -narrow">
- <ul class="tabrow">
- <li [ngClass]="{'selected': mode === 'all'}"
- (click)="setMode('all')">
- <a href="#" [textContent]="text.all">
- </a>
- </li>
- <li [ngClass]="{'selected': mode === 'recent'}"
- (click)="setMode('recent')">
- <a href="#" [textContent]="text.recent">
- </a>
- </li>
- </ul>
+ <div class="scrollable-tabs">
+ <div class="op-scrollable-tabs--tab-container">
+ <ul class="op-tab-row">
+ <li
+ class="op-tab-row--tab"
+ (click)="setMode('all')"
+ >
+ <a
+ href="#"
+ class="op-tab-row--link"
+ [class.op-tab-row--link_selected]="mode === 'all'"
+ [textContent]="text.all"
+ >
+ </a>
+ </li>
+ <li
+ class="op-tab-row--tab"
+ [ngClass]="{'selected': mode === 'recent'}"
+ (click)="setMode('recent')"
+ >
+ <a
+ class="op-tab-row--link"
+ href="#"
+ [textContent]="text.recent"
+ >
+ </a>
+ </li>
+ </ul>
+ </div>
</div>
</ng-template>
<ng-template ng-tag-tmp let-search="searchTerm">
diff --git a/frontend/src/app/modules/boards/board/board-list/board-list.component.ts b/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
index 5a4125dbd25..cbea634c7cf 100644
--- a/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
+++ b/frontend/src/app/modules/boards/board/board-list/board-list.component.ts
@@ -52,6 +52,7 @@ import { HalEvent, HalEventsService } from "core-app/modules/hal/services/hal-ev
import { ChangeItem } from "core-app/modules/fields/changeset/changeset";
import { SchemaCacheService } from "core-components/schemas/schema-cache.service";
import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
+import { KeepTabService } from "core-components/wp-single-view-tabs/keep-tab/keep-tab.service";
export interface DisabledButtonPlaceholder {
text:string;
@@ -147,7 +148,9 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
readonly boardService:BoardService,
readonly boardActionRegistry:BoardActionsRegistryService,
readonly causedUpdates:CausedUpdatesService,
- readonly $state:StateService) {
+ readonly keepTab:KeepTabService,
+ readonly $state:StateService,
+ ) {
super(I18n, injector);
}
@@ -180,16 +183,16 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
debounceTime(100),
this.untilDestroyed()
).subscribe((selectionState) => {
- const selected = Object.keys(_.pickBy(selectionState.selected, (selected, _) => selected === true));
+ const selected = Object.keys(_.pickBy(selectionState.selected, (selected, _) => selected === true));
- const focused = this.wpViewFocusService.focusedWorkPackage;
+ const focused = this.wpViewFocusService.focusedWorkPackage;
- this.boardListCrossSelectionService.updateSelection({
- withinQuery: this.queryId,
- focusedWorkPackage: focused,
- allSelected: selected
- });
+ this.boardListCrossSelectionService.updateSelection({
+ withinQuery: this.queryId,
+ focusedWorkPackage: focused,
+ allSelected: selected
});
+ });
// Apply focus and selection when changed in cross service
this.boardListCrossSelectionService
@@ -459,8 +462,8 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
return !!current && (current === to || current === from);
})
).subscribe((event) => {
- this.updateQuery(true);
- });
+ this.updateQuery(true);
+ });
}
openFullViewOnDoubleClick(event:{ workPackageId:string, double:boolean }) {
@@ -475,7 +478,11 @@ export class BoardListComponent extends AbstractWidgetComponent implements OnIni
openStateLink(event:{ workPackageId:string; requestedState:string }) {
const params = { workPackageId: event.workPackageId };
- this.$state.go(event.requestedState, params);
+ if (event.requestedState === 'split') {
+ this.keepTab.goCurrentDetailsState(params);
+ } else {
+ this.keepTab.goCurrentShowState(params);
+ }
}
private schema(workPackage:WorkPackageResource) {
diff --git a/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.html b/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.html
index eb67584b921..7ca4a1b4fc9 100644
--- a/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.html
+++ b/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.html
@@ -1,25 +1,27 @@
<div
- class="op-modal wp-table--configuration-modal loading-indicator--location"
- data-indicator-name="modal"
+ class="op-modal wp-table--configuration-modal loading-indicator--location"
+ data-indicator-name="modal"
>
<op-modal-header (close)="closeMe($event)">{{text.title}}</op-modal-header>
<div class="op-modal--body">
<div
- *ngIf="!!tabPortalHost"
- class="content--tabs scrollable-tabs"
+ *ngIf="!!tabPortalHost"
+ class="content--tabs scrollable-tabs"
>
- <ul class="tabrow">
- <li *ngFor="let tab of availableTabs"
- [ngClass]="{ 'selected': currentTab && tab.name === currentTab.name }">
+ <ul class="op-tab-row">
+ <li
+ *ngFor="let tab of availableTabs"
+ class="op-tab-row--tab"
+ >
<a
- class="tab-show"
- role="button"
- [ngClass]="{ '-disabled': tab.disableBecause != null, 'selected': currentTab && tab.name === currentTab.name }"
- [attr.title]="tab.disableBecause || tab.title"
- [textContent]="tab.title"
- (click)="switchTo(tab.name)"
- href
+ class="op-tab-row--link"
+ role="button"
+ [ngClass]="{ 'op-tab-row--link_selected': currentTab && tab.name === currentTab.name, 'op-tab-row--link_disabled': tab.disableBecause != null }"
+ [attr.title]="tab.disableBecause || tab.title"
+ [textContent]="tab.title"
+ (click)="switchTo(tab.name)"
+ href
></a>
</li>
</ul>
@@ -29,13 +31,17 @@
</div>
<div class="op-modal--footer">
- <button class="button -highlight"
- [textContent]="text.applyButton"
- (click)="saveChanges()">
+ <button
+ class="button -highlight"
+ [textContent]="text.applyButton"
+ (click)="saveChanges()"
+ >
</button>
- <button class="button"
- [textContent]="text.cancelButton"
- (click)="closeMe($event)">
+ <button
+ class="button"
+ [textContent]="text.cancelButton"
+ (click)="closeMe($event)"
+ >
</button>
</div>
</div>
diff --git a/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.ts b/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.ts
index 8251a5a02ae..7676dcd5dd8 100644
--- a/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.ts
+++ b/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.modal.ts
@@ -73,7 +73,7 @@ export class BoardConfigurationModal extends OpModalComponent implements OnInit,
);
setTimeout(() => {
- const initialTab = this.availableTabs[0].name;
+ const initialTab = this.availableTabs[0];
this.switchTo(initialTab);
});
}
@@ -90,8 +90,8 @@ export class BoardConfigurationModal extends OpModalComponent implements OnInit,
return this.tabPortalHost.currentTab;
}
- public switchTo(name:string) {
- this.tabPortalHost.switchTo(name);
+ public switchTo(tab:TabInterface) {
+ this.tabPortalHost.switchTo(tab);
}
public saveChanges():void {
diff --git a/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.service.ts b/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.service.ts
index 3efa2d2bcff..87e3d71fc2a 100644
--- a/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.service.ts
+++ b/frontend/src/app/modules/boards/board/configuration-modal/board-configuration.service.ts
@@ -8,8 +8,8 @@ export class BoardConfigurationService {
protected _tabs:TabInterface[] = [
{
- name: 'highlighting',
- title: this.I18n.t('js.work_packages.table_configuration.highlighting'),
+ id: 'highlighting',
+ name: this.I18n.t('js.work_packages.table_configuration.highlighting'),
componentClass: BoardHighlightingTabComponent,
}
];
diff --git a/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts b/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts
index 85b41a0a4c6..cd130692889 100644
--- a/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts
+++ b/frontend/src/app/modules/calendar/wp-calendar/wp-calendar.component.ts
@@ -106,7 +106,10 @@ export class WorkPackagesCalendarController extends UntilDestroyedMixin implemen
ngOnInit() {
this.resizeSubject
- .pipe(debounceTime(50))
+ .pipe(
+ this.untilDestroyed(),
+ debounceTime(50)
+ )
.subscribe(() => {
this.ucCalendar.getApi().updateSize();
});
diff --git a/frontend/src/app/modules/common/back-routing/back-routing.service.ts b/frontend/src/app/modules/common/back-routing/back-routing.service.ts
index 9f86ef7ad1a..e76f80cfd91 100644
--- a/frontend/src/app/modules/common/back-routing/back-routing.service.ts
+++ b/frontend/src/app/modules/common/back-routing/back-routing.service.ts
@@ -56,7 +56,9 @@ export class BackRoutingService {
if (preferListOverSplit) {
this.goToOtherState(baseRoute, this.backRoute.params);
} else {
- this.goToOtherState(baseRoute + this.keepTab.currentDetailsSubState, this.backRoute.params);
+ const state = baseRoute + '.details.tabs';
+ const params = { ...this.backRoute.params, tabIdentifier: this.keepTab.currentDetailsTab };
+ this.goToOtherState(state, params);
}
}
diff --git a/frontend/src/app/modules/common/openproject-common.module.ts b/frontend/src/app/modules/common/openproject-common.module.ts
index 482f0f0a217..aa55cc97ff3 100644
--- a/frontend/src/app/modules/common/openproject-common.module.ts
+++ b/frontend/src/app/modules/common/openproject-common.module.ts
@@ -61,8 +61,6 @@ import {UploadProgressComponent} from './notifications/upload-progress.component
import {ResizerComponent} from './resizer/resizer.component';
import {CollapsibleSectionComponent} from './collapsible-section/collapsible-section.component';
import {NoResultsComponent} from './no-results/no-results.component';
-import {ScrollableTabsComponent} from './tabs/scrollable-tabs/scrollable-tabs.component';
-import {ContentTabsComponent} from './tabs/content-tabs/content-tabs.component';
import {EditableToolbarTitleComponent} from './editable-toolbar-title/editable-toolbar-title.component';
import {PersistentToggleComponent} from './persistent-toggle/persistent-toggle.component';
import {AddSectionDropdownComponent} from './hide-section/add-section-dropdown/add-section-dropdown.component';
@@ -169,8 +167,6 @@ export function bootstrapModule(injector:Injector) {
NoResultsComponent,
- ScrollableTabsComponent,
-
EditableToolbarTitleComponent,
// Enterprise Edition
@@ -218,9 +214,6 @@ export function bootstrapModule(injector:Injector) {
NoResultsComponent,
- ScrollableTabsComponent,
- ContentTabsComponent,
-
EditableToolbarTitleComponent,
PersistentToggleComponent,
diff --git a/frontend/src/app/modules/common/tabs/content-tabs/content-tabs.component.sass b/frontend/src/app/modules/common/tabs/content-tabs/content-tabs.component.sass
new file mode 100644
index 00000000000..64bd5def44e
--- /dev/null
+++ b/frontend/src/app/modules/common/tabs/content-tabs/content-tabs.component.sass
@@ -0,0 +1,3 @@
+content-tabs
+ min-height: 73px
+ display: block
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/tabs/content-tabs/content-tabs.component.ts b/frontend/src/app/modules/common/tabs/content-tabs/content-tabs.component.ts
index e332a738fd2..96a8b47abed 100644
--- a/frontend/src/app/modules/common/tabs/content-tabs/content-tabs.component.ts
+++ b/frontend/src/app/modules/common/tabs/content-tabs/content-tabs.component.ts
@@ -29,46 +29,44 @@
import {
Component,
ElementRef,
- ChangeDetectionStrategy
+ ChangeDetectionStrategy, ChangeDetectorRef,
} from '@angular/core';
import { GonService } from "core-app/modules/common/gon/gon.service";
import { StateService } from '@uirouter/core';
import { I18nService } from "core-app/modules/common/i18n/i18n.service";
import { ScrollableTabsComponent } from "core-app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component";
+import { TabDefinition } from "core-app/modules/common/tabs/tab.interface";
export const contentTabsSelector = 'content-tabs';
-interface GonTab {
- name:string;
+interface GonTab extends TabDefinition {
partial:string;
- path:string;
label:string;
}
@Component({
- selector: 'content-tabs',
+ selector: 'op-content-tabs',
templateUrl: '../scrollable-tabs/scrollable-tabs.component.html',
+ styleUrls: ['./content-tabs.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ContentTabsComponent extends ScrollableTabsComponent {
- public gonTabs:GonTab[];
- public currentTab:GonTab;
-
public classes:string[] = ['content--tabs', 'scrollable-tabs'];
constructor(readonly elementRef:ElementRef,
readonly $state:StateService,
readonly gon:GonService,
+ cdRef:ChangeDetectorRef,
readonly I18n:I18nService) {
- super();
+ super(cdRef);
- this.gonTabs = JSON.parse((this.gon.get('contentTabs') as any).tabs);
- this.currentTab = JSON.parse((this.gon.get('contentTabs') as any).selected);
+ const gonTabs = JSON.parse((this.gon.get('contentTabs') as any).tabs);
+ const currentTab = JSON.parse((this.gon.get('contentTabs') as any).selected);
// parse tabs from backend and map them to scrollable tabs structure
- this.tabs = this.gonTabs.map((tab:GonTab) => {
+ this.tabs = gonTabs.map((tab:GonTab) => {
return {
id: tab.name,
name: this.I18n.t('js.' + tab.label, { defaultValue: tab.label }),
@@ -77,6 +75,6 @@ export class ContentTabsComponent extends ScrollableTabsComponent {
});
// highlight current tab
- this.currentTabId = this.currentTab.name;
+ this.currentTabId = currentTab.name;
}
}
diff --git a/frontend/src/app/modules/common/tabs/openproject-tabs.module.ts b/frontend/src/app/modules/common/tabs/openproject-tabs.module.ts
new file mode 100644
index 00000000000..dbaf3ae8556
--- /dev/null
+++ b/frontend/src/app/modules/common/tabs/openproject-tabs.module.ts
@@ -0,0 +1,56 @@
+//-- copyright
+// OpenProject is an open source project management software.
+// Copyright (C) 2012-2021 the OpenProject GmbH
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License version 3.
+//
+// OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
+// Copyright (C) 2006-2013 Jean-Philippe Lang
+// Copyright (C) 2010-2013 the ChiliProject Team
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+// See docs/COPYRIGHT.rdoc for more details.
+//++
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { IconModule } from 'core-app/modules/icon/icon.module';
+import { AttributeHelpTextModule } from 'core-app/modules/attribute-help-texts/attribute-help-text.module';
+import { FocusModule } from "core-app/modules/focus/focus.module";
+import { ScrollableTabsComponent } from "core-app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component";
+import { ContentTabsComponent } from "core-app/modules/common/tabs/content-tabs/content-tabs.component";
+import { TabCountComponent } from "core-app/modules/common/tabs/tab-badges/tab-count.component";
+import { UIRouterModule } from "@uirouter/angular";
+
+@NgModule({
+ imports: [
+ CommonModule,
+ FocusModule,
+ IconModule,
+ AttributeHelpTextModule,
+ UIRouterModule,
+ ],
+ exports: [
+ ScrollableTabsComponent,
+ ],
+ declarations: [
+ ScrollableTabsComponent,
+ ContentTabsComponent,
+ TabCountComponent,
+ ],
+})
+export class OpenprojectTabsModule {
+}
diff --git a/frontend/src/app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component.html b/frontend/src/app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component.html
index d665783bce0..14d266e6700 100644
--- a/frontend/src/app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component.html
+++ b/frontend/src/app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component.html
@@ -1,19 +1,64 @@
-<div #scrollContainer [ngClass]="classes">
- <ul #scrollPane class="tabrow" (scroll)="onScroll($event)">
- <li *ngFor="let tab of tabs"
- [class.selected]="tab.id === currentTabId"
- [attr.tab-id]="tab.id">
- <a [href]="tab.path" (click)="clickTab(tab.id)" [textContent]="tab.name"></a>
- </li>
- </ul>
- <div #scrollLeftBtn [hidden]="hideLeftButton"
- class="scrollable-tabs--button -left"
- (click)="scrollLeft()">
- <span class="icon-arrow-left2"></span>
- </div>
- <div #scrollRightBtn [hidden]="hideRightButton"
- class="scrollable-tabs--button -right"
- (click)="scrollRight()">
- <span class="icon-arrow-right2"></span>
+<div class="op-scrollable-tabs" [ngClass]="classes">
+ <div
+ #scrollContainer
+ class="op-scrollable-tabs--tab-container"
+ >
+ <ul #scrollPane class="op-tab-row" (scroll)="onScroll($event)">
+ <li
+ *ngFor="let tab of tabs; trackBy:trackById"
+ class="op-tab-row--tab"
+ [attr.data-tab-id]="tab.id"
+ [attr.data-qa-tab-id]="tab.id"
+ [attr.data-qa-tab-selected]="tab.id === currentTabId || undefined"
+ [attr.data-qa-tab-disabled]="tab.disable || undefined"
+ >
+ <a
+ *ngIf="!tab.route"
+ [href]="tab.path"
+ class="op-tab-row--link"
+ [class.op-tab-row--link_selected]="tab.id === currentTabId"
+ [class.op-tab-row--link_disabled]="tab.disable !== undefined"
+ (click)="clickTab(tab, $event)"
+ [attr.title]="tabTitle(tab)"
+ [textContent]="tab.name"
+ >
+ </a>
+ <a
+ *ngIf="tab.route"
+ [uiSref]="tab.route"
+ [uiParams]="tab.routeParams"
+ class="op-tab-row--link"
+ uiSrefActive="op-tab-row--link_selected"
+ (click)="clickTab(tab, $event)"
+ [attr.title]="tabTitle(tab)"
+ [class.op-tab-row--link_disabled]="tab.disable !== undefined"
+ href=""
+ role="button"
+ >
+ <span [textContent]="tab.name"></span>
+ <op-tab-count
+ *ngIf="tab.counter"
+ [counter]="tab.counter"
+ ></op-tab-count>
+ </a>
+ </li>
+ </ul>
+ <div
+ #scrollLeftBtn [hidden]="hideLeftButton"
+ class="op-scrollable-tabs--button op-scrollable-tabs--button_left"
+ (click)="scrollLeft()"
+ >
+ <span class="icon-arrow-left2"></span>
+ </div>
+ <div
+ #scrollRightBtn [hidden]="hideRightButton"
+ class="op-scrollable-tabs--button op-scrollable-tabs--button_right"
+ (click)="scrollRight()"
+ >
+ <span class="icon-arrow-right2"></span>
+ </div>
</div>
+ <ul class="op-scrollable-tabs--actions">
+ <ng-content select="[slot=actions]"></ng-content>
+ </ul>
</div>
diff --git a/frontend/src/app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component.ts b/frontend/src/app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component.ts
index 94c501c80e3..8154af0e84f 100644
--- a/frontend/src/app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component.ts
+++ b/frontend/src/app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component.ts
@@ -1,61 +1,101 @@
-import { AfterViewInit, Component, ElementRef, ViewChild } from "@angular/core";
-
-export interface Tab {
- id:string;
- name:string;
- path?:string;
-}
+import {
+ AfterViewInit,
+ ChangeDetectionStrategy, ChangeDetectorRef,
+ Component,
+ ElementRef,
+ EventEmitter,
+ Input, OnChanges,
+ Output, SimpleChanges,
+ ViewChild,
+ ViewEncapsulation,
+} from "@angular/core";
+import { TabDefinition } from "core-app/modules/common/tabs/tab.interface";
+import { AngularTrackingHelpers } from "core-components/angular/tracking-functions";
@Component({
- templateUrl: 'scrollable-tabs.component.html'
+ templateUrl: 'scrollable-tabs.component.html',
+ selector: 'op-scrollable-tabs',
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
-export class ScrollableTabsComponent implements AfterViewInit {
+export class ScrollableTabsComponent implements AfterViewInit, OnChanges {
@ViewChild('scrollContainer', { static: true }) scrollContainer:ElementRef;
@ViewChild('scrollPane', { static: true }) scrollPane:ElementRef;
@ViewChild('scrollRightBtn', { static: true }) scrollRightBtn:ElementRef;
@ViewChild('scrollLeftBtn', { static: true }) scrollLeftBtn:ElementRef;
- public currentTabId = '';
- public tabs:Tab[] = [];
- public classes:string[] = ['scrollable-tabs'];
- public hideLeftButton = true;
- public hideRightButton = true;
+ @Input() public currentTabId:string|null = null;
+ @Input() public tabs:TabDefinition[] = [];
+ @Input() public classes:string[] = [];
+ @Input() public hideLeftButton = true;
+ @Input() public hideRightButton = true;
+
+ @Output() public tabSelected = new EventEmitter<TabDefinition>();
+
+ trackById = AngularTrackingHelpers.trackByProperty('id');
private container:Element;
private pane:Element;
- ngAfterViewInit() {
+ constructor(private cdRef:ChangeDetectorRef) {
+ }
+
+ ngAfterViewInit():void {
this.container = this.scrollContainer.nativeElement;
this.pane = this.scrollPane.nativeElement;
+ this.updateScrollableArea();
+ }
+
+ ngOnChanges(changes:SimpleChanges):void {
+ if (this.pane) {
+ this.updateScrollableArea();
+ }
+ }
+
+ private updateScrollableArea() {
this.determineScrollButtonVisibility();
- this.scrollIntoVisibleArea(this.currentTabId);
+ if (this.currentTabId != null) {
+ this.scrollIntoVisibleArea(this.currentTabId);
+ }
}
- public clickTab(tab:string) {
- this.currentTabId = tab;
+ public clickTab(tab:TabDefinition, event:Event):void {
+ this.currentTabId = tab.id;
+ this.tabSelected.emit(tab);
+
+ // If the tab does not provide its own link,
+ // avoid propagation
+ if (!tab.path) {
+ event.preventDefault();
+ }
}
- public onScroll(event:any) {
+ public onScroll(event:any):void {
this.determineScrollButtonVisibility();
}
private determineScrollButtonVisibility() {
this.hideLeftButton = (this.pane.scrollLeft <= 0);
this.hideRightButton = (this.pane.scrollWidth - this.pane.scrollLeft <= this.container.clientWidth);
+
+ this.cdRef.detectChanges();
}
- public scrollRight() {
+ public scrollRight():void {
this.pane.scrollLeft += this.container.clientWidth;
}
- public scrollLeft() {
+ public scrollLeft():void {
this.pane.scrollLeft -= this.container.clientWidth;
}
+ public tabTitle(tab:TabDefinition):string {
+ return (typeof tab.disable === 'string') ? tab.disable : tab.name;
+ }
+
private scrollIntoVisibleArea(tabId:string) {
- const tab:JQuery<Element> = jQuery(this.pane).find(`[tab-id=${tabId}]`);
+ const tab:JQuery<Element> = jQuery(this.pane).find(`[data-tab-id=${tabId}]`);
const position:JQueryCoordinates = tab.position();
const tabRightBorderAt:number = position.left + Number(tab.outerWidth());
diff --git a/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.html b/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.html
new file mode 100644
index 00000000000..12c743b2c49
--- /dev/null
+++ b/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.html
@@ -0,0 +1,8 @@
+<ng-container *ngIf="(counter$ | async) as count">
+ <span
+ class="op-tab-count"
+ *ngIf="count > 0"
+ [textContent]="count"
+ >
+ </span>
+</ng-container>
diff --git a/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.sass b/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.sass
new file mode 100644
index 00000000000..e0a6fd4e291
--- /dev/null
+++ b/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.sass
@@ -0,0 +1,12 @@
+.op-tab-count
+ margin-left: 5px
+ border-radius: 0.5rem
+ min-width: 1rem
+ display: inline-block
+ font-size: 0.7rem
+ line-height: 1rem
+ min-height: 1rem
+ vertical-align: 0.1rem
+ padding: 0 0.15rem 0 0.15rem
+ background: var(--light-gray)
+ font-weight: bold
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.ts b/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.ts
new file mode 100644
index 00000000000..d68d433bd6c
--- /dev/null
+++ b/frontend/src/app/modules/common/tabs/tab-badges/tab-count.component.ts
@@ -0,0 +1,12 @@
+import { ChangeDetectionStrategy, Component, Input, OnChanges, OnInit } from "@angular/core";
+import { Observable } from "rxjs";
+
+@Component({
+ selector: 'op-tab-count',
+ templateUrl: './tab-count.component.html',
+ styleUrls: ['./tab-count.component.sass'],
+ changeDetection: ChangeDetectionStrategy.OnPush,
+})
+export class TabCountComponent {
+ @Input('counter') counter$:Observable<number>;
+}
\ No newline at end of file
diff --git a/frontend/src/app/modules/common/tabs/tab.interface.ts b/frontend/src/app/modules/common/tabs/tab.interface.ts
new file mode 100644
index 00000000000..b34e6e9c877
--- /dev/null
+++ b/frontend/src/app/modules/common/tabs/tab.interface.ts
@@ -0,0 +1,18 @@
+import { Observable } from "rxjs";
+
+export interface TabDefinition {
+ /** Internal identifier of the tab */
+ id:string;
+ /** Human readable name */
+ name:string;
+ /** Manual URL to link to if set */
+ path?:string;
+ /** UI router route to use uiSref with */
+ route?:string;
+ /** UI router params to use uiParams with */
+ routeParams?:unknown;
+ /** Show a tab count with this observable's result */
+ counter?:Observable<number>;
+ /** Disable the tab, optionally with an explanatory title */
+ disable?:string|true;
+}
\ No newline at end of file
diff --git a/frontend/src/app/modules/global_search/tabs/global-search-tabs.component.ts b/frontend/src/app/modules/global_search/tabs/global-search-tabs.component.ts
index 0bdd5ee79d4..c2166f8df03 100644
--- a/frontend/src/app/modules/global_search/tabs/global-search-tabs.component.ts
+++ b/frontend/src/app/modules/global_search/tabs/global-search-tabs.component.ts
@@ -26,10 +26,11 @@
// See docs/COPYRIGHT.rdoc for more details.
//++
-import { Component, OnDestroy } from '@angular/core';
+import { ChangeDetectorRef, Component, OnDestroy } from '@angular/core';
import { GlobalSearchService } from "core-app/modules/global_search/services/global-search.service";
import { Subscription } from "rxjs";
import { ScrollableTabsComponent } from "core-app/modules/common/tabs/scrollable-tabs/scrollable-tabs.component";
+import { TabDefinition } from "core-app/modules/common/tabs/tab.interface";
export const globalSearchTabsSelector = 'global-search-tabs';
@@ -44,8 +45,9 @@ export class GlobalSearchTabsComponent extends ScrollableTabsComponent implement
public classes:string[] = ['global-search--tabs', 'scrollable-tabs'];
- constructor(readonly globalSearchService:GlobalSearchService) {
- super();
+ constructor(readonly globalSearchService:GlobalSearchService,
+ cdRef:ChangeDetectorRef) {
+ super(cdRef);
}
ngOnInit() {
@@ -63,10 +65,10 @@ export class GlobalSearchTabsComponent extends ScrollableTabsComponent implement
});
}
- public clickTab(tab:string) {
- super.clickTab(tab);
+ public clickTab(tab:TabDefinition, event:Event) {
+ super.clickTab(tab, event);
- this.globalSearchService.currentTab = tab;
+ this.globalSearchService.currentTab = tab.id;
this.globalSearchService.submitSearch();
}
diff --git a/frontend/src/app/modules/plugins/hook-service.spec.ts b/frontend/src/app/modules/plugins/hook-service.spec.ts
index 725873741f9..6027af8a036 100644
--- a/frontend/src/app/modules/plugins/hook-service.spec.ts
+++ b/frontend/src/app/modules/plugins/hook-service.spec.ts
@@ -28,10 +28,7 @@
/*jshint expr: true*/
-import { Component, ChangeDetectionStrategy } from '@angular/core';
import { HookService } from 'core-app/modules/plugins/hook-service';
-import { WorkPackageResource } from 'core-app/modules/hal/resources/work-package-resource';
-import { Tab, TabComponent } from 'core-app/components/wp-tabs/components/wp-tab-wrapper/tab';
describe('HookService', function() {
let service:HookService = new HookService();
@@ -159,32 +156,4 @@ describe('HookService', function() {
shouldBehaveLikeResultWithElements(validId, 2);
});
});
-
- describe('registerWorkPackageTab/getWorkPackageTabs', function() {
- @Component({
- selector: 'my-tab-component',
- template: '',
- changeDetection: ChangeDetectionStrategy.OnPush,
- })
- class MyTestTabComponent implements TabComponent {
- workPackage: WorkPackageResource;
- }
-
- const tab1 = new Tab(MyTestTabComponent, 'GitHub', 'github', () => true);
- const tab2 = new Tab(MyTestTabComponent, 'GitLab', 'gitlab', () => true);
- const tab3 = new Tab(MyTestTabComponent, 'Bitbucket', 'bitbucket', () => true);
-
- it('returns all registered tabs', function() {
- expect(service.getWorkPackageTabs()).toEqual([]);
-
- service.registerWorkPackageTab(tab1);
- expect(service.getWorkPackageTabs()).toEqual([tab1]);
-
- service.registerWorkPackageTab(tab2);
- expect(service.getWorkPackageTabs()).toEqual([tab1, tab2]);
-
- service.registerWorkPackageTab(tab3);
- expect(service.getWorkPackageTabs()).toEqual([tab1, tab2, tab3]);
- });
- });
});
diff --git a/frontend/src/app/modules/plugins/hook-service.ts b/frontend/src/app/modules/plugins/hook-service.ts
index 48e2e7751a3..dee85c9885a 100644
--- a/frontend/src/app/modules/plugins/hook-service.ts
+++ b/frontend/src/app/modules/plugins/hook-service.ts
@@ -27,13 +27,12 @@
//++
import { Injectable } from '@angular/core';
-import { Tab } from 'core-app/components/wp-tabs/components/wp-tab-wrapper/tab';
@Injectable({
providedIn: 'root'
})
export class HookService {
- private hooks:{[hook:string]:Function[]} = {};
+ private hooks:{ [hook:string]:Function[] } = {};
public register(id:string, callback:Function) {
if (!callback) {
@@ -62,12 +61,4 @@ export class HookService {
return results;
}
-
- public registerWorkPackageTab(tab:Tab) {
- this.register('workPackageTabs', () => tab);
- }
-
- public getWorkPackageTabs():Tab[] {
- return(this.call('workPackageTabs'));
- }
}
diff --git a/frontend/src/app/modules/work-package-graphs/configuration-modal/wp-graph-configuration.modal.ts b/frontend/src/app/modules/work-package-graphs/configuration-modal/wp-graph-configuration.modal.ts
index dcfc1240ef7..0d7076a69fd 100644
--- a/frontend/src/app/modules/work-package-graphs/configuration-modal/wp-graph-configuration.modal.ts
+++ b/frontend/src/app/modules/work-package-graphs/configuration-modal/wp-graph-configuration.modal.ts
@@ -1,5 +1,6 @@
import {
ApplicationRef,
+ ChangeDetectionStrategy,
ChangeDetectorRef,
Component,
ComponentFactoryResolver,
@@ -33,6 +34,7 @@ export const WpTableConfigurationModalPrependToken = new InjectionToken<Componen
@Component({
templateUrl: '../../../components/wp-table/configuration-modal/wp-table-configuration.modal.html',
+ changeDetection: ChangeDetectionStrategy.OnPush,
})
export class WpGraphConfigurationModalComponent extends OpModalComponent implements OnInit, OnDestroy {
@@ -74,7 +76,7 @@ export class WpGraphConfigurationModalComponent extends OpModalComponent impleme
super(locals, cdRef, elementRef);
}
- ngOnInit() {
+ ngOnInit():void {
this.$element = jQuery(this.elementRef.nativeElement);
this.loadingIndicator.indicator('modal').promise = this.graphConfiguration.loadForms()
@@ -87,12 +89,14 @@ export class WpGraphConfigurationModalComponent extends OpModalComponent impleme
this.injector
);
- const initialTab = this.locals['initialTab'] || this.availableTabs[0].name;
- this.switchTo(initialTab);
+ const initialTabName = this.locals['initialTab'];
+ const initialTab = this.availableTabs.find(el => el.id === initialTabName);
+ this.cdRef.markForCheck();
+ this.switchTo(initialTab || this.availableTabs[0]);
});
}
- ngOnDestroy() {
+ ngOnDestroy():void {
this.tabPortalHost.dispose();
}
@@ -104,8 +108,8 @@ export class WpGraphConfigurationModalComponent extends OpModalComponent impleme
return this.tabPortalHost.currentTab;
}
- public switchTo(name:string) {
- this.tabPortalHost.switchTo(name);
+ public switchTo(tab:TabInterface):void {
+ this.tabPortalHost.switchTo(tab);
}
public saveChanges():void {
diff --git a/frontend/src/app/modules/work-package-graphs/configuration/wp-graph-configuration.service.ts b/frontend/src/app/modules/work-package-graphs/configuration/wp-graph-configuration.service.ts
index 0eaaf5e1775..04c0d0154f8 100644
--- a/frontend/src/app/modules/work-package-graphs/configuration/wp-graph-configuration.service.ts
+++ b/frontend/src/app/modules/work-package-graphs/configuration/wp-graph-configuration.service.ts
@@ -4,7 +4,7 @@ import { QueryResource } from "core-app/modules/hal/resources/query-resource";
import { TabInterface } from "core-components/wp-table/configuration-modal/tab-portal-outlet";
import { Injectable } from '@angular/core';
import { WpGraphConfigurationFiltersTab } from "core-app/modules/work-package-graphs/configuration-modal/tabs/filters-tab.component";
-import { ChartType } from 'chart.js';
+import { ChartOptions, ChartType } from 'chart.js';
import { QueryFormResource } from "core-app/modules/hal/resources/query-form-resource";
import {
WpGraphConfiguration,
@@ -13,6 +13,8 @@ import {
import { CurrentProjectService } from "core-components/projects/current-project.service";
import { WorkPackageNotificationService } from "core-app/modules/work_packages/notifications/work-package-notification.service";
import { APIV3Service } from "core-app/modules/apiv3/api-v3.service";
+import { FormResource } from "core-app/modules/hal/resources/form-resource";
+import { WorkPackageEmbeddedGraphDataset } from "core-app/modules/work-package-graphs/embedded/wp-embedded-graph.component";
@Injectable()
export class WpGraphConfigurationService {
@@ -27,13 +29,13 @@ export class WpGraphConfigurationService {
readonly currentProject:CurrentProjectService) {
}
- public persistAndReload() {
+ public persistAndReload():Promise<unknown> {
return this
.persistChanges()
.then(() => this.reloadQueries());
}
- public persistChanges() {
+ public persistChanges():Promise<unknown> {
const promises = this.queries.map(query => {
return this.saveQuery(query);
});
@@ -41,7 +43,7 @@ export class WpGraphConfigurationService {
return Promise.all(promises);
}
- public get datasets() {
+ public get datasets():WorkPackageEmbeddedGraphDataset[] {
return this.queries.map(query => {
return {
groups: query.results.groups,
@@ -51,13 +53,13 @@ export class WpGraphConfigurationService {
});
}
- public reloadQueries() {
+ public reloadQueries():Promise<unknown> {
this.configuration.queries.length = 0;
return this.loadQueries();
}
- public ensureQueryAndLoad() {
+ public ensureQueryAndLoad():Promise<unknown> {
if (this.queryParams.length === 0) {
return this.createInitial()
.then((query) => {
@@ -138,7 +140,7 @@ export class WpGraphConfigurationService {
this._formsPromise = null;
}
- public async formFor(query:QueryResource) {
+ public async formFor(query:QueryResource):Promise<QueryFormResource> {
return this
.loadForms()
.then(() => {
@@ -146,19 +148,19 @@ export class WpGraphConfigurationService {
});
}
- public get tabs() {
+ public get tabs():TabInterface[] {
const tabs:TabInterface[] = [
{
- name: 'graph-settings',
- title: this.I18n.t('js.chart.tabs.graph_settings'),
+ id: 'graph-settings',
+ name: this.I18n.t('js.chart.tabs.graph_settings'),
componentClass: WpGraphConfigurationSettingsTab,
}
];
const queryTabs = this.configuration.queries.map((query) => {
return {
- name: query.id as string,
- title: this.I18n.t('js.work_packages.query.filters'),
+ id: query.id as string,
+ name: this.I18n.t('js.work_packages.query.filters'),
componentClass: WpGraphConfigurationFiltersTab
};
});
@@ -166,7 +168,7 @@ export class WpGraphConfigurationService {
return tabs.concat(queryTabs);
}
- public loadForms() {
+ public loadForms():Promise<unknown> {
if (!this._formsPromise) {
const formPromises = this.configuration.queries.map((query) => {
return this
@@ -187,7 +189,7 @@ export class WpGraphConfigurationService {
return this._formsPromise;
}
- public get chartType() {
+ public get chartType():ChartType {
return this._configuration.chartType;
}
@@ -195,15 +197,15 @@ export class WpGraphConfigurationService {
this._configuration.chartType = type;
}
- public get queries() {
+ public get queries():QueryResource[] {
return this._configuration.queries;
}
- public get chartOptions() {
+ public get chartOptions():ChartOptions {
return this._configuration.chartOptions;
}
- public get queryParams() {
+ public get queryParams():WpGraphQueryParams[] {
return this._configuration.queryParams;
}
}
diff --git a/frontend/src/app/modules/work-package-graphs/openproject-work-package-graphs.module.ts b/frontend/src/app/modules/work-package-graphs/openproject-work-package-graphs.module.ts
index 00219b83705..b33c4a52545 100644
--- a/frontend/src/app/modules/work-package-graphs/openproject-work-package-graphs.module.ts
+++ b/frontend/src/app/modules/work-package-graphs/openproject-work-package-graphs.module.ts
@@ -39,6 +39,7 @@ import { WorkPackageEmbeddedGraphComponent } from "core-app/modules/work-package
import { WorkPackageOverviewGraphComponent } from "core-app/modules/work-package-graphs/overview/wp-overview-graph.component";
import { ChartsModule } from 'ng2-charts';
import * as ChartDataLabels from 'chartjs-plugin-datalabels';
+import { OpenprojectTabsModule } from "core-app/modules/common/tabs/openproject-tabs.module";
@NgModule({
imports: [
@@ -47,6 +48,7 @@ import * as ChartDataLabels from 'chartjs-plugin-datalabels';
OpenprojectModalModule,
OpenprojectWorkPackagesModule,
+ OpenprojectTabsModule,
ChartsModule,
],
diff --git a/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts b/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
index 290f2f328ee..fa2c0c7a185 100644
--- a/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
+++ b/frontend/src/app/modules/work_packages/openproject-work-packages.module.ts
@@ -69,8 +69,6 @@ import { WorkPackageActivityTabComponent } from 'core-components/wp-single-view-
import { OpenprojectAttachmentsModule } from 'core-app/modules/attachments/openproject-attachments.module';
import { WpCustomActionComponent } from 'core-components/wp-custom-actions/wp-custom-actions/wp-custom-action.component';
import { WpCustomActionsComponent } from 'core-components/wp-custom-actions/wp-custom-actions.component';
-import { WorkPackageRelationsCountComponent } from 'core-components/work-packages/wp-relations-count/wp-relations-count.component';
-import { WorkPackageWatchersCountComponent } from 'core-components/work-packages/wp-relations-count/wp-watchers-count.component';
import { WorkPackageBreadcrumbComponent } from 'core-components/work-packages/wp-breadcrumb/wp-breadcrumb.component';
import { WorkPackageSplitViewToolbarComponent } from 'core-components/wp-details/wp-details-toolbar.component';
import { WorkPackageWatcherButtonComponent } from 'core-components/work-packages/wp-watcher-button/wp-watcher-button.component';
@@ -172,6 +170,7 @@ import { WorkPackageGroupToggleDropdownMenuDirective } from "core-components/op-
import { OpenprojectAutocompleterModule } from "core-app/modules/autocompleter/openproject-autocompleter.module";
import { OpWpTabsModule } from "core-components/wp-tabs/wp-tabs.module";
import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-controls/edit-field-controls.module";
+import { OpenprojectTabsModule } from "core-app/modules/common/tabs/openproject-tabs.module";
@NgModule({
@@ -196,6 +195,7 @@ import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-cont
OpWpTabsModule,
EditFieldControlsModule,
+ OpenprojectTabsModule,
],
providers: [
// Notification service
@@ -351,8 +351,6 @@ import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-cont
// Split view
WorkPackageDetailsViewButtonComponent,
WorkPackageSplitViewComponent,
- WorkPackageRelationsCountComponent,
- WorkPackageWatchersCountComponent,
WorkPackageBreadcrumbComponent,
WorkPackageSplitViewToolbarComponent,
WorkPackageWatcherButtonComponent,
@@ -412,8 +410,6 @@ import { EditFieldControlsModule } from "core-app/modules/fields/edit/field-cont
WorkPackageBreadcrumbParentComponent,
WorkPackageSplitViewToolbarComponent,
WorkPackageSubjectComponent,
- WorkPackageWatchersCountComponent,
- WorkPackageRelationsCountComponent,
WorkPackagesGridComponent,
// Modals
diff --git a/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts b/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts
index 5deb565326d..f1c0085bfff 100644
--- a/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts
+++ b/frontend/src/app/modules/work_packages/routing/split-view-routes.template.ts
@@ -71,7 +71,13 @@ export function makeSplitViewRoutes(baseRoute:string,
{
name: routeName + '.details',
url: '/details/{workPackageId:[0-9]+}',
- redirectTo: routeName + '.details.overview',
+ redirectTo: (trans) => {
+ const params = trans.params('to');
+ return {
+ state: routeName + '.details.tabs',
+ params: { ...params, tabIdentifier: 'overview' }
+ };
+ },
reloadOnSearch: false,
data: {
bodyClasses: 'router--work-packages-partitioned-split-view-details',
@@ -85,49 +91,9 @@ export function makeSplitViewRoutes(baseRoute:string,
// https://ui-router.github.io/guide/views#relative-parent-state
views,
},
- {
- name: routeName + '.details.overview',
- url: '/overview',
- component: WorkPackageOverviewTabComponent,
- data: {
- baseRoute: baseRoute,
- menuItem: menuItemClass,
- parent: routeName + '.details'
- }
- },
- {
- name: routeName + '.details.activity',
- url: '/activity',
- component: WorkPackageActivityTabComponent,
- data: {
- baseRoute: baseRoute,
- menuItem: menuItemClass,
- parent: routeName + '.details'
- }
- },
- {
- name: routeName + '.details.relations',
- url: '/relations',
- component: WorkPackageRelationsTabComponent,
- data: {
- baseRoute: baseRoute,
- menuItem: menuItemClass,
- parent: routeName + '.details'
- }
- },
- {
- name: routeName + '.details.watchers',
- url: '/watchers',
- component: WorkPackageWatchersTabComponent,
- data: {
- baseRoute: baseRoute,
- menuItem: menuItemClass,
- parent: routeName + '.details'
- }
- },
{
name: routeName + '.details.tabs',
- url: '/tabs/:tabIdentifier',
+ url: '/:tabIdentifier',
component: WpTabWrapperComponent,
data: {
baseRoute: baseRoute,
diff --git a/frontend/src/app/modules/work_packages/routing/work-packages-routes.ts b/frontend/src/app/modules/work_packages/routing/work-packages-routes.ts
index 30e3f9c5794..08a67771b3a 100644
--- a/frontend/src/app/modules/work_packages/routing/work-packages-routes.ts
+++ b/frontend/src/app/modules/work_packages/routing/work-packages-routes.ts
@@ -89,7 +89,13 @@ export const WORK_PACKAGES_ROUTES:Ng2StateDeclaration[] = [
name: 'work-packages.show',
url: '/{workPackageId:[0-9]+}',
// Redirect to 'activity' by default.
- redirectTo: 'work-packages.show.activity',
+ redirectTo: (trans) => {
+ const params = trans.params('to');
+ return {
+ state: 'work-packages.show.tabs',
+ params: { ...params, tabIdentifier: 'activity' }
+ };
+ },
component: WorkPackagesFullViewComponent,
data: {
baseRoute: 'work-packages',
@@ -98,45 +104,9 @@ export const WORK_PACKAGES_ROUTES:Ng2StateDeclaration[] = [
menuItem: menuItemClass
}
},
- {
- name: 'work-packages.show.activity',
- url: '/activity',
- component: WorkPackageActivityTabComponent,
- data: {
- parent: 'work-packages.show',
- menuItem: menuItemClass
- }
- },
- {
- name: 'work-packages.show.activity.details',
- url: '/activity/details/#{activity_no:\d+}',
- component: WorkPackageActivityTabComponent,
- data: {
- parent: 'work-packages.show',
- menuItem: menuItemClass
- }
- },
- {
- name: 'work-packages.show.relations',
- url: '/relations',
- component: WorkPackageRelationsTabComponent,
- data: {
- parent: 'work-packages.show',
- menuItem: menuItemClass
- }
- },
- {
- name: 'work-packages.show.watchers',
- url: '/watchers',
- component: WorkPackageWatchersTabComponent,
- data: {
- parent: 'work-packages.show',
- menuItem: menuItemClass
- }
- },
{
name: 'work-packages.show.tabs',
- url: '/tabs/:tabIdentifier',
+ url: "/:tabIdentifier",
component: WpTabWrapperComponent,
data: {
parent: 'work-packages.show',
diff --git a/frontend/src/app/modules/work_packages/routing/wp-full-view/wp-full-view.html b/frontend/src/app/modules/work_packages/routing/wp-full-view/wp-full-view.html
index 2488ae19526..4d149748bf4 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-full-view/wp-full-view.html
+++ b/frontend/src/app/modules/work_packages/routing/wp-full-view/wp-full-view.html
@@ -52,32 +52,7 @@
<div class="work-packages-full-view--split-right work-packages-tab-view--overflow">
<div class="work-packages--panel-inner">
<span class="hidden-for-sighted" tabindex="-1" focus [textContent]="focusAnchorLabel"></span>
- <div id="tabs">
- <ul class="tabrow">
- <!-- The hrefs with empty URLs are necessary for IE10 to focus these links
- properly. Thus, don't remove the hrefs or the empty URLs! -->
- <li uiSref="work-packages.show.activity"
- [uiParams]="{workPackageId: workPackage.id}"
- uiSrefActive="selected">
- <a href="" [textContent]="text.tabs.activity"></a>
- </li>
- <li uiSref="work-packages.show.relations"
- [uiParams]="{workPackageId: workPackage.id}"
- uiSrefActive="selected">
- <a href="" [textContent]="text.tabs.relations"></a>
- <wp-relations-count [wpId]="workPackage.id"></wp-relations-count>
- </li>
- <li *ngIf="canViewWorkPackageWatchers()"
- uiSref="work-packages.show.watchers"
- [uiParams]="{workPackageId: workPackage.id}"
- uiSrefActive="selected">
- <a href="" [textContent]="text.tabs.watchers"></a>
- <wp-watchers-count [wpId]="workPackage.id"></wp-watchers-count>
- </li>
-
- <op-wp-tabs [workPackage]="workPackage" view="full"></op-wp-tabs>
- </ul>
- </div>
+ <op-wp-tabs [workPackage]="workPackage" view="full"></op-wp-tabs>
<div class="tabcontent" ui-view>
</div>
</div>
diff --git a/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.ts b/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.ts
index 0e1b02bb1f8..0901d230edf 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-list-view/wp-list-view.component.ts
@@ -172,17 +172,17 @@ export class WorkPackageListViewComponent extends UntilDestroyedMixin implements
}
}
- openStateLink(event:{ workPackageId:string; requestedState:string }) {
- const selectedTabIdentifier = this.$state?.params?.tabIdentifier;
-
- this.$state.go(
- (this.keepTab as any)[event.requestedState] || event.requestedState,
- {
- workPackageId: event.workPackageId,
- focus: true,
- ...selectedTabIdentifier && {tabIdentifier: selectedTabIdentifier},
- }
- );
+ openStateLink(event:{ workPackageId:string; requestedState:'show'|'split' }) {
+ const params = {
+ workPackageId: event.workPackageId,
+ focus: true,
+ };
+
+ if (event.requestedState === 'split') {
+ this.keepTab.goCurrentDetailsState(params);
+ } else {
+ this.keepTab.goCurrentShowState(params);
+ }
}
/**
diff --git a/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.component.ts b/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.component.ts
index 6a96f7587e3..d644423a7ed 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.component.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.component.ts
@@ -96,15 +96,6 @@ export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase imp
});
}
-
- public close() {
- this.$state.go(this.baseRoute, this.$state.params);
- }
-
- public switchToFullscreen() {
- this.$state.go(this.keepTab.currentShowState, this.$state.params);
- }
-
public get shouldFocus() {
return this.$state.params.focus === true;
}
@@ -116,10 +107,4 @@ export class WorkPackageSplitViewComponent extends WorkPackageSingleViewBase imp
public backToList() {
this.backRouting.goToBaseState();
}
-
- protected initializeTexts() {
- super.initializeTexts();
- this.text.closeDetailsView = this.I18n.t('js.button_close_details');
- this.text.goTofullScreen = this.I18n.t('js.work_packages.message_successful_show_in_fullscreen');
- }
}
diff --git a/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.html b/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.html
index 0d7b04ec792..ec9e9b05ea9 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.html
+++ b/frontend/src/app/modules/work_packages/routing/wp-split-view/wp-split-view.html
@@ -1,50 +1,7 @@
<div class="work-packages--details loading-indicator--location"
data-indicator-name="wpDetails"
*ngIf="workPackage">
- <div id="tabs">
- <ul class="tabrow">
- <!-- The hrefs with empty URLs are necessary for IE10 to focus these links
- properly. Thus, don't remove the hrefs or the empty URLs! -->
- <li uiSref=".overview"
- uiSrefActive="selected">
- <a href="" [textContent]="text.tabs.overview"></a>
- </li>
- <li uiSref=".activity"
- uiSrefActive="selected">
- <a href="" [textContent]="text.tabs.activity"></a>
- </li>
- <li uiSref=".relations"
- uiSrefActive="selected">
- <a href="" [textContent]="text.tabs.relations"></a>
- <wp-relations-count [wpId]="workPackage.id"></wp-relations-count>
- </li>
- <li *ngIf="canViewWorkPackageWatchers()"
- uiSref=".watchers"
- uiSrefActive="selected">
- <a href="" [textContent]="text.tabs.watchers"></a>
- <wp-watchers-count [wpId]="workPackage.id"></wp-watchers-count>
- </li>
-
- <op-wp-tabs [workPackage]="workPackage" view="split"></op-wp-tabs>
-
- <li class="tab-icon">
- <accessible-by-keyboard (execute)="switchToFullscreen()"
- [linkAriaLabel]="text.goTofullScreen"
- [linkTitle]="text.goTofullScreen"
- linkClass="work-packages--details-fullscreen-icon"
- spanClass="icon-context icon-to-fullscreen">
- </accessible-by-keyboard>
- </li>
- <li class="tab-icon">
- <accessible-by-keyboard (execute)="close()"
- [linkAriaLabel]="text.closeDetailsView"
- [linkTitle]="text.closeDetailsView"
- linkClass="work-packages--details-close-icon"
- spanClass="icon-context icon-close">
- </accessible-by-keyboard>
- </li>
- </ul>
- </div>
+ <op-wp-tabs [workPackage]="workPackage" view="split"></op-wp-tabs>
<div class="work-packages--details-content work-packages-tab-view--overflow" *ngIf="workPackage">
<span class="hidden-for-sighted" tabindex="-1" focus="shouldFocus" [textContent]="focusAnchorLabel">
</span>
diff --git a/frontend/src/app/modules/work_packages/routing/wp-view-base/work-package-single-view.base.ts b/frontend/src/app/modules/work_packages/routing/wp-view-base/work-package-single-view.base.ts
index 6eb6a7a40b5..65871f15516 100644
--- a/frontend/src/app/modules/work_packages/routing/wp-view-base/work-package-single-view.base.ts
+++ b/frontend/src/app/modules/work_packages/routing/wp-view-base/work-package-single-view.base.ts
@@ -41,7 +41,6 @@ import { WorkPackageNotificationService } from 'core-app/modules/work_packages/n
import { InjectField } from 'core-app/helpers/angular/inject-field.decorator';
import { UntilDestroyedMixin } from 'core-app/helpers/angular/until-destroyed.mixin';
import { APIV3Service } from 'core-app/modules/apiv3/api-v3.service';
-import { Tab } from 'core-app/components/wp-tabs/components/wp-tab-wrapper/tab';
import { HookService } from 'core-app/modules/plugins/hook-service';
export class WorkPackageSingleViewBase extends UntilDestroyedMixin {
@@ -142,13 +141,6 @@ export class WorkPackageSingleViewBase extends UntilDestroyedMixin {
});
}
- public tabs():Tab[] {
- return _.filter(
- this.hooks.getWorkPackageTabs(),
- (tab) => tab.displayable(this.workPackage)
- );
- }
-
/**
* Recompute the current tab focus label
*/
@@ -161,8 +153,4 @@ export class WorkPackageSingleViewBase extends UntilDestroyedMixin {
return this.focusAnchorLabel = tabLabel;
}
-
- public canViewWorkPackageWatchers() {
- return !!(this.workPackage && this.workPackage.watchers);
- }
}
diff --git a/frontend/src/global_styles/content/_index.sass b/frontend/src/global_styles/content/_index.sass
index 39657b39705..7f1471356f5 100644
--- a/frontend/src/global_styles/content/_index.sass
+++ b/frontend/src/global_styles/content/_index.sass
@@ -51,6 +51,7 @@
@import form_error_messages
@import ajax_indicator
@import tooltips
+@import scrollable_tabs
@import tabs
@import autocomplete
@import diff
diff --git a/frontend/src/global_styles/content/_scrollable_tabs.sass b/frontend/src/global_styles/content/_scrollable_tabs.sass
new file mode 100644
index 00000000000..907cd782ed3
--- /dev/null
+++ b/frontend/src/global_styles/content/_scrollable_tabs.sass
@@ -0,0 +1,45 @@
+.op-scrollable-tabs
+ display: flex
+ border-bottom: 1px solid #ddd
+ margin-bottom: 1rem
+
+ &--tab-container
+ flex: 1
+ position: relative
+ overflow: hidden
+ box-sizing: content-box
+ height: 40px
+
+ &--actions
+ margin: 0 0 0 10px
+ list-style: none
+ flex: 0
+ height: 40px
+ // Vertically center icons, space them out
+ display: flex
+ align-items: center
+
+ &--tab-container
+ position: relative
+ overflow: hidden
+
+ &--button
+ display: block
+ width: 20px
+ position: absolute
+ top: 0px
+ line-height: 38px
+ background: white
+ color: var(--light-gray)
+ font-size: 0.7rem
+ &_left
+ left: 0
+ box-shadow: 0px 0px 10px 10px white
+ text-align: left
+ &_right
+ right: 0
+ text-align: right
+ box-shadow: 0px 0px 10px 10px white
+ &:hover
+ color: var(--content-link-color)
+ cursor: pointer
diff --git a/frontend/src/global_styles/content/_tabs.lsg b/frontend/src/global_styles/content/_tabs.lsg
index 2f8367f0dc3..52215e7ba84 100644
--- a/frontend/src/global_styles/content/_tabs.lsg
+++ b/frontend/src/global_styles/content/_tabs.lsg
@@ -1,25 +1,26 @@
# Scrollable tabs
```
-<div class="scrollable-tabs">
- <ul class="tabrow"">
- <li class="selected"
- tab-id="tab_1">
- <a href="#scrollable-tabs?tab=tab_1">Tab 1</a>
- </li>
- <li tab-id="tab_2">
- <a href="#scrollable-tabs?tab=tab_2">Tab 2</a>
- </li>
- <li tab-id="tab_3">
- <a href="#scrollable-tabs?tab=tab_3">Tab 3</a>
- </li>
- </ul>
- <div hidden="true" class="scrollable-tabs--button -left">
- <span class="icon-arrow-left2"></span>
- </div>
- <div hidden="true" class="scrollable-tabs--button -right">
- <span class="icon-arrow-right2"></span>
- </div>
+<div class="scrollable-tabs -narrow">
+ <div class="op-scrollable-tabs--tab-container">
+ <ul class="op-tab-row"">
+ <li class="op-tab-row--tab">
+ <a class="op-tab-row--link op-tab-row--link_selected" href="#scrollable-tabs?tab=tab_1">Tab 1</a>
+ </li>
+ <li class="op-tab-row--tab">
+ <a class="op-tab-row--link" href="#scrollable-tabs?tab=tab_2">Tab 2</a>
+ </li>
+ <li class="op-tab-row--tab">
+ <a class="op-tab-row--link" href="#scrollable-tabs?tab=tab_3">Tab 3</a>
+ </li>
+ </ul>
+ <div hidden="true" class="scrollable-tabs--button -left">
+ <span class="icon-arrow-left2"></span>
+ </div>
+ <div hidden="true" class="scrollable-tabs--button -right">
+ <span class="icon-arrow-right2"></span>
+ </div>
+ </div>
</div>
```
@@ -27,23 +28,24 @@ The height of the tabs section can be reduced applying the `-narrow` modificatio
```
<div class="scrollable-tabs -narrow">
- <ul class="tabrow"">
- <li class="selected"
- tab-id="tab_1">
- <a href="#scrollable-tabs?tab=tab_1">Tab 1</a>
- </li>
- <li tab-id="tab_2">
- <a href="#scrollable-tabs?tab=tab_2">Tab 2</a>
- </li>
- <li tab-id="tab_3">
- <a href="#scrollable-tabs?tab=tab_3">Tab 3</a>
- </li>
- </ul>
- <div hidden="true" class="scrollable-tabs--button -left">
- <span class="icon-arrow-left2"></span>
- </div>
- <div hidden="true" class="scrollable-tabs--button -right">
- <span class="icon-arrow-right2"></span>
- </div>
+ <div class="op-scrollable-tabs--tab-container">
+ <ul class="op-tab-row"">
+ <li class="op-tab-row--tab">
+ <a class="op-tab-row--link op-tab-row--link_selected" href="#scrollable-tabs?tab=tab_1">Tab 1</a>
+ </li>
+ <li class="op-tab-row--tab">
+ <a class="op-tab-row--link" href="#scrollable-tabs?tab=tab_2">Tab 2</a>
+ </li>
+ <li class="op-tab-row--tab">
+ <a class="op-tab-row--link" href="#scrollable-tabs?tab=tab_3">Tab 3</a>
+ </li>
+ </ul>
+ <div hidden="true" class="scrollable-tabs--button -left">
+ <span class="icon-arrow-left2"></span>
+ </div>
+ <div hidden="true" class="scrollable-tabs--button -right">
+ <span class="icon-arrow-right2"></span>
+ </div>
+ </div>
</div>
```
diff --git a/frontend/src/global_styles/content/_tabs.sass b/frontend/src/global_styles/content/_tabs.sass
index 6da53211a34..52335c5ecd9 100644
--- a/frontend/src/global_styles/content/_tabs.sass
+++ b/frontend/src/global_styles/content/_tabs.sass
@@ -1,132 +1,55 @@
-.tabrow
- display: table
+.op-tab-row
+ display: block
text-align: left
list-style: none
margin: 0
padding: 0
- line-height: var(--work-package-details--tab-height) - 10px
- height: var(--work-package-details--tab-height)
- overflow: hidden
position: relative
- width: 100%
font-weight: bold
text-transform: uppercase
+ overflow-x: auto
+ white-space: nowrap
+ height: 57px
+
+ &::-webkit-scrollbar
+ width: 0
+ background: transparent
- li
- display: table-cell
- box-sizing: content-box
- position: relative
+ &--tab
+ display: inline-block
line-height: 38px
margin: 0
padding: 0
text-align: center
cursor: pointer
- .wp-tabs-count
- margin-left: 5px
- border-radius: 0.5rem
- min-width: 1rem
- display: inline-block
- font-size: 0.7rem
- line-height: 1rem
- min-height: 1rem
- vertical-align: 0.1rem
- padding: 0 0.15rem 0 0.15rem
- background: var(--light-gray)
- font-weight: bold
-
- a
- display: inline-block
- color: #333
- text-decoration: none
- &:hover
- text-decoration: none
-
- li.tab-icon
+ &--tab-icon
width: 5%
.icon-context:before
padding-top: 10px
&:hover
border-bottom: 0
- li.selected,
- li:hover
- color: #999
- border-bottom: 2px solid
- a
- color: var(--content-link-color)
- .wp-tabs-count
- color: var(--content-link-color)
- &:hover
- color: var(--content-link-color)
- li.selected,
- li.selected:hover
- border-bottom-color: var(--content-link-color)
- li:hover
- border-bottom-color: #DDDDDD
- li.-disabled
- cursor: default
- pointer-events: none
- border-bottom-width: 0
- a
- color: var(--tabs-font-color-disabled)
-
-content-tabs
- min-height: 73px
- display: block
-
-.scrollable-tabs
- position: relative
- overflow: hidden
- box-sizing: content-box
- height: 40px
- border-bottom: 1px solid #DDDDDD
- margin-bottom: 1rem
-
- .tabrow
+ &--link
display: block
- overflow-x: auto
- white-space: nowrap
- height: 57px
- li
- display: inline-block
- padding-left: 1rem
- padding-right: 1rem
- font-size: 14px
-
- &.-narrow
- margin-bottom: 0
- height: initial
-
- .tabrow
- height: initial
- line-height: initial
+ padding-left: 1rem
+ padding-right: 1rem
+ color: var(--body-font-color)
+ text-decoration: none
+ font-size: var(--generic-table--header-font-size)
- li
- line-height: initial
- padding-bottom: 6px
+ &:hover
+ text-decoration: none
+ border-bottom: 2px solid
+ border-bottom-color: var(--light-gray)
-.scrollable-tabs--button
- display: block
- width: 20px
- position: absolute
- top: 0px
- line-height: 38px
- background: white
- color: var(--light-gray)
- font-size: 0.7rem
- &.-left
- left: 0
- box-shadow: 0px 0px 10px 10px white
- text-align: left
- &.-right
- right: 0
- text-align: right
- box-shadow: 0px 0px 10px 10px white
- &:hover
- color: var(--content-link-color)
- cursor: pointer
+ &_selected, &_selected:hover
+ color: var(--content-link-color)
+ border-bottom: 2px solid
+ border-bottom-color: var(--content-link-color)
-.tab-content
- .form--section
- padding: 0
+ &_disabled
+ cursor: default
+ pointer-events: none
+ border-bottom-width: 0
+ color: var(--tabs-font-color-disabled)
diff --git a/frontend/src/global_styles/content/work_packages/single_view/_single_view.sass b/frontend/src/global_styles/content/work_packages/single_view/_single_view.sass
index dc3981ea15e..30197b6abb0 100644
--- a/frontend/src/global_styles/content/work_packages/single_view/_single_view.sass
+++ b/frontend/src/global_styles/content/work_packages/single_view/_single_view.sass
@@ -95,11 +95,6 @@ i
vertical-align: -2px
padding: 0 0 0 4px
-// -------------------- TABS row styling --------------------
-#tabs
- position: relative
- width: 100%
-
.work-packages--details-close-icon span,
.work-packages--details-fullscreen-icon span
display: inline-block
diff --git a/frontend/src/global_styles/layout/work_packages/_details_view.sass b/frontend/src/global_styles/layout/work_packages/_details_view.sass
index 0cea08a408e..be043007f44 100644
--- a/frontend/src/global_styles/layout/work_packages/_details_view.sass
+++ b/frontend/src/global_styles/layout/work_packages/_details_view.sass
@@ -57,7 +57,7 @@ body.router--work-packages-partitioned-split-view-new
.detailsViewMenuItem
display: none
- .tabrow
+ .op-tab-row
padding-left: 20px
.work-packages--details-toolbar-container
diff --git a/frontend/src/global_styles/layout/work_packages/_mobile.sass b/frontend/src/global_styles/layout/work_packages/_mobile.sass
index 8bd63fd3b69..f32c148e93b 100644
--- a/frontend/src/global_styles/layout/work_packages/_mobile.sass
+++ b/frontend/src/global_styles/layout/work_packages/_mobile.sass
@@ -59,8 +59,6 @@
.work-packages-full-view--split-right
width: initial
- .tabrow
- margin: 0.75rem 0 2.5rem 0
.work-packages--panel-inner
padding: 0
diff --git a/modules/boards/spec/features/support/board_page.rb b/modules/boards/spec/features/support/board_page.rb
index 33874b88d2b..bc16c18234e 100644
--- a/modules/boards/spec/features/support/board_page.rb
+++ b/modules/boards/spec/features/support/board_page.rb
@@ -85,6 +85,8 @@ module Pages
subject.set card_title
subject.send_keys :enter
+ sleep 1
+
expect_card(list_name, card_title)
end
diff --git a/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.template.html b/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.template.html
index f4a41060b29..7442353abee 100644
--- a/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.template.html
+++ b/modules/github_integration/frontend/module/git-actions-menu/git-actions-menu.template.html
@@ -3,11 +3,16 @@
<op-icon icon-classes="button--icon icon-console-light"></op-icon>
{{text.title}}
</h3>
- <ul class="tabrow">
- <!-- The hrefs with empty URLs are necessary for IE10 to focus these links
- properly. Thus, don't remove the hrefs or the empty URLs! -->
- <li *ngFor="let tab of tabs" (click)="selectTab(tab)" [class.selected]="tab.selected">
- <a href="" [textContent]="tab.label"></a>
+ <ul class="op-tab-row">
+ <li
+ *ngFor="let tab of tabs"
+ class="op-tab-row--tab"
+ >
+ <a
+ href=""
+ (click)="selectTab(tab)"
+ [class.op-tab-row--link_selected]="tab.selected"
+ [textContent]="tab.label"></a>
</li>
</ul>
<div class="copy-wrapper">
diff --git a/modules/github_integration/frontend/module/git-actions-menu/styles/git-actions-menu.sass b/modules/github_integration/frontend/module/git-actions-menu/styles/git-actions-menu.sass
index 916bfcc986d..e1d044c1ee2 100644
--- a/modules/github_integration/frontend/module/git-actions-menu/styles/git-actions-menu.sass
+++ b/modules/github_integration/frontend/module/git-actions-menu/styles/git-actions-menu.sass
@@ -5,9 +5,6 @@
min-width: 25rem
box-shadow: .1em .1em .4em rgba(0,0,0,0.1)
- .tabrow
- margin-bottom: 0.5rem
-
.copy-wrapper
width: 100%
position: relative
diff --git a/modules/github_integration/frontend/module/main.ts b/modules/github_integration/frontend/module/main.ts
index 2878c442df5..d39728a619d 100644
--- a/modules/github_integration/frontend/module/main.ts
+++ b/modules/github_integration/frontend/module/main.ts
@@ -24,44 +24,35 @@
//
// See docs/COPYRIGHT.rdoc for more details.
-import {Injector, NgModule} from '@angular/core';
+import { Injector, NgModule } from '@angular/core';
+import { OpenprojectCommonModule } from 'core-app/modules/common/openproject-common.module';
-import {HookService} from 'core-app/modules/plugins/hook-service';
-import {WorkPackageResource} from 'core-app/modules/hal/resources/work-package-resource';
-import { Tab } from 'core-app/components/wp-tabs/components/wp-tab-wrapper/tab';
-import {OpenprojectCommonModule} from 'core-app/modules/common/openproject-common.module';
-
-import {GitHubTabComponent} from './github-tab/github-tab.component';
-import {TabHeaderComponent} from './tab-header/tab-header.component';
-import {TabPrsComponent} from './tab-prs/tab-prs.component';
-import {GitActionsMenuDirective} from './git-actions-menu/git-actions-menu.directive';
-import {GitActionsMenuComponent} from './git-actions-menu/git-actions-menu.component';
+import { GitHubTabComponent } from './github-tab/github-tab.component';
+import { TabHeaderComponent } from './tab-header/tab-header.component';
+import { TabPrsComponent } from './tab-prs/tab-prs.component';
+import { GitActionsMenuDirective } from './git-actions-menu/git-actions-menu.directive';
+import { GitActionsMenuComponent } from './git-actions-menu/git-actions-menu.component';
import { WorkPackagesGithubPrsService } from './tab-prs/wp-github-prs.service';
import { PullRequestComponent } from './pull-request/pull-request.component';
-
-function displayable(work_package: WorkPackageResource): boolean {
- return(!!work_package.github);
-}
+import { WorkPackageTabsService } from "core-components/wp-tabs/services/wp-tabs/wp-tabs.service";
export function initializeGithubIntegrationPlugin(injector:Injector) {
- const hooks = injector.get<HookService>(HookService);
- hooks.registerWorkPackageTab(
- new Tab(
- GitHubTabComponent,
- I18n.t('js.github_integration.work_packages.tab_name'),
- 'github',
- displayable
- )
- );
+ const wpTabService = injector.get(WorkPackageTabsService);
+ wpTabService.register({
+ component: GitHubTabComponent,
+ name: I18n.t('js.github_integration.work_packages.tab_name'),
+ id: 'github',
+ displayable: (workPackage) => !!workPackage.github,
+ });
}
@NgModule({
imports: [
- OpenprojectCommonModule
+ OpenprojectCommonModule,
],
providers: [
- WorkPackagesGithubPrsService
+ WorkPackagesGithubPrsService,
],
declarations: [
GitHubTabComponent,
@@ -69,7 +60,7 @@ export function initializeGithubIntegrationPlugin(injector:Injector) {
TabPrsComponent,
GitActionsMenuDirective,
GitActionsMenuComponent,
- PullRequestComponent
+ PullRequestComponent,
],
exports: [
GitHubTabComponent,
@@ -77,7 +68,7 @@ export function initializeGithubIntegrationPlugin(injector:Injector) {
TabPrsComponent,
GitActionsMenuDirective,
GitActionsMenuComponent,
- ]
+ ],
})
export class PluginModule {
constructor(injector:Injector) {
diff --git a/modules/github_integration/spec/support/pages/work_package_github_tab.rb b/modules/github_integration/spec/support/pages/work_package_github_tab.rb
index 75461612bf0..503267ec648 100644
--- a/modules/github_integration/spec/support/pages/work_package_github_tab.rb
+++ b/modules/github_integration/spec/support/pages/work_package_github_tab.rb
@@ -56,7 +56,7 @@ module Pages
end
def expect_tab_not_present
- expect(page).not_to have_selector('.tabrow li', text: 'GITHUB')
+ expect(page).not_to have_selector('.op-tab-row--link', text: 'GITHUB')
end
private
diff --git a/modules/meeting/spec/features/meetings_close_spec.rb b/modules/meeting/spec/features/meetings_close_spec.rb
index 744a868ab62..dc23267d1e2 100644
--- a/modules/meeting/spec/features/meetings_close_spec.rb
+++ b/modules/meeting/spec/features/meetings_close_spec.rb
@@ -58,26 +58,26 @@ describe 'Meetings close', type: :feature do
# Go to minutes, expect uneditable
SeleniumHubWaiter.wait
- find('.tabrow a', text: 'MINUTES').click
+ find('.op-tab-row--link', text: 'MINUTES').click
expect(page).to have_selector('.button', text: 'Close the agenda to begin the Minutes')
# Close the meeting
SeleniumHubWaiter.wait
- find('.tabrow a', text: 'AGENDA').click
+ find('.op-tab-row--link', text: 'AGENDA').click
SeleniumHubWaiter.wait
find('.button', text: 'Close').click
page.accept_confirm
# Expect to be on minutes
- expect(page).to have_selector('.tabrow li.selected', text: 'MINUTES')
+ expect(page).to have_selector('.op-tab-row--link_selected', text: 'MINUTES')
# Copies the text
expect(page).to have_selector('#meeting_minutes-text', text: 'asdf')
# Go back to agenda, expect we can open it again
SeleniumHubWaiter.wait
- find('.tabrow a', text: 'AGENDA').click
+ find('.op-tab-row--link', text: 'AGENDA').click
SeleniumHubWaiter.wait
find('.button', text: 'Open').click
page.accept_confirm
diff --git a/modules/meeting/spec/features/meetings_search_spec.rb b/modules/meeting/spec/features/meetings_search_spec.rb
index 22fe9773272..477657b1653 100644
--- a/modules/meeting/spec/features/meetings_search_spec.rb
+++ b/modules/meeting/spec/features/meetings_search_spec.rb
@@ -48,7 +48,7 @@ describe 'Meeting search', type: :feature, js: true do
query: "Meeting",
select_text: "In this project ↵")
- page.find('[tab-id="meetings"]').click
+ page.find('[data-qa-tab-id="meetings"]').click
expect(page.find('#search-results')).to have_text(meeting.title)
end
end
diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb
index 37c34508517..e3040adee07 100644
--- a/spec/features/search_spec.rb
+++ b/spec/features/search_spec.rb
@@ -225,19 +225,19 @@ describe 'Search', type: :feature, js: true, with_settings: { per_page_options:
global_search.submit_in_current_project
# Expect that the "All" tab is selected.
- expect(page).to have_selector('[tab-id="all"].selected')
+ expect(page).to have_selector('[data-qa-tab-id="all"][data-qa-tab-selected]')
# Expect that the project scope is set to current_project and no module (this is the "all" tab) is requested.
expect(current_url).to match(/\/#{project.identifier}\/search\?q=#{query}&scope=current_project$/)
# Select "Work packages" tab
- page.find('[tab-id="work_packages"]').click
+ page.find('[data-qa-tab-id="work_packages"]').click
# Expect that the project scope is set to current_project and the module "work_packages" is requested.
expect(current_url).to match(/\/search\?q=#{query}&work_packages=1&scope=current_project$/)
# Expect that the "Work packages" tab is selected.
- expect(page).to have_selector('[tab-id="work_packages"].selected')
+ expect(page).to have_selector('[data-qa-tab-id="work_packages"][data-qa-tab-selected]')
table = Pages::EmbeddedWorkPackagesTable.new(find('.work-packages-embedded-view--container'))
table.expect_work_package_count(5) # because we set the page size to this
@@ -312,7 +312,7 @@ describe 'Search', type: :feature, js: true, with_settings: { per_page_options:
global_search.submit_in_project_and_subproject_scope
# Expect that the "Work packages" tab is selected.
- expect(page).to have_selector('[tab-id="work_packages"].selected')
+ expect(page).to have_selector('[data-qa-tab-id="work_packages"][data-qa-tab-selected]')
expect(page).to have_text "Search for \"#{other_work_package.subject}\" in #{project.name} and all subprojects"
diff --git a/spec/features/work_packages/details/query_groups/relation_query_group_spec.rb b/spec/features/work_packages/details/query_groups/relation_query_group_spec.rb
index f3fb6057fe0..d09bbea3238 100644
--- a/spec/features/work_packages/details/query_groups/relation_query_group_spec.rb
+++ b/spec/features/work_packages/details/query_groups/relation_query_group_spec.rb
@@ -61,7 +61,7 @@ describe 'Work package with relation query group', js: true, selenium: true do
let(:full_wp) { ::Pages::FullWorkPackage.new(work_package) }
let(:relations) { ::Components::WorkPackages::Relations.new(work_package) }
let(:tabs) { ::Components::WorkPackages::Tabs.new(work_package) }
- let(:relations_tab) { find('.tabrow li', text: 'RELATIONS') }
+ let(:relations_tab) { find('.op-tab-row--link', text: 'RELATIONS') }
let(:embedded_table) { Pages::EmbeddedWorkPackagesTable.new(first('wp-single-view .work-packages-embedded-view--container')) }
let(:visit) { true }
@@ -241,7 +241,7 @@ describe 'Work package with relation query group', js: true, selenium: true do
# Check that deletion of relations still work after a page reload
full_wp.visit!
- relations_tab = find('.tabrow li', text: 'RELATIONS')
+ relations_tab = find('.op-tab-row--link', text: 'RELATIONS')
relations = Components::WorkPackages::Relations.new(work_package)
embedded_table = Pages::EmbeddedWorkPackagesTable.new(first('wp-single-view .work-packages-embedded-view--container'))
diff --git a/spec/features/work_packages/details/relations/hierarchy_custom_fields_spec.rb b/spec/features/work_packages/details/relations/hierarchy_custom_fields_spec.rb
index a5c734fb847..8a5858f4e4c 100644
--- a/spec/features/work_packages/details/relations/hierarchy_custom_fields_spec.rb
+++ b/spec/features/work_packages/details/relations/hierarchy_custom_fields_spec.rb
@@ -41,7 +41,7 @@ describe 'creating a child directly after the wp itself was created', js: true d
field_format: 'int',
is_for_all: true
end
- let(:relations_tab) { find('.tabrow li', text: 'RELATIONS') }
+ let(:relations_tab) { find('.op-tab-row--link', text: 'RELATIONS') }
before do
login_as user
@@ -71,7 +71,7 @@ describe 'creating a child directly after the wp itself was created', js: true d
# Expect CF value to be still visible
wp_page.expect_and_dismiss_notification(message: 'Successful creation.')
- expect(wp_page).to have_selector('wp-relations-count', text: 1)
+ expect(wp_page).to have_selector('op-tab-count', text: 1)
wp_page.expect_attributes "customField#{custom_field.id}": '42'
end
end
diff --git a/spec/features/work_packages/details/relations/hierarchy_milestone_spec.rb b/spec/features/work_packages/details/relations/hierarchy_milestone_spec.rb
index 4c5f72ba95c..b984ce137bb 100644
--- a/spec/features/work_packages/details/relations/hierarchy_milestone_spec.rb
+++ b/spec/features/work_packages/details/relations/hierarchy_milestone_spec.rb
@@ -37,7 +37,7 @@ describe 'work package hierarchies for milestones', js: true, selenium: true do
let(:tabs) { ::Components::WorkPackages::Tabs.new(work_package) }
let(:wp_page) { Pages::FullWorkPackage.new(work_package) }
- let(:relations_tab) { find('.tabrow li.selected', text: 'RELATIONS') }
+ let(:relations_tab) { find('.op-tab-row--link_selected', text: 'RELATIONS') }
let(:visit) { true }
before do
diff --git a/spec/features/work_packages/details/relations/hierarchy_spec.rb b/spec/features/work_packages/details/relations/hierarchy_spec.rb
index e5232a62f8a..e1ad6141f4c 100644
--- a/spec/features/work_packages/details/relations/hierarchy_spec.rb
+++ b/spec/features/work_packages/details/relations/hierarchy_spec.rb
@@ -38,7 +38,7 @@ shared_examples 'work package relations tab', js: true, selenium: true do
let(:relations) { ::Components::WorkPackages::Relations.new(work_package) }
let(:tabs) { ::Components::WorkPackages::Tabs.new(work_package) }
- let(:relations_tab) { find('.tabrow li.selected', text: 'RELATIONS') }
+ let(:relations_tab) { find('.op-tab-row--link_selected', text: 'RELATIONS') }
let(:visit) { true }
diff --git a/spec/features/work_packages/details/relations/relations_spec.rb b/spec/features/work_packages/details/relations/relations_spec.rb
index 0fcda9ccdd5..9b85702bfa7 100644
--- a/spec/features/work_packages/details/relations/relations_spec.rb
+++ b/spec/features/work_packages/details/relations/relations_spec.rb
@@ -40,7 +40,7 @@ describe 'Work package relations tab', js: true, selenium: true do
let(:relations) { ::Components::WorkPackages::Relations.new(work_package) }
let(:tabs) { ::Components::WorkPackages::Tabs.new(work_package) }
- let(:relations_tab) { find('.tabrow li.selected', text: 'RELATIONS') }
+ let(:relations_tab) { find('.op-tab-row--link_selected', text: 'RELATIONS') }
let(:visit) { true }
diff --git a/spec/features/work_packages/new/new_work_package_spec.rb b/spec/features/work_packages/new/new_work_package_spec.rb
index 7500ae6a0b5..2877f53c9b8 100644
--- a/spec/features/work_packages/new/new_work_package_spec.rb
+++ b/spec/features/work_packages/new/new_work_package_spec.rb
@@ -142,7 +142,7 @@ describe 'new work package', js: true do
description_field.set_value description
save_work_package!
- expect(page).to have_selector('#tabs')
+ expect(page).to have_selector('.op-work-package-tabs')
subject_field.expect_state_text(subject)
description_field = wp_page.edit_field :description
diff --git a/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb b/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb
index c2dcba7f017..75f9da76d01 100644
--- a/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb
+++ b/spec/features/work_packages/table/configuration_modal/table_configuration_modal_spec.rb
@@ -32,6 +32,6 @@ describe 'Work Package table configuration modal', js: true do
find('#column-context-menu .menu-item', text: 'Insert columns ...').click
# Expect active tab is columns
- expect(page).to have_selector('.tab-show.selected', text: 'COLUMNS')
+ expect(page).to have_selector('.op-tab-row--link_selected', text: 'COLUMNS')
end
end
diff --git a/spec/features/work_packages/tabs/watcher_tab_spec.rb b/spec/features/work_packages/tabs/watcher_tab_spec.rb
index f8ee72e8d6e..1748a31a709 100644
--- a/spec/features/work_packages/tabs/watcher_tab_spec.rb
+++ b/spec/features/work_packages/tabs/watcher_tab_spec.rb
@@ -16,7 +16,7 @@ describe 'Watcher tab', js: true, selenium: true do
end
let(:watch_button) { find '#watch-button' }
- let(:watchers_tab) { find('.tabrow li.selected', text: 'WATCHERS') }
+ let(:watchers_tab) { find('.op-tab-row--link_selected', text: 'WATCHERS') }
def expect_button_is_watching
title = I18n.t('js.label_unwatch_work_package')
@@ -53,7 +53,7 @@ describe 'Watcher tab', js: true, selenium: true do
login_as(user)
wp_page.visit_tab! :watchers
expect_angular_frontend_initialized
- expect(page).to have_selector('.tabrow li.selected', text: 'WATCHERS')
+ expect(page).to have_selector('.op-tab-row--link_selected', text: 'WATCHERS')
end
it 'modifying the watcher list modifies the watch button' do
@@ -133,7 +133,7 @@ describe 'Watcher tab', js: true, selenium: true do
it 'should show the number of watchers [#33685]' do
wp_table.open_full_screen_by_doubleclick(work_package)
- expect(page).to have_selector('.wp-tabs-count', text: 1)
+ expect(page).to have_selector('.op-tab-count', text: 1)
end
end
diff --git a/spec/support/components/work_packages/table_configuration/filters.rb b/spec/support/components/work_packages/table_configuration/filters.rb
index d97a14f113b..04d09f59dcc 100644
--- a/spec/support/components/work_packages/table_configuration/filters.rb
+++ b/spec/support/components/work_packages/table_configuration/filters.rb
@@ -55,7 +55,7 @@ module Components
def expect_open
modal.expect_open
- expect(page).to have_selector('.tab-show.selected', text: 'FILTERS')
+ expect(page).to have_selector('.op-tab-row--link_selected', text: 'FILTERS')
end
def expect_closed
diff --git a/spec/support/components/work_packages/table_configuration/highlighting.rb b/spec/support/components/work_packages/table_configuration/highlighting.rb
index 76e08510da0..20962fc6400 100644
--- a/spec/support/components/work_packages/table_configuration/highlighting.rb
+++ b/spec/support/components/work_packages/table_configuration/highlighting.rb
@@ -83,7 +83,7 @@ module Components
::Components::WorkPackages::SettingsMenu.new.open_and_choose 'Configure view'
retry_block do
- find(".tab-show", text: 'HIGHLIGHTING', wait: 10).click
+ find(".op-tab-row--link", text: 'HIGHLIGHTING', wait: 10).click
end
end
diff --git a/spec/support/components/work_packages/table_configuration_modal.rb b/spec/support/components/work_packages/table_configuration_modal.rb
index c5c8688e634..305df9ef50d 100644
--- a/spec/support/components/work_packages/table_configuration_modal.rb
+++ b/spec/support/components/work_packages/table_configuration_modal.rb
@@ -89,11 +89,11 @@ module Components
end
def expect_disabled_tab(name)
- expect(page).to have_selector("#{selector} li.-disabled", text: name.upcase)
+ expect(page).to have_selector("#{selector} [data-qa-tab-disabled]", text: name.upcase)
end
def selected_tab(name)
- page.find("#{selector} .tab-show.selected", text: name.upcase)
+ page.find("#{selector} .op-tab-row--link_selected", text: name.upcase)
page.find("#{selector} .tab-content[data-tab-name='#{name}']")
end
@@ -103,7 +103,7 @@ module Components
SeleniumHubWaiter.wait
retry_block do
- find("#{selector} .tab-show", text: target.upcase, wait: 2).click
+ find("#{selector} .op-tab-row--link", text: target.upcase, wait: 2).click
selected_tab(target)
end
end
diff --git a/spec/support/components/work_packages/tabs_counter.rb b/spec/support/components/work_packages/tabs_counter.rb
index b2ba82601b2..8fb971e03f3 100644
--- a/spec/support/components/work_packages/tabs_counter.rb
+++ b/spec/support/components/work_packages/tabs_counter.rb
@@ -15,12 +15,12 @@ module Components
# Check value of counter for the given tab
def expect_counter(tab, content)
- expect(tab).to have_selector('.wp-tabs-count', text: content.to_s)
+ expect(tab).to have_selector('.op-tab-count', text: content.to_s)
end
# Counter should not be displayed, if there are no relations or watchers
def expect_no_counter(tab)
- expect(tab).to have_no_selector('.wp-tabs-count', wait: 10)
+ expect(tab).to have_no_selector('.op-tab-count', wait: 10)
end
end
end
diff --git a/spec/support/pages/work_packages/abstract_work_package.rb b/spec/support/pages/work_packages/abstract_work_package.rb
index a9f0da8c86b..c778ea4d382 100644
--- a/spec/support/pages/work_packages/abstract_work_package.rb
+++ b/spec/support/pages/work_packages/abstract_work_package.rb
@@ -42,11 +42,11 @@ module Pages
end
def switch_to_tab(tab:)
- find('.tabrow li a', text: tab.upcase).click
+ find('.op-tab-row--link', text: tab.upcase).click
end
def expect_tab(tab)
- expect(page).to have_selector('.tabrow li.selected', text: tab.to_s.upcase)
+ expect(page).to have_selector('.op-tab-row--link_selected', text: tab.to_s.upcase)
end
def edit_field(attribute)