Finalize Dialog on New DMP (Wizard)

This commit is contained in:
apapachristou 2019-06-24 16:02:09 +03:00
parent 425a64e60a
commit 742dd5015f
5 changed files with 73 additions and 18 deletions

View File

@ -435,6 +435,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
data: { data: {
formGroup: this.formGroup, formGroup: this.formGroup,
dmp: this.dmp, dmp: this.dmp,
isWizard: false,
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'), message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'), confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
@ -445,8 +446,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
} }
} }
}); });
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { });
});
} }
} }

View File

@ -50,8 +50,36 @@
| translate}}</mat-error> | translate}}</mat-error>
</div> </div>
<div mat-dialog-content *ngIf="isWizard" class="pt-2 pb-2">
<mat-accordion [multi]="true">
<mat-expansion-panel>
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'DMP-FINALISE-DIALOG.DMP' | translate }}
</mat-panel-title>
<mat-panel-description class="dmp-title">
{{ formGroup.get('dmp')?.get('label')?.value }}
</mat-panel-description>
</mat-expansion-panel-header>
{{ formGroup.get('dmp')?.get('description')?.value }}
</mat-expansion-panel>
<mat-expansion-panel [expanded]="true">
<mat-expansion-panel-header>
<mat-panel-title>
{{ 'DMP-FINALISE-DIALOG.DATASETS' | translate }}
</mat-panel-title>
<mat-panel-description></mat-panel-description>
</mat-expansion-panel-header>
<div *ngFor="let label of allDatasetLabels" class="row pl-3 datasets">
<mat-icon class="col-1 finalized-bookmark">bookmark</mat-icon>
<h4 class="col-11 ml-auto mt-1 mb-4">{{ label }}</h4>
</div>
</mat-expansion-panel>
</mat-accordion>
</div>
<div> <div>
<mat-error class="row pt-2 pb-2 pl-4 pr-4" > <mat-error class="row pt-2 pb-2 pl-4 pr-4">
{{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }} {{ 'DMP-FINALISE-DIALOG.IMPACT' | translate }}
</mat-error> </mat-error>
<div class="row pl-4 pr-4"> <div class="row pl-4 pr-4">

View File

@ -26,6 +26,8 @@ export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit
public datasetsFinalized: DatasetListingModel[]; public datasetsFinalized: DatasetListingModel[];
public datasetsDraft: DatasetListingModel[]; public datasetsDraft: DatasetListingModel[];
public allDatasets: DatasetListingModel[] = []; public allDatasets: DatasetListingModel[] = [];
public allDatasetLabels: String[] = [];
public isWizard: boolean;
constructor( constructor(
public router: Router, public router: Router,
public dialogRef: MatDialogRef<DmpFinalizeDialogComponent>, public dialogRef: MatDialogRef<DmpFinalizeDialogComponent>,
@ -36,11 +38,18 @@ export class DmpFinalizeDialogComponent extends BaseComponent implements OnInit
this.submitFunction = data['submitFunction']; this.submitFunction = data['submitFunction'];
this.dmp = data['dmp']; this.dmp = data['dmp'];
this.formGroup = data['formGroup']; this.formGroup = data['formGroup'];
this.isWizard = data['isWizard'];
} }
ngOnInit(): void { ngOnInit(): void {
if(!this.isWizard) {
this.initialiseDatasetFinalizedRequest(); this.initialiseDatasetFinalizedRequest();
this.initialiseDmpFinalizedRequest(); this.initialiseDmpFinalizedRequest();
} else {
for (let value of (this.formGroup.get('datasets').get('datasetsList') as FormArray).value) {
this.allDatasetLabels.push(value.datasetLabel);
}
}
} }
initialiseDatasetFinalizedRequest() { initialiseDatasetFinalizedRequest() {

View File

@ -15,6 +15,7 @@ import { ProjectEditorWizardModel } from '../project-editor/project-editor-wizar
import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model'; import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model';
import { DatasetEditorWizardComponent } from '../dataset-editor/dataset-editor-wizard.component'; import { DatasetEditorWizardComponent } from '../dataset-editor/dataset-editor-wizard.component';
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component'; import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
import { DmpFinalizeDialogComponent } from '../../dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
@Component({ @Component({
@ -78,15 +79,31 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
} }
saveFinalize() { saveFinalize() {
const dialogRef = this.dialog.open(DmpFinalizeDialogComponent, {
maxWidth: '500px',
data: {
formGroup: this.formGroup,
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
isWizard: true,
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
submitFunction: () => {
if (!this.isFormValid()) { return; } if (!this.isFormValid()) { return; }
if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) { if (this.formGroup.get('datasets') && this.formGroup.get('datasets').get('datasetsList') && (this.formGroup.get('datasets').get('datasetsList') as FormArray).length > 0) {
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) { for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue('1'); control.get('status').setValue('1');
} }
this.formGroup.get('dmp').get('status').setValue('1');
this.onSubminSaveAndFinalize(); this.onSubminSaveAndFinalize();
} else { } else {
return; return;
} }
dialogRef.close();
}
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
});
} }
hasDatasets() { hasDatasets() {

View File

@ -10,6 +10,7 @@ import { QuickWizardEditorComponent } from './quick-wizard-editor/quick-wizard-e
import { AutoCompleteModule } from '../../library/auto-complete/auto-complete.module'; import { AutoCompleteModule } from '../../library/auto-complete/auto-complete.module';
import { DatasetEditorWizardComponent } from './dataset-editor/dataset-editor-wizard.component'; import { DatasetEditorWizardComponent } from './dataset-editor/dataset-editor-wizard.component';
import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/dataset-description-form.module'; import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/dataset-description-form.module';
import { DmpModule } from '../dmp/dmp.module';
@NgModule({ @NgModule({
@ -21,12 +22,13 @@ import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/d
ConfirmationDialogModule, ConfirmationDialogModule,
QuickWizardRoutingModule, QuickWizardRoutingModule,
DatasetDescriptionFormModule, DatasetDescriptionFormModule,
DmpModule
], ],
declarations: [ declarations: [
ProjectEditorWizardComponent, ProjectEditorWizardComponent,
DmpEditorWizardComponent, DmpEditorWizardComponent,
QuickWizardEditorComponent, QuickWizardEditorComponent,
DatasetEditorWizardComponent DatasetEditorWizardComponent,
], ],
exports: [ exports: [
DatasetEditorWizardComponent, DatasetEditorWizardComponent,