2019-07-01 11:35:09 +02:00
|
|
|
import { Component, Inject, OnInit } from '@angular/core';
|
2019-09-23 10:17:03 +02:00
|
|
|
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
2018-11-27 18:33:17 +01:00
|
|
|
import { Router } from '@angular/router';
|
2019-12-11 15:51:03 +01:00
|
|
|
import { DatasetStatus } from '@app/core/common/enum/dataset-status';
|
|
|
|
import { DatasetService } from '@app/core/services/dataset/dataset.service';
|
|
|
|
import { BaseComponent } from '@common/base/base.component';
|
2018-10-11 13:22:03 +02:00
|
|
|
|
|
|
|
@Component({
|
2019-01-18 18:03:45 +01:00
|
|
|
selector: 'app-dmp-finalize-dialog-component',
|
|
|
|
templateUrl: 'dmp-finalize-dialog.component.html',
|
2019-02-08 11:31:22 +01:00
|
|
|
styleUrls: ['./dmp-finalize-dialog.component.scss']
|
2018-10-11 13:22:03 +02:00
|
|
|
})
|
2019-01-18 18:03:45 +01:00
|
|
|
export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit {
|
2018-10-11 13:22:03 +02:00
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
inputModel: DmpFinalizeDialogInput;
|
|
|
|
outputModel: DmpFinalizeDialogOutput;
|
|
|
|
|
2018-10-11 13:22:03 +02:00
|
|
|
constructor(
|
|
|
|
public router: Router,
|
2019-01-18 18:03:45 +01:00
|
|
|
public dialogRef: MatDialogRef<DmpFinalizeDialogComponent>,
|
2019-07-01 11:35:09 +02:00
|
|
|
public datasetService: DatasetService,
|
2018-10-11 13:22:03 +02:00
|
|
|
@Inject(MAT_DIALOG_DATA) public data: any
|
|
|
|
) {
|
2018-11-27 18:33:17 +01:00
|
|
|
super();
|
2019-07-01 11:35:09 +02:00
|
|
|
this.inputModel = data['dialogInputModel'];
|
|
|
|
this.outputModel = { datasetsToBeFinalized: [] };
|
2018-10-12 10:22:23 +02:00
|
|
|
}
|
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
ngOnInit(): void { }
|
2018-10-12 10:22:23 +02:00
|
|
|
|
|
|
|
onSubmit() {
|
2019-07-01 11:35:09 +02:00
|
|
|
this.dialogRef.close(this.outputModel);
|
2018-10-12 10:22:23 +02:00
|
|
|
}
|
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
getFinalizedDatasets() {
|
|
|
|
return this.inputModel.datasets.filter(x => x.status === DatasetStatus.Finalized);
|
2018-10-11 13:22:03 +02:00
|
|
|
}
|
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
getDraftDatasets() {
|
|
|
|
return this.inputModel.datasets.filter(x => x.status === DatasetStatus.Draft);
|
2019-06-21 15:55:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
close() {
|
2019-07-01 11:35:09 +02:00
|
|
|
this.dialogRef.close({ cancelled: true } as DmpFinalizeDialogOutput);
|
2019-06-21 15:55:38 +02:00
|
|
|
}
|
2019-07-01 11:35:09 +02:00
|
|
|
}
|
2019-06-21 15:55:38 +02:00
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
export interface DmpFinalizeDialogInput {
|
|
|
|
dmpLabel: string;
|
|
|
|
dmpDescription: string;
|
|
|
|
datasets: DmpFinalizeDialogDataset[];
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface DmpFinalizeDialogDataset {
|
|
|
|
label: string;
|
|
|
|
id?: string;
|
|
|
|
status: DatasetStatus;
|
|
|
|
}
|
2019-06-21 15:55:38 +02:00
|
|
|
|
2019-07-01 11:35:09 +02:00
|
|
|
export interface DmpFinalizeDialogOutput {
|
|
|
|
cancelled?: boolean;
|
|
|
|
datasetsToBeFinalized?: string[];
|
2018-10-11 13:22:03 +02:00
|
|
|
}
|