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

Use HostBinding and spot css

Oliver Günthera35a0a5a47a3
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.html
index 9ab437d576c..e22426832b5 100644
--- 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.html
@@ -1,27 +1,21 @@
-<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
+ 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]="!deviceService.isMobile"
+ ></op-principal>
+ <span *ngIf="!last && actors.length > 2" [textContent]="', '"></span>
+ </ng-container>
+ <span *ngIf="actors.length > 3" [textContent]="text_for_additional_authors(actors.length - 3) "></span>
</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.sass
index 0ae72459744..81fbd4a24dd 100644
--- 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.sass
@@ -3,7 +3,7 @@
.op-ian-actors
display: grid
grid-template-columns: auto 1fr
- grid-column-gap: 5px
+ grid-column-gap: $spot-spacing-0_25
align-items: center
color: var(--gray-dark)
diff --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.ts
index db9ff9f5262..e3bef1d92f2 100644
--- 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.ts
@@ -1,8 +1,10 @@
import {
ChangeDetectionStrategy,
Component,
+ HostBinding,
Input,
OnInit,
+ ViewEncapsulation,
} 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';
@@ -23,8 +25,11 @@ import { DeviceService } from 'core-app/core/browser/device.service';
templateUrl: './in-app-notification-actors-line.component.html',
styleUrls: ['./in-app-notification-actors-line.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
+ encapsulation: ViewEncapsulation.None,
})
export class InAppNotificationActorsLineComponent implements OnInit {
+ @HostBinding('class.op-ian-actors') className = true;
+
@Input() aggregatedNotifications:INotification[];
@Input() notification:INotification;
@@ -52,9 +57,9 @@ export class InAppNotificationActorsLineComponent implements OnInit {
};
constructor(
+ readonly deviceService:DeviceService,
private I18n:I18nService,
private timezoneService:TimezoneService,
- private deviceService:DeviceService,
) { }
ngOnInit():void {
@@ -62,18 +67,12 @@ export class InAppNotificationActorsLineComponent implements OnInit {
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;
+ return this.text.and_other_singular;
} else {
- hint = this.text.and_other_plural(number);
+ return this.text.and_other_plural(number);
}
- return hint;
}
private buildTime() {
diff --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.html
index aac5db6c572..c46580c1429 100644
--- 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.html
@@ -1,12 +1,7 @@
-<div
- class="op-ian-date-alert"
- [ngClass]="{ 'op-ian-date-alert_overdue': isOverdue }"
->
- <span
- class="op-ian-date-alert--property"
- [textContent]="propertyText"></span>
- &ngsp;
- <span
- class="op-ian-date-alert--days"
- [textContent]="alertText"></span>
-</div>
+<span
+ class="op-ian-date-alert--property"
+ [textContent]="propertyText"></span>
+&ngsp;
+<span
+ class="op-ian-date-alert--days"
+ [textContent]="alertText"></span>
diff --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.ts
index d8a696dc7aa..9ba9f4e898d 100644
--- 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.ts
@@ -1,8 +1,10 @@
import {
ChangeDetectionStrategy,
Component,
+ HostBinding,
Input,
OnInit,
+ ViewEncapsulation,
} from '@angular/core';
import { INotification } from 'core-app/core/state/in-app-notifications/in-app-notification.model';
import { I18nService } from 'core-app/core/i18n/i18n.service';
@@ -16,18 +18,24 @@ import { Moment } from 'moment';
templateUrl: './in-app-notification-date-alert.component.html',
styleUrls: ['./in-app-notification-date-alert.component.sass'],
changeDetection: ChangeDetectionStrategy.OnPush,
+ encapsulation: ViewEncapsulation.None,
+ host: {
+ class: 'op-ian-date-alert'
+ }
})
export class InAppNotificationDateAlertComponent implements OnInit {
@Input() aggregatedNotifications:INotification[];
@Input() workPackage:WorkPackageResource;
+ @HostBinding('class.op-ian-date-alert') className = true;
+
+ @HostBinding('class.op-ian-date-alert_overdue') isOverdue:boolean;
+
alertText:string;
dateIsPast:boolean;
- isOverdue:boolean;
-
propertyText:string;
private daysDiff:string;