2019-04-25 16:04:54 +02:00
|
|
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
|
|
|
import { DmpListingModel } from '../../../../core/model/dmp/dmp-listing';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { MatDialog } from '@angular/material/dialog';
|
2019-05-08 10:37:44 +02:00
|
|
|
import { DmpInvitationDialogComponent } from '../../invitation/dmp-invitation.component';
|
2019-05-15 08:57:10 +02:00
|
|
|
import { Router, ActivatedRoute } from '@angular/router';
|
|
|
|
import { DatasetService } from '../../../../core/services/dataset/dataset.service';
|
2019-05-16 09:44:20 +02:00
|
|
|
import { AuthService } from '../../../../core/services/auth/auth.service';
|
2020-04-27 15:21:03 +02:00
|
|
|
import { Principal } from '../../../../core/model/auth/principal';
|
2019-05-16 09:44:20 +02:00
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2019-06-25 11:16:37 +02:00
|
|
|
import { DmpStatus } from '../../../../core/common/enum/dmp-status';
|
2019-04-25 16:04:54 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-dmp-listing-item-component',
|
|
|
|
templateUrl: './dmp-listing-item.component.html',
|
|
|
|
styleUrls: ['./dmp-listing-item.component.scss'],
|
|
|
|
})
|
|
|
|
export class DmpListingItemComponent implements OnInit {
|
|
|
|
|
|
|
|
@Input() dmp: DmpListingModel;
|
|
|
|
@Input() showDivider: boolean = true;
|
2020-04-01 17:16:06 +02:00
|
|
|
@Input() isPublic: boolean;
|
2019-04-25 16:04:54 +02:00
|
|
|
@Output() onClick: EventEmitter<DmpListingModel> = new EventEmitter();
|
|
|
|
|
2019-05-09 15:30:39 +02:00
|
|
|
isDraft: boolean;
|
2019-06-25 17:16:31 +02:00
|
|
|
isFinalized: boolean;
|
|
|
|
isPublished: boolean;
|
2019-05-09 15:30:39 +02:00
|
|
|
|
2019-05-16 09:44:20 +02:00
|
|
|
constructor(
|
|
|
|
private router: Router,
|
|
|
|
private dialog: MatDialog,
|
|
|
|
private authentication: AuthService,
|
2019-05-21 15:42:28 +02:00
|
|
|
private translate: TranslateService) { }
|
2019-04-25 16:04:54 +02:00
|
|
|
|
|
|
|
ngOnInit() {
|
2019-06-25 17:16:31 +02:00
|
|
|
if (this.dmp.status == DmpStatus.Draft) {
|
|
|
|
this.isDraft = true;
|
|
|
|
this.isFinalized = false;
|
|
|
|
this.isPublished = false;
|
|
|
|
}
|
|
|
|
else if (this.dmp.status == DmpStatus.Finalized) {
|
|
|
|
this.isDraft = false;
|
|
|
|
this.isFinalized = true;
|
|
|
|
this.isPublished = false;
|
|
|
|
if (this.dmp.public == true) { this.isPublished = true }
|
|
|
|
}
|
2019-04-25 16:04:54 +02:00
|
|
|
}
|
|
|
|
|
2019-05-08 10:37:44 +02:00
|
|
|
openShareDialog(rowId: any, rowName: any) {
|
|
|
|
const dialogRef = this.dialog.open(DmpInvitationDialogComponent, {
|
|
|
|
// height: '250px',
|
|
|
|
// width: '700px',
|
2019-09-27 10:09:29 +02:00
|
|
|
restoreFocus: false,
|
2019-05-08 10:37:44 +02:00
|
|
|
data: {
|
|
|
|
dmpId: rowId,
|
|
|
|
dmpName: rowName
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-05-22 15:52:55 +02:00
|
|
|
editClicked(dmpId: String) {
|
|
|
|
this.router.navigate(['/plans/edit/' + dmpId]);
|
|
|
|
}
|
|
|
|
|
2019-05-08 10:37:44 +02:00
|
|
|
addDataset(rowId: String) {
|
|
|
|
this.router.navigate(['/datasets/new/' + rowId]);
|
|
|
|
}
|
|
|
|
|
|
|
|
showDatasets(rowId: String, rowLabel: String) {
|
|
|
|
this.router.navigate(['/datasets/dmp/' + rowId, { dmpLabel: rowLabel }]);
|
|
|
|
}
|
|
|
|
|
|
|
|
viewVersions(rowId: String, rowLabel: String) {
|
|
|
|
this.router.navigate(['/plans/versions/' + rowId], { queryParams: { groupLabel: rowLabel } });
|
|
|
|
}
|
2019-05-14 13:35:02 +02:00
|
|
|
|
2019-10-23 17:36:29 +02:00
|
|
|
// itemClicked() {
|
|
|
|
// this.onClick.emit(this.dmp);
|
|
|
|
// }
|
2019-05-14 13:35:02 +02:00
|
|
|
|
2019-10-23 17:36:29 +02:00
|
|
|
// grantClicked(grantId: String) {
|
|
|
|
// this.router.navigate(['/grants/edit/' + grantId]);
|
|
|
|
// }
|
2019-05-15 08:57:10 +02:00
|
|
|
|
2019-10-23 17:36:29 +02:00
|
|
|
// datasetClicked(dmpId: string) {
|
|
|
|
// this.router.navigate(['/plans/edit/' + dmpId], { queryParams: { tab: "datasetDescriptions" } });
|
|
|
|
// }
|
2019-05-16 09:44:20 +02:00
|
|
|
|
|
|
|
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) {
|
2019-05-21 15:42:28 +02:00
|
|
|
return this.translate.instant('DMP-LISTING.OWNER');
|
2019-05-16 09:44:20 +02:00
|
|
|
}
|
|
|
|
else if (role === 1) {
|
2019-05-21 15:42:28 +02:00
|
|
|
return this.translate.instant('DMP-LISTING.MEMBER');
|
2019-05-16 09:44:20 +02:00
|
|
|
}
|
|
|
|
else {
|
2019-05-21 15:42:28 +02:00
|
|
|
return this.translate.instant('DMP-LISTING.OWNER');
|
2019-05-16 09:44:20 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-25 16:04:54 +02:00
|
|
|
}
|