From e847e4ef51aab604d1d07b79860003551eafe467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Gra=C3=A7a?= Date: Thu, 26 Oct 2023 14:14:22 +0100 Subject: [PATCH 1/5] adding new access-status-list-element-badge css classes --- .../access-status-badge/access-status-badge.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.html b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.html index a0180a761aa..264bd3621ca 100644 --- a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.html +++ b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.html @@ -1,5 +1,5 @@ - {{ accessStatus | translate }} + {{ accessStatus | translate }} From 3bf2eb1997aff92abc9bb7f642d5e7c77866d552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Gra=C3=A7a?= Date: Fri, 10 Nov 2023 00:04:45 +0000 Subject: [PATCH 2/5] Create new access-status-badge.component.scss --- .../access-status-badge/access-status-badge.component.scss | 1 + 1 file changed, 1 insertion(+) create mode 100644 src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.scss diff --git a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.scss b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.scss new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.scss @@ -0,0 +1 @@ + From 6378dbec4afc635a3e3e3dc37f573122a5097746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Gra=C3=A7a?= Date: Fri, 10 Nov 2023 00:09:46 +0000 Subject: [PATCH 3/5] new accessStatusClass atribute --- .../access-status-badge.component.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts index 2be44669b02..e7bb15a75ba 100644 --- a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts +++ b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts @@ -11,7 +11,8 @@ import { ITEM } from '../../../../../core/shared/item.resource-type'; @Component({ selector: 'ds-access-status-badge', - templateUrl: './access-status-badge.component.html' + templateUrl: './access-status-badge.component.html', + styleUrls: ['./access-status-badge.component.scss'] }) /** * Component rendering the access status of an item as a badge @@ -26,6 +27,11 @@ export class AccessStatusBadgeComponent { */ showAccessStatus: boolean; + /** + * Value based stylesheet class for access status badge + */ + accessStatusClass: string; + /** * Initialize instance variables * @@ -57,5 +63,12 @@ export class AccessStatusBadgeComponent { map((status: string) => `access-status.${status.toLowerCase()}.listelement.badge`), catchError(() => observableOf('access-status.unknown.listelement.badge')) ); + + // stylesheet based on the access status value + this.accessStatus$.pipe( + map((accessStatusClass: string) => accessStatusClass.replace(/\./g, '-')) + ).subscribe((accessStatusClass: string) => { + this.accessStatusClass = accessStatusClass; + }); } } From c7eae9242a69cb9a598c2a55843dda72f5125ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Gra=C3=A7a?= Date: Fri, 10 Nov 2023 00:10:55 +0000 Subject: [PATCH 4/5] remove replaceAll and use an object property --- .../access-status-badge/access-status-badge.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.html b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.html index 264bd3621ca..5b20860684b 100644 --- a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.html +++ b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.html @@ -1,5 +1,5 @@ - {{ accessStatus | translate }} + {{ accessStatus | translate }} From 75b788d05b819715feefc31e645d97368ae63054 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Gra=C3=A7a?= Date: Fri, 10 Nov 2023 15:19:36 +0000 Subject: [PATCH 5/5] adding ngOnDestroy for dealing with unsubscribe --- .../access-status-badge.component.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts index e7bb15a75ba..5f27ba4f65d 100644 --- a/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts +++ b/src/app/shared/object-collection/shared/badges/access-status-badge/access-status-badge.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; import { catchError, map } from 'rxjs/operators'; -import { Observable, of as observableOf } from 'rxjs'; +import { Observable, of as observableOf, Subscription } from 'rxjs'; import { AccessStatusObject } from './access-status.model'; import { hasValue } from '../../../../empty.util'; import { environment } from 'src/environments/environment'; @@ -32,6 +32,11 @@ export class AccessStatusBadgeComponent { */ accessStatusClass: string; + /** + * List of subscriptions + */ + subs: Subscription[] = []; + /** * Initialize instance variables * @@ -65,10 +70,16 @@ export class AccessStatusBadgeComponent { ); // stylesheet based on the access status value - this.accessStatus$.pipe( - map((accessStatusClass: string) => accessStatusClass.replace(/\./g, '-')) - ).subscribe((accessStatusClass: string) => { - this.accessStatusClass = accessStatusClass; - }); + this.subs.push( + this.accessStatus$.pipe( + map((accessStatusClass: string) => accessStatusClass.replace(/\./g, '-')) + ).subscribe((accessStatusClass: string) => { + this.accessStatusClass = accessStatusClass; + }) + ); + } + + ngOnDestroy(): void { + this.subs.filter((sub) => hasValue(sub)).forEach((sub) => sub.unsubscribe()); } }