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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Extract current authors footer into own component
Oliver Güntherebacf9562425
diff --git a/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.html b/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.htmlnew file mode 100644index 00000000000..9ab437d576c--- /dev/null+++ b/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.html@@ -0,0 +1,27 @@+<div class="op-ian-actors">+ <div+ class="op-ian-actors--date"+ [title]="fixedTime"+ [textContent]="relativeTime$ | async"+ ></div>+ <div>+ <ng-container *ngFor="let actor of actors | slice:0:3; let last = last">+ <span *ngIf="last && actors.length > 1 && actors.length < 4">+ {{ text.and }}+ </span>+ <op-principal+ class="op-ian-item--actors"+ [principal]="actor"+ [hideName]="false"+ [hideAvatar]="true"+ [link]="!isMobile()"+ ></op-principal>+ <span *ngIf="!last && actors.length > 2" [textContent]="', '"></span>+ </ng-container>+ <span+ *ngIf="actors.length > 3"+ >+ {{ text_for_additional_authors(actors.length - 3) }}+ </span>+ </div>+</div>diff --git a/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.sass b/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.sassnew file mode 100644index 00000000000..0ae72459744--- /dev/null+++ b/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.sass@@ -0,0 +1,16 @@+@import "src/assets/sass/helpers"++.op-ian-actors+ display: grid+ grid-template-columns: auto 1fr+ grid-column-gap: 5px+ align-items: center+ color: var(--gray-dark)++ &--line+ vertical-align: baseline++ &--date+ @include text-shortener+ max-width: 100%+ line-height: 16pxdiff --git a/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.ts b/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.tsnew file mode 100644index 00000000000..db9ff9f5262--- /dev/null+++ b/frontend/src/app/features/in-app-notifications/entry/actors-line/in-app-notification-actors-line.component.ts@@ -0,0 +1,109 @@+import {+ ChangeDetectionStrategy,+ Component,+ Input,+ OnInit,+} from '@angular/core';+import { INotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';+import { PrincipalLike } from 'core-app/shared/components/principal/principal-types';+import {+ Observable,+ timer,+} from 'rxjs';+import {+ distinctUntilChanged,+ map,+} from 'rxjs/operators';+import { I18nService } from 'core-app/core/i18n/i18n.service';+import { TimezoneService } from 'core-app/core/datetime/timezone.service';+import { DeviceService } from 'core-app/core/browser/device.service';++@Component({+ selector: 'op-in-app-notification-actors-line',+ templateUrl: './in-app-notification-actors-line.component.html',+ styleUrls: ['./in-app-notification-actors-line.component.sass'],+ changeDetection: ChangeDetectionStrategy.OnPush,+})+export class InAppNotificationActorsLineComponent implements OnInit {+ @Input() aggregatedNotifications:INotification[];++ @Input() notification:INotification;++ // The actor, if any+ actors:PrincipalLike[] = [];++ // Fixed notification time+ fixedTime:string;++ // Format relative elapsed time (n seconds/minutes/hours ago)+ // at an interval for auto updating+ relativeTime$:Observable<string>;++ text = {+ and: this.I18n.t('js.notifications.center.label_actor_and'),+ and_other_singular: this.I18n.t('js.notifications.center.and_more_users.one'),+ and_other_plural: (count:number):string => this.I18n.t('js.notifications.center.and_more_users.other',+ { count }),+ loading: this.I18n.t('js.ajax.loading'),+ placeholder: this.I18n.t('js.placeholders.default'),+ mark_as_read: this.I18n.t('js.notifications.center.mark_as_read'),+ updated_by_at: (age:string):string => this.I18n.t('js.notifications.center.text_update_date',+ { date: age }),+ };++ constructor(+ private I18n:I18nService,+ private timezoneService:TimezoneService,+ private deviceService:DeviceService,+ ) { }++ ngOnInit():void {+ this.buildActors();+ this.buildTime();+ }++ isMobile():boolean {+ return this.deviceService.isMobile;+ }++ text_for_additional_authors(number:number):string {+ let hint:string;+ if (number === 1) {+ hint = this.text.and_other_singular;+ } else {+ hint = this.text.and_other_plural(number);+ }+ return hint;+ }++ private buildTime() {+ this.fixedTime = this.timezoneService.formattedDatetime(this.notification.createdAt);+ this.relativeTime$ = timer(0, 10000)+ .pipe(+ map(() => this.text.updated_by_at(+ this.timezoneService.formattedRelativeDateTime(this.notification.createdAt),+ )),+ distinctUntilChanged(),+ );+ }++ private buildActors() {+ const actors = this+ .aggregatedNotifications+ .map((notification) => {+ const { actor } = notification._links;++ if (!actor) {+ return null;+ }++ return {+ href: actor.href,+ name: actor.title,+ };+ })+ .filter((actor) => actor !== null) as PrincipalLike[];++ this.actors = _.uniqBy(actors, (item) => item.href);+ }+}diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.htmlindex ed60a6b417b..ec03ae452a9 100644--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.html@@ -87,31 +87,10 @@<divclass="op-ian-item--bottom-line">- <div- class="op-ian-item--date"- [title]="fixedTime"- [textContent]="relativeTime$ | async"- ></div>- <div>- <ng-container *ngFor ="let actor of actors | slice:0:3; let last = last">- <span *ngIf="last && actors.length > 1 && actors.length < 4">- {{ text.and }}- </span>- <op-principal- class="op-ian-item--actors"- [principal]="actor"- [hideName]="false"- [hideAvatar]="true"- [link]="!isMobile()"- ></op-principal>- <span *ngIf="!last && actors.length > 2" [textContent]="', '"></span>- </ng-container>- <span- *ngIf="actors.length > 3"- >- {{ text_for_additional_authors(actors.length - 3) }}- </span>- </div>+ <op-in-app-notification-actors-line+ [notification]="notification"+ [aggregatedNotifications]="aggregatedNotifications"+ ></op-in-app-notification-actors-line></div></ng-container><ng-template #workPackageLoading>diff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sassindex 8818fc62f0a..668b8d646ad 100644--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.sass@@ -66,11 +66,6 @@ $subject-font-size: 14px&--bottom-linegrid-area: footer- display: grid- grid-template-columns: auto 1fr- grid-column-gap: 5px- align-items: center- color: var(--gray-dark)&--work-package-subject@include text-shortener@@ -103,11 +98,6 @@ $subject-font-size: 14pxcolor: var(--gray-dark)max-width: 100%- &--date- @include text-shortener- max-width: 100%- line-height: 16px-&--statusgrid-area: statusmargin-right: 5px@@ -137,7 +127,3 @@ $subject-font-size: 14pxgrid-template-columns: max-content auto minmax(20px, max-content)grid-template-areas: "loadingIndicator count buttons"grid-column-gap: 5px-- &--actors- vertical-align: baseline-\ No newline at end of filediff --git a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.tsindex 9ad81dcd917..ce24c0c18e9 100644--- a/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts+++ b/frontend/src/app/features/in-app-notifications/entry/in-app-notification-entry.component.ts@@ -48,30 +48,15 @@ export class InAppNotificationEntryComponent implements OnInit {stateChanged$ = this.storeService.stateChanged$;- // The actor, if any- actors:PrincipalLike[] = [];-// The translated reason, if availabletranslatedReasons:{ [reason:string]:number };- // Format relative elapsed time (n seconds/minutes/hours ago)- // at an interval for auto updating- relativeTime$:Observable<string>;-- fixedTime:string;-project?:{ href:string, title:string, showUrl:string };text = {- and: this.I18n.t('js.notifications.center.label_actor_and'),- and_other_singular: this.I18n.t('js.notifications.center.and_more_users.one'),- and_other_plural: (count:number):string => this.I18n.t('js.notifications.center.and_more_users.other',- { count }),loading: this.I18n.t('js.ajax.loading'),placeholder: this.I18n.t('js.placeholders.default'),mark_as_read: this.I18n.t('js.notifications.center.mark_as_read'),- updated_by_at: (age:string):string => this.I18n.t('js.notifications.center.text_update_date',- { date: age }),};constructor(@@ -87,8 +72,6 @@ export class InAppNotificationEntryComponent implements OnInit {ngOnInit():void {this.buildTranslatedReason();- this.buildActors();- this.buildTime();this.buildProject();this.loadWorkPackage();}@@ -106,17 +89,6 @@ export class InAppNotificationEntryComponent implements OnInit {}}- private buildTime() {- this.fixedTime = this.timezoneService.formattedDatetime(this.notification.createdAt);- this.relativeTime$ = timer(0, 10000)- .pipe(- map(() => this.text.updated_by_at(- this.timezoneService.formattedRelativeDateTime(this.notification.createdAt),- )),- distinctUntilChanged(),- );- }-showDetails():void {if (!this.workPackage$) {return;@@ -141,40 +113,10 @@ export class InAppNotificationEntryComponent implements OnInit {this.storeService.markAsRead(notifications.map((el) => el.id));}- text_for_additional_authors(number:number):string {- let hint:string;- if (number === 1) {- hint = this.text.and_other_singular;- } else {- hint = this.text.and_other_plural(number);- }- return hint;- }-isMobile():boolean {return this.deviceService.isMobile;}- private buildActors() {- const actors = this- .aggregatedNotifications- .map((notification) => {- const { actor } = notification._links;-- if (!actor) {- return null;- }-- return {- href: actor.href,- name: actor.title,- };- })- .filter((actor) => actor !== null) as PrincipalLike[];-- this.actors = _.uniqBy(actors, (item) => item.href);- }-private buildTranslatedReason() {const reasons:{ [reason:string]:number } = {};diff --git a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.tsindex f191185278b..297501b0c48 100644--- a/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts+++ b/frontend/src/app/features/in-app-notifications/in-app-notifications.module.ts@@ -20,6 +20,7 @@ import { MarkAllAsReadButtonComponent } from './center/toolbar/mark-all-as-read/import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-content-loader/openproject-content-loader.module';import { EmptyStateComponent } from './center/empty-state/empty-state.component';import { IanBellService } from 'core-app/features/in-app-notifications/bell/state/ian-bell.service';+import { InAppNotificationActorsLineComponent } from './entry/actors-line/in-app-notification-actors-line.component';@NgModule({declarations: [@@ -33,6 +34,7 @@ import { IanBellService } from 'core-app/features/in-app-notifications/bell/statMarkAllAsReadButtonComponent,IanMenuComponent,EmptyStateComponent,+ InAppNotificationActorsLineComponent,],imports: [OPSharedModule,