mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
Merge pull request #2579 from paulo-graca/bugfix/accessstatus-2402
adding new access-status-list-element-badge css classes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<ng-container *ngIf="showAccessStatus">
|
<ng-container *ngIf="showAccessStatus">
|
||||||
<span *ngIf="accessStatus$ | async as accessStatus">
|
<span *ngIf="accessStatus$ | async as accessStatus">
|
||||||
<span class="badge badge-secondary">{{ accessStatus | translate }}</span>
|
<span [class]="'badge badge-secondary access-status-list-element-badge ' + accessStatusClass">{{ accessStatus | translate }}</span>
|
||||||
</span>
|
</span>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
@@ -0,0 +1 @@
|
|||||||
|
|
@@ -1,6 +1,6 @@
|
|||||||
import { Component, Input } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { catchError, map } from 'rxjs/operators';
|
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 { AccessStatusObject } from './access-status.model';
|
||||||
import { hasValue } from '../../../../empty.util';
|
import { hasValue } from '../../../../empty.util';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
@@ -11,7 +11,8 @@ import { ITEM } from '../../../../../core/shared/item.resource-type';
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-access-status-badge',
|
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
|
* Component rendering the access status of an item as a badge
|
||||||
@@ -26,6 +27,16 @@ export class AccessStatusBadgeComponent {
|
|||||||
*/
|
*/
|
||||||
showAccessStatus: boolean;
|
showAccessStatus: boolean;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Value based stylesheet class for access status badge
|
||||||
|
*/
|
||||||
|
accessStatusClass: string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of subscriptions
|
||||||
|
*/
|
||||||
|
subs: Subscription[] = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize instance variables
|
* Initialize instance variables
|
||||||
*
|
*
|
||||||
@@ -57,5 +68,18 @@ export class AccessStatusBadgeComponent {
|
|||||||
map((status: string) => `access-status.${status.toLowerCase()}.listelement.badge`),
|
map((status: string) => `access-status.${status.toLowerCase()}.listelement.badge`),
|
||||||
catchError(() => observableOf('access-status.unknown.listelement.badge'))
|
catchError(() => observableOf('access-status.unknown.listelement.badge'))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// stylesheet based on the access status value
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user