From 4ba6b687b68f27cf43324a086304cdeb178c3f16 Mon Sep 17 00:00:00 2001 From: apapachristou Date: Wed, 19 Jun 2019 11:59:47 +0300 Subject: [PATCH] Fixes bug on DMP wizard new dataset - (Issue #106) --- .../recent-edited-activity.component.css | 3 +- .../recent-visited-activity.component.css | 3 +- .../dataset-create-wizard.component.ts | 72 +++++++++++-------- .../dataset-editor-wizard.component.html | 1 + .../dataset-editor-wizard.component.ts | 33 ++++++--- .../quick-wizard-editor.component.ts | 2 +- .../src/app/ui/sidebar/sidebar.component.html | 2 +- dmp-frontend/src/assets/i18n/en.json | 3 +- 8 files changed, 73 insertions(+), 46 deletions(-) diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.css b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.css index 77d54cc2c..bb91d4d54 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.css +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.css @@ -3,7 +3,8 @@ th { } .is-public { - padding-left: 0px; + padding-left: 5px; + padding-right: 5px; border: 1px solid rgb(197, 224, 180); color: rgb(131, 184, 95); background-color: rgb(240, 247, 236); diff --git a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.css b/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.css index 122770624..8402448b8 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.css +++ b/dmp-frontend/src/app/ui/dashboard/recent-visited-activity/recent-visited-activity.component.css @@ -3,7 +3,8 @@ th { } .is-public { - padding-left: 0px; + padding-left: 5px; + padding-right: 5px; border: 1px solid rgb(197, 224, 180); color: rgb(131, 184, 95); background-color: rgb(240, 247, 236); diff --git a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.ts b/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.ts index c151cc291..6182d6254 100644 --- a/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.ts +++ b/dmp-frontend/src/app/ui/dataset-create-wizard/dataset-create-wizard.component.ts @@ -44,13 +44,16 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread ngOnInit() { this.datasetCreateWizardModel = new DatasetCreateWizardModel(); this.formGroup = this.datasetCreateWizardModel.buildForm(); - this.breadCrumbs = Observable.of([ - { - parentComponentName: 'Dashboard', - label: this.language.instant('NAV-BAR.DATASET-DESCRIPTION-WIZARD'), - url: '/datasetcreatewizard' - }] - ); + this.language.get('NAV-BAR.DATASET-DESCRIPTION-WIZARD').pipe(takeUntil(this._destroyed)).subscribe(x => { + this.breadCrumbs = Observable.of([ + { + parentComponentName: 'Dashboard', + label: x, + url: '/datasetcreatewizard' + }] + ); + }) + } save() { @@ -58,7 +61,13 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread for (let control of (this.formGroup.get('datasets').get('datasetsList') as FormArray).controls) { control.get('status').setValue('0'); } - this.onSubmitSave(); + // this.onSubmitSave(); + const dmpId = this.formGroup.get('dmpMeta').get('dmp').value.id; + this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) + .pipe(takeUntil(this._destroyed)) + .subscribe( + complete => this.onCallbackSuccess(dmpId) + ) } else { return; } @@ -76,32 +85,33 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread } } - onSubmitSave() { - const dialogRef = this.dialog.open(ConfirmationDialogComponent, { - data: { - message: this.language.instant('QUICKWIZARD.SAVE-DIALOG.TITLE'), - confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), - cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE') - } - }); - dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { - if (result) { - this.datasetEditorWizardComponent.addDataset(); - } else if (result === false) { - this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) - .pipe(takeUntil(this._destroyed)) - .subscribe( - complete => this.onCallbackSuccess() - ) - } - }); - } + // onSubmitSave() { + // const dialogRef = this.dialog.open(ConfirmationDialogComponent, { + // data: { + // message: this.language.instant('QUICKWIZARD.SAVE-DIALOG.TITLE'), + // confirmButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.AFFIRMATIVE'), + // cancelButton: this.language.instant('QUICKWIZARD.SAVE-DIALOG.ACTIONS.NEGATIVE') + // } + // }); + // dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + // if (result) { + // this.datasetEditorWizardComponent.addDataset(); + // } else if (result === false) { + // this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) + // .pipe(takeUntil(this._destroyed)) + // .subscribe( + // complete => this.onCallbackSuccess() + // ) + // } + // }); + // } onSubmitSaveAndFinalize() { + const dmpId = this.formGroup.get('dmpMeta').get('dmp').value.id; this.quickWizardService.createQuickDatasetWizard(this.formGroup.value) .pipe(takeUntil(this._destroyed)) .subscribe( - complete => this.onCallbackSuccess() + complete => this.onCallbackSuccess(dmpId) ) } @@ -117,9 +127,9 @@ export class DatasetCreateWizard extends BaseComponent implements OnInit, IBread return this.formGroup.valid; } - onCallbackSuccess(): void { + onCallbackSuccess(dmpId: string): void { this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); - this.router.navigate(['/home']); + this.router.navigate(['/plans/overview/' + dmpId]); } isActive(step: string): boolean { diff --git a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.html b/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.html index c40682feb..13e85e5ae 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.html +++ b/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.html @@ -46,6 +46,7 @@ + {{'QUICKWIZARD.HINT' | translate}} diff --git a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts b/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts index d530c9a6c..20cdcca30 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts +++ b/dmp-frontend/src/app/ui/quick-wizard/dataset-editor/dataset-editor-wizard.component.ts @@ -19,7 +19,7 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni breadCrumbs: Observable; @Input() formGroup: FormGroup; - @Input() datasetProfile: FormGroup;// DatasetProfileModel; + @Input() datasetProfile: FormGroup; // DatasetProfileModel; @Input() datasetLabel: string; editedDataset: boolean = false; dataset: DatasetDescriptionFormEditorModel; @@ -28,6 +28,8 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni public toggleButton = 0; public _inputValue: string; + isFirst: boolean; + constructor( private datasetWizardService: DatasetWizardService, public language: TranslateService, @@ -44,7 +46,8 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni const length = (this.formGroup.get('datasets').get('datasetsList') as FormArray).length; if (length == 0) { this.lastIndexOfDataset = length; - this.addDataset(); + this.isFirst = true; + this.addDataset(this.isFirst); this.onValChange("dataset"); } }); @@ -56,7 +59,7 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni this.editedDataset = false; this._inputValue = "list"; } else if (event == "add") { - this.addDataset(); + this.addDataset(this.isFirst); this.toggleButton = 2; this._inputValue = "dataset"; } else if (event == "dataset") { @@ -66,7 +69,7 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni } editDataset(index: number) { - this.lastIndexOfDataset = index; + // this.lastIndexOfDataset = index; this.toggleButton = 2; this.editedDataset = true; this._inputValue = "dataset" @@ -80,16 +83,26 @@ export class DatasetEditorWizardComponent extends BaseComponent implements OnIni (this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index); } - addDataset() { + addDataset(isFirst: boolean) { const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray); let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition); let formGroup = dataset.buildForm(); - formGroup.get('datasetLabel').setValue( - this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME') + - this.datasetProfile.value["label"] + - this.language.instant('QUICKWIZARD.CREATE-ADD.CREATE.QUICKWIZARD_CREATE.THIRD-STEP.DATASET-NAME-FOR') + - this.datasetLabel); + if(isFirst) { + formGroup.get('datasetLabel').setValue( + this.datasetProfile.value["label"] + " " + + this.language.instant('GENERAL.NAMES.DATASET') + ); + this.isFirst = false; + } + else { + formGroup.get('datasetLabel').setValue( + this.datasetProfile.value["label"] + " " + + this.language.instant('GENERAL.NAMES.DATASET') + + " (" + + this.lastIndexOfDataset + ")" + ); + } formArray.push(formGroup); this.lastIndexOfDataset = formArray.length - 1; this.editedDataset = true; diff --git a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts index 1d33863e1..462212f43 100644 --- a/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts +++ b/dmp-frontend/src/app/ui/quick-wizard/quick-wizard-editor/quick-wizard-editor.component.ts @@ -135,7 +135,7 @@ export class QuickWizardEditorComponent extends BaseComponent implements OnInit, }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { - this.datasetEditorWizardComponent.addDataset(); + this.datasetEditorWizardComponent.addDataset(false); } else if (result === false) { this.quickWizardService.createQuickWizard(this.formGroup.value) .pipe(takeUntil(this._destroyed)) diff --git a/dmp-frontend/src/app/ui/sidebar/sidebar.component.html b/dmp-frontend/src/app/ui/sidebar/sidebar.component.html index e0e8fa1a2..50156656d 100644 --- a/dmp-frontend/src/app/ui/sidebar/sidebar.component.html +++ b/dmp-frontend/src/app/ui/sidebar/sidebar.component.html @@ -53,7 +53,7 @@ -