argos/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.ts

109 lines
3.1 KiB
TypeScript
Raw Normal View History

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';
import { Router, ActivatedRoute } from '@angular/router';
import { DatasetService } from '../../../../core/services/dataset/dataset.service';
import { AuthService } from '../../../../core/services/auth/auth.service';
2020-04-27 15:21:03 +02:00
import { Principal } from '../../../../core/model/auth/principal';
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;
@Input() isPublic: boolean;
2019-04-25 16:04:54 +02:00
@Output() onClick: EventEmitter<DmpListingModel> = new EventEmitter();
isDraft: boolean;
isFinalized: boolean;
isPublished: boolean;
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() {
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',
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-10-23 17:36:29 +02:00
// itemClicked() {
// this.onClick.emit(this.dmp);
// }
2019-10-23 17:36:29 +02:00
// grantClicked(grantId: String) {
// this.router.navigate(['/grants/edit/' + grantId]);
// }
2019-10-23 17:36:29 +02:00
// datasetClicked(dmpId: string) {
// this.router.navigate(['/plans/edit/' + dmpId], { queryParams: { tab: "datasetDescriptions" } });
// }
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');
}
else if (role === 1) {
2019-05-21 15:42:28 +02:00
return this.translate.instant('DMP-LISTING.MEMBER');
}
else {
2019-05-21 15:42:28 +02:00
return this.translate.instant('DMP-LISTING.OWNER');
}
}
2019-04-25 16:04:54 +02:00
}