From f32a3db3b5984d8d2fded997dae457e223dde0bc Mon Sep 17 00:00:00 2001 From: apapachristou Date: Tue, 8 Sep 2020 16:54:01 +0300 Subject: [PATCH] Adds functionality, remove dataset from dmp editor --- .../dataset-editor-details.component.ts | 1 - .../dataset-info/dataset-info.component.ts | 79 +++++++++---------- .../ui/dmp/editor/dmp-editor.component.html | 7 +- .../ui/dmp/editor/dmp-editor.component.scss | 18 ++++- .../app/ui/dmp/editor/dmp-editor.component.ts | 36 +++++++++ dmp-frontend/src/assets/i18n/en.json | 1 + 6 files changed, 95 insertions(+), 47 deletions(-) diff --git a/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.ts index 1fef2771c..fe0262629 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.ts @@ -115,7 +115,6 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn subtitleFn: (item) => item['description'] }; - // if (this.datasetId) { // this.datasetWizardService.getSingle(this.datasetId) // .pipe(takeUntil(this._destroyed)) diff --git a/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.ts index 62c2c7e22..a7ec8a171 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dataset-info/dataset-info.component.ts @@ -170,49 +170,48 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit { return false; } - dmpValueChanged(dmp: DmpListingModel) { - if (dmp) { - this.formGroup.get('profile').enable(); - this.loadDatasetProfiles(); - } - else { - this.availableProfiles = []; - this.formGroup.get('profile').reset(); - this.formGroup.get('profile').disable(); - this.formGroup.removeControl('datasetProfileDefinition'); - } - } + // dmpValueChanged(dmp: DmpListingModel) { + // if (dmp) { + // this.formGroup.get('profile').enable(); + // this.loadDatasetProfiles(); + // } + // else { + // this.availableProfiles = []; + // this.formGroup.get('profile').reset(); + // this.formGroup.get('profile').disable(); + // this.formGroup.removeControl('datasetProfileDefinition'); + // } + // } - registerFormListeners() { - // this.formGroup.get('datasets')['controls'][0].get('dmp').valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(x => { - // this.dmpValueChanged(x); - // }); - // this.formGroup.get('profile').valueChanges - // .pipe(takeUntil(this._destroyed)) - // .subscribe(x => { - // //this.datasetProfileValueChanged(x); - // }); - } + // registerFormListeners() { + // this.formGroup.get('datasets')['controls'][0].get('dmp').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // this.dmpValueChanged(x); + // }); + // this.formGroup.get('profile').valueChanges + // .pipe(takeUntil(this._destroyed)) + // .subscribe(x => { + // //this.datasetProfileValueChanged(x); + // }); + // } - datasetProfileValueChanged(profiledId: string) { - if (profiledId && profiledId.length > 0) { - this.formGroup.removeControl('datasetProfileDefinition'); - this.getDefinition(); - } - } + // datasetProfileValueChanged(profiledId: string) { + // if (profiledId && profiledId.length > 0) { + // this.formGroup.removeControl('datasetProfileDefinition'); + // this.getDefinition(); + // } + // } - getDefinition() { - // if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; } - this.datasetWizardService.getDefinition(this.formGroup.get('profile').value) - .pipe(takeUntil(this._destroyed)) - .subscribe(item => { - this.formGroup.get('datasets')['controls'][0].datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item); - this.datasetProfileDefinitionModel = this.formGroup.get('datasets')['controls'][0].datasetProfileDefinition; - this.formGroup.addControl('datasetProfileDefinition', this.datasetProfileDefinitionModel.buildForm()); - }); - } + // getDefinition() { + // this.datasetWizardService.getDefinition(this.formGroup.get('profile').value) + // .pipe(takeUntil(this._destroyed)) + // .subscribe(item => { + // this.formGroup.get('datasets')['controls'][0].datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item); + // this.datasetProfileDefinitionModel = this.formGroup.get('datasets')['controls'][0].datasetProfileDefinition; + // this.formGroup.addControl('datasetProfileDefinition', this.datasetProfileDefinitionModel.buildForm()); + // }); + // } onRemoveTemplate(event) { let found = false; diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html index 66e4f68da..da99abc8d 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.html @@ -82,7 +82,10 @@
  • {{'DMP-EDITOR.STEPPER.DATASET-INFO' | translate}}
  • -
    {{'DMP-EDITOR.STEPPER.DATASET' | translate}}
    +
    +
    {{'DMP-EDITOR.STEPPER.DATASET' | translate}}
    + remove_circle_outline +
    check{{'TYPES.DATASET-STATUS.FINALISED' | translate}} @@ -123,7 +126,7 @@ -
    +
    diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss index a2239075e..eb8ae2c58 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.scss @@ -259,6 +259,11 @@ a:hover { max-width: 290px; } +.stepper-list li:hover { + background-color: #ececec; + border-radius: 6px; +} + .stepper-list .active { color: #212121; font-weight: 700; @@ -269,7 +274,7 @@ a:hover { color: #212121; font-weight: 700; opacity: 1; - div { + .label { width: 73px; height: 27px; background-color: #f7dd72; @@ -283,6 +288,9 @@ a:hover { } } +.remove-dataset:hover { + color: rgb(204, 0, 0); +} .stepper-options { // flex-grow: 1; } @@ -307,7 +315,8 @@ a:hover { font-size: 14px; } -.previous, .add-dataset-btn { +.previous, +.add-dataset-btn { color: #212121; background: #f5f5f5 0% 0% no-repeat padding-box; box-shadow: 0px 3px 6px #1e202029; @@ -332,7 +341,8 @@ a:hover { cursor: pointer; } -.previous-disabled, .add-dataset-btn-disabled { +.previous-disabled, +.add-dataset-btn-disabled { border: 1px solid #b5b5b5; color: #b5b5b5 !important; cursor: auto !important; @@ -392,7 +402,7 @@ a:hover { } .add-dataset-option { - list-style-type: none; + list-style-type: none; } // ::ng-deep .mat-tab-labels { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts index 54918fb6c..0c4dd3c51 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/dmp-editor.component.ts @@ -49,6 +49,7 @@ import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-descript import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; import { CloneDialogComponent } from '../clone/clone-dialog/clone-dialog.component'; import { DatasetWizardModel } from '@app/core/model/dataset/dataset-wizard'; +import { DatasetService } from '@app/core/services/dataset/dataset.service'; @Component({ selector: 'app-dmp-editor-component', @@ -97,6 +98,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC constructor( private dmpProfileService: DmpProfileService, private datasetWizardService: DatasetWizardService, + private datasetService: DatasetService, private dmpService: DmpService, private route: ActivatedRoute, private router: Router, @@ -828,6 +830,40 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC this.isDiscarded = false; } + public removeDataset(datasetId: string, index: number) { + const dialogRef = this.dialog.open(ConfirmationDialogComponent, { + maxWidth: '300px', + restoreFocus: false, + data: { + message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'), + confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'), + cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'), + isDeleteConfirmation: true + } + }); + dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { + if (result) { + if (datasetId) { + this.datasetService.delete(datasetId) + .pipe(takeUntil(this._destroyed)) + .subscribe( + complete => { + this.onDeleteCallbackSuccess(); + }, + error => this.onDeleteCallbackError(error) + ); + } + this.formGroup.get('datasets')['controls'].splice(index, 1); + this.step = 0; + } + }); + } + + onDeleteCallbackSuccess(): void { + this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success); + this.dmp.id != null ? this.router.navigate(['/plans', 'edit', this.dmp.id]) : this.router.navigate(['/plans']); + } + // advancedClicked() { // const dialogRef = this.dialog.open(ExportMethodDialogComponent, { // maxWidth: '500px', diff --git a/dmp-frontend/src/assets/i18n/en.json b/dmp-frontend/src/assets/i18n/en.json index 3c480e880..835adea18 100644 --- a/dmp-frontend/src/assets/i18n/en.json +++ b/dmp-frontend/src/assets/i18n/en.json @@ -803,6 +803,7 @@ "SAVE": "Save", "CANCEL": "Cancel", "DELETE": "Delete", + "DELETE-DATASET": "Delete Dataset", "DISCARD": "Discard", "FINALISE": "Finalize", "LOCK": "DMP is locked by another user",