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
Add date alert component
Oliver Güntherb3dfa7528936
diff --git a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.tsindex 94e1750e655..0bc23be67ab 100644--- a/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts+++ b/frontend/src/app/core/state/in-app-notifications/in-app-notification.model.ts@@ -12,6 +12,8 @@ export interface IInAppNotificationHalResourceLinks extends IHalResourceLinks {resource:IHalResourceLink;activity:IHalResourceLink;}+export interface IInAppNotificationHalResourceEmbedded {+}export interface INotification {id:ID;@@ -28,4 +30,5 @@ export interface INotification {expanded:boolean;_links:IInAppNotificationHalResourceLinks;+ _embedded:IInAppNotificationHalResourceEmbedded;}diff --git a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.tsindex c60718573aa..0b60c0ef89c 100644--- a/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts+++ b/frontend/src/app/features/in-app-notifications/center/state/ian-center.service.ts@@ -6,6 +6,7 @@ import {debounceTime,defaultIfEmpty,distinctUntilChanged,+ filter,map,mapTo,pluck,@@ -81,6 +82,15 @@ export class IanCenterService extends UntilDestroyedMixin {activeCollection$ = this.query.select('activeCollection');+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion+ activeReason$:Observable<string|undefined> = this.uiRouterGlobals.params$!.pipe(+ this.untilDestroyed(),+ distinctUntilChanged(),+ filter((params) => params.filter === 'reason'),+ map((params) => params.name as string),+ shareReplay(1),+ );+loading$:Observable<boolean> = this.query.selectLoading();selectNotifications$:Observable<INotification[]> = thisdiff --git a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.html b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.htmlnew file mode 100644index 00000000000..8fe1884cd22--- /dev/null+++ b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.html@@ -0,0 +1 @@+<p>in-app-notification-date-alert works!</p>diff --git a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.sass b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.sassnew file mode 100644index 00000000000..e69de29bb2ddiff --git a/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.tsnew file mode 100644index 00000000000..cf6f61c27ec--- /dev/null+++ b/frontend/src/app/features/in-app-notifications/entry/date-alert/in-app-notification-date-alert.component.ts@@ -0,0 +1,69 @@+import {+ Component,+ OnInit,+ ChangeDetectionStrategy,+ Input,+} 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 } from 'rxjs';+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';+import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';+import { SchemaCacheService } from 'core-app/core/schemas/schema-cache.service';++@Component({+ selector: 'op-in-app-notification-date-alert',+ templateUrl: './in-app-notification-date-alert.component.html',+ styleUrls: ['./in-app-notification-date-alert.component.sass'],+ changeDetection: ChangeDetectionStrategy.OnPush+})+export class InAppNotificationDateAlertComponent implements OnInit {+ @Input() aggregatedNotifications:INotification[];++ @Input() notification:INotification;++ @Input() workPackage:WorkPackageResource;++ 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,+ private schemaCache:SchemaCacheService,+ ) { }++ ngOnInit():void {+ this.buildAlertText();+ }++ private buildAlertText() {+ if (this.isOverdue) {+ return;+ }++ if (this.isMilestone) {++ }+ }++ private get isOverdue():boolean {+ return false;+ }++ private get isMilestone():boolean {+ return this.schemaCache.of(this.workPackage).isMilestone as boolean;+ }+}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 ec03ae452a9..3ebd60853ca 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,10 +87,19 @@<divclass="op-ian-item--bottom-line">- <op-in-app-notification-actors-line- [notification]="notification"- [aggregatedNotifications]="aggregatedNotifications"- ></op-in-app-notification-actors-line>+ <ng-container *ngIf="(showDateAlert$ | async) as showDateAlert">+ <op-in-app-notification-date-alert+ *ngIf="showDateAlert"+ [workPackage]="workPackage"+ [notification]="notification"+ [aggregatedNotifications]="aggregatedNotifications"+ ></op-in-app-notification-date-alert>+ <op-in-app-notification-actors-line+ *ngIf="!showDateAlert"+ [notification]="notification"+ [aggregatedNotifications]="aggregatedNotifications"+ ></op-in-app-notification-actors-line>+ </ng-container></div></ng-container><ng-template #workPackageLoading>diff --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 ce24c0c18e9..29b1b0caf4c 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@@ -7,19 +7,16 @@ import {ViewEncapsulation,} from '@angular/core';import { WorkPackageResource } from 'core-app/features/hal/resources/work-package-resource';-import {- Observable,- timer,-} from 'rxjs';+import { Observable } from 'rxjs';import { ApiV3Service } from 'core-app/core/apiv3/api-v3.service';import idFromLink from 'core-app/features/hal/helpers/id-from-link';import { I18nService } from 'core-app/core/i18n/i18n.service';import { TimezoneService } from 'core-app/core/datetime/timezone.service';import {- distinctUntilChanged,map,+ startWith,+ tap,} from 'rxjs/operators';-import { PrincipalLike } from 'core-app/shared/components/principal/principal-types';import { PathHelperService } from 'core-app/core/path-helper/path-helper.service';import { take } from 'rxjs/internal/operators/take';import { StateService } from '@uirouter/angular';@@ -44,6 +41,17 @@ export class InAppNotificationEntryComponent implements OnInit {workPackage$:Observable<WorkPackageResource>|null = null;+ dateAlertFiltered$:Observable<boolean> = this+ .storeService+ .activeReason$+ .pipe(+ tap((x) => console.warn(x)),+ map((reason) => reason === 'date_alert'),+ startWith(false),+ );++ showDateAlert$:Observable<boolean>;+loading$ = this.storeService.query.selectLoading();stateChanged$ = this.storeService.stateChanged$;@@ -72,6 +80,7 @@ export class InAppNotificationEntryComponent implements OnInit {ngOnInit():void {this.buildTranslatedReason();+ this.buildDateAlert();this.buildProject();this.loadWorkPackage();}@@ -145,4 +154,15 @@ export class InAppNotificationEntryComponent implements OnInit {};}}++ private buildDateAlert() {+ this.showDateAlert$ = this+ .dateAlertFiltered$+ .pipe(+ map((dateAlertFiltered) => {+ const dateAlerts = this.aggregatedNotifications.filter((notification) => notification.reason === 'dateAlert');+ return dateAlertFiltered || dateAlerts.length === this.aggregatedNotifications.length;+ }),+ );+ }}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 297501b0c48..39334eb26e8 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@@ -21,6 +21,7 @@ import { OpenprojectContentLoaderModule } from 'core-app/shared/components/op-coimport { 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';+import { InAppNotificationDateAlertComponent } from './entry/date-alert/in-app-notification-date-alert.component';@NgModule({declarations: [@@ -35,6 +36,7 @@ import { InAppNotificationActorsLineComponent } from './entry/actors-line/in-appIanMenuComponent,EmptyStateComponent,InAppNotificationActorsLineComponent,+ InAppNotificationDateAlertComponent,],imports: [OPSharedModule,