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: {
formGroup: this.formGroup,
dmp: this.dmp,
isWizard: false,
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.FINALIZE-ITEM'),
confirmButton: this.language.instant('DMP-FINALISE-DIALOG.SUBMIT'),
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>
</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>
<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 }}
</mat-error>
<div class="row pl-4 pr-4">

View File

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

View File

@ -15,6 +15,7 @@ import { ProjectEditorWizardModel } from '../project-editor/project-editor-wizar
import { QuickWizardEditorWizardModel } from './quick-wizard-editor.model';
import { DatasetEditorWizardComponent } from '../dataset-editor/dataset-editor-wizard.component';
import { ConfirmationDialogComponent } from '../../../library/confirmation-dialog/confirmation-dialog.component';
import { DmpFinalizeDialogComponent } from '../../dmp/editor/dmp-finalize-dialog/dmp-finalize-dialog.component';
@Component({
@ -78,15 +79,31 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
}
saveFinalize() {
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) {
for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) {
control.get('status').setValue('1');
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.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) {
control.get('status').setValue('1');
}
this.formGroup.get('dmp').get('status').setValue('1');
this.onSubminSaveAndFinalize();
} else {
return;
}
dialogRef.close();
}
}
this.onSubminSaveAndFinalize();
} else {
return;
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
});
}
hasDatasets() {
@ -120,8 +137,8 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
this.quickWizardService.createQuickWizard(this.formGroup.getRawValue())
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
complete => this.onCallbackSuccess(),
error => this.onCallbackError(error)
);
}
@ -140,7 +157,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit,
this.quickWizardService.createQuickWizard(this.formGroup.value)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => this.onCallbackSuccess()
complete => this.onCallbackSuccess()
)
}
});

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 { DatasetEditorWizardComponent } from './dataset-editor/dataset-editor-wizard.component';
import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/dataset-description-form.module';
import { DmpModule } from '../dmp/dmp.module';
@NgModule({
@ -21,12 +22,13 @@ import { DatasetDescriptionFormModule } from '../misc/dataset-description-form/d
ConfirmationDialogModule,
QuickWizardRoutingModule,
DatasetDescriptionFormModule,
DmpModule
],
declarations: [
ProjectEditorWizardComponent,
DmpEditorWizardComponent,
QuickWizardEditorComponent,
DatasetEditorWizardComponent
DatasetEditorWizardComponent,
],
exports: [
DatasetEditorWizardComponent,