argos/dmp-frontend/src/app/ui/dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.compone...

64 lines
1.7 KiB
TypeScript
Raw Normal View History

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';
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';
@Component({
2019-01-18 18:03:45 +01:00
selector: 'app-dmp-finalize-dialog-component',
templateUrl: 'dmp-finalize-dialog.component.html',
styleUrls: ['./dmp-finalize-dialog.component.scss']
})
2019-01-18 18:03:45 +01:00
export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit {
inputModel: DmpFinalizeDialogInput;
outputModel: DmpFinalizeDialogOutput;
constructor(
public router: Router,
2019-01-18 18:03:45 +01:00
public dialogRef: MatDialogRef<DmpFinalizeDialogComponent>,
public datasetService: DatasetService,
@Inject(MAT_DIALOG_DATA) public data: any
) {
2018-11-27 18:33:17 +01:00
super();
this.inputModel = data['dialogInputModel'];
this.outputModel = { datasetsToBeFinalized: [] };
}
ngOnInit(): void { }
onSubmit() {
this.dialogRef.close(this.outputModel);
}
getFinalizedDatasets() {
return this.inputModel.datasets.filter(x => x.status === DatasetStatus.Finalized);
}
getDraftDatasets() {
return this.inputModel.datasets.filter(x => x.status === DatasetStatus.Draft);
}
close() {
this.dialogRef.close({ cancelled: true } as DmpFinalizeDialogOutput);
}
}
export interface DmpFinalizeDialogInput {
dmpLabel: string;
dmpDescription: string;
datasets: DmpFinalizeDialogDataset[];
}
export interface DmpFinalizeDialogDataset {
label: string;
id?: string;
status: DatasetStatus;
}
export interface DmpFinalizeDialogOutput {
cancelled?: boolean;
datasetsToBeFinalized?: string[];
}