Fixes the role indicator on DMP listing items.

This commit is contained in:
gkolokythas 2019-05-16 10:44:20 +03:00
parent 3914c456d3
commit 468810ccf4
3 changed files with 34 additions and 2 deletions

View File

@ -38,7 +38,7 @@
<div class="row"> <div class="row">
<div class="col-12 about-item"> <div class="col-12 about-item">
<mat-icon class="gray-icon pt-2">settings</mat-icon> <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"> <div class="datasets-counter">
<mat-icon (click)="$event.stopImmediatePropagation(); datasetClicked(dmp)" class="gray-icon pt-2">storage</mat-icon> <mat-icon (click)="$event.stopImmediatePropagation(); datasetClicked(dmp)" class="gray-icon pt-2">storage</mat-icon>

View File

@ -11,6 +11,9 @@ import { DatasetCriteria } from '../../../../core/query/dataset/dataset-criteria
import { DmpService } from '../../../../core/services/dmp/dmp.service'; import { DmpService } from '../../../../core/services/dmp/dmp.service';
import { DatasetService } from '../../../../core/services/dataset/dataset.service'; import { DatasetService } from '../../../../core/services/dataset/dataset.service';
import { DataTableRequest } from '../../../../core/model/data-table/data-table-request'; 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({ @Component({
selector: 'app-dmp-listing-item-component', selector: 'app-dmp-listing-item-component',
@ -25,7 +28,13 @@ export class DmpListingItemComponent implements OnInit {
isDraft: boolean; 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() { ngOnInit() {
if (this.dmp.status == 0) { this.isDraft = true } if (this.dmp.status == 0) { this.isDraft = true }
@ -66,4 +75,25 @@ export class DmpListingItemComponent implements OnInit {
datasetClicked(dmp: DmpListingModel) { datasetClicked(dmp: DmpListingModel) {
this.router.navigate(['/datasets'], { queryParams: { dmpId: dmp.id } }); 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');
}
}
} }

View File

@ -209,6 +209,8 @@
}, },
"DMP-LISTING": { "DMP-LISTING": {
"TITLE": "Data Management Plans", "TITLE": "Data Management Plans",
"OWNER": "Owner",
"MEMBER": "Member",
"COLUMNS": { "COLUMNS": {
"NAME": "Name", "NAME": "Name",
"PROJECT": "Project", "PROJECT": "Project",