Fixes the role indicator on DMP listing items.
This commit is contained in:
parent
3914c456d3
commit
468810ccf4
|
@ -38,7 +38,7 @@
|
|||
<div class="row">
|
||||
<div class="col-12 about-item">
|
||||
<mat-icon class="gray-icon pt-2">settings</mat-icon>
|
||||
<h4 class="mt-2 ml-1 mr-3 p-1">OWNER</h4>
|
||||
<h4 class="mt-2 ml-1 mr-3 p-1">{{roleDisplay(dmp.users)}}</h4>
|
||||
|
||||
<div class="datasets-counter">
|
||||
<mat-icon (click)="$event.stopImmediatePropagation(); datasetClicked(dmp)" class="gray-icon pt-2">storage</mat-icon>
|
||||
|
|
|
@ -11,6 +11,9 @@ import { DatasetCriteria } from '../../../../core/query/dataset/dataset-criteria
|
|||
import { DmpService } from '../../../../core/services/dmp/dmp.service';
|
||||
import { DatasetService } from '../../../../core/services/dataset/dataset.service';
|
||||
import { DataTableRequest } from '../../../../core/model/data-table/data-table-request';
|
||||
import { AuthService } from '../../../../core/services/auth/auth.service';
|
||||
import { Principal } from '../../../../core/model/auth/Principal';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
@Component({
|
||||
selector: 'app-dmp-listing-item-component',
|
||||
|
@ -25,7 +28,13 @@ export class DmpListingItemComponent implements OnInit {
|
|||
|
||||
isDraft: boolean;
|
||||
|
||||
constructor(private router: Router, private dialog: MatDialog, private route: ActivatedRoute, private datasetService: DatasetService) { }
|
||||
constructor(
|
||||
private router: Router,
|
||||
private dialog: MatDialog,
|
||||
private route: ActivatedRoute,
|
||||
private datasetService: DatasetService,
|
||||
private authentication: AuthService,
|
||||
private language: TranslateService) { }
|
||||
|
||||
ngOnInit() {
|
||||
if (this.dmp.status == 0) { this.isDraft = true }
|
||||
|
@ -66,4 +75,25 @@ export class DmpListingItemComponent implements OnInit {
|
|||
datasetClicked(dmp: DmpListingModel) {
|
||||
this.router.navigate(['/datasets'], { queryParams: { dmpId: dmp.id } });
|
||||
}
|
||||
|
||||
roleDisplay(value: any) {
|
||||
const principal: Principal = this.authentication.current();
|
||||
let role: number;
|
||||
if (principal) {
|
||||
value.forEach(element => {
|
||||
if (principal.id === element.id) {
|
||||
role = element.role;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (role === 0) {
|
||||
return this.language.instant('DMP-LISTING.OWNER');
|
||||
}
|
||||
else if (role === 1) {
|
||||
return this.language.instant('DMP-LISTING.MEMBER');
|
||||
}
|
||||
else {
|
||||
return this.language.instant('DMP-LISTING.OWNER');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -209,6 +209,8 @@
|
|||
},
|
||||
"DMP-LISTING": {
|
||||
"TITLE": "Data Management Plans",
|
||||
"OWNER": "Owner",
|
||||
"MEMBER": "Member",
|
||||
"COLUMNS": {
|
||||
"NAME": "Name",
|
||||
"PROJECT": "Project",
|
||||
|
|
Loading…
Reference in New Issue