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 0a663a6d2..2e95543bd 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 @@ -4,12 +4,12 @@
- - format_align_left - - + add + + format_align_left +
@@ -43,9 +43,12 @@
- + - +
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 73bd3c06e..0f064a226 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 @@ -13,97 +13,92 @@ import { QuickWizardDatasetDescriptionModel } from "./quick-wizard-dataset-descr import { IfStmt } from "@angular/compiler"; import { TranslateService } from "@ngx-translate/core"; - - - - - - @Component({ - selector: 'app-dataset-editor-wizard-component', - templateUrl: 'dataset-editor-wizard.component.html', - styleUrls: ['./dataset-editor-wizard.component.scss'] + selector: 'app-dataset-editor-wizard-component', + templateUrl: 'dataset-editor-wizard.component.html', + styleUrls: ['./dataset-editor-wizard.component.scss'] }) export class DatasetEditorWizardComponent extends BaseComponent implements OnInit, IBreadCrumbComponent { - breadCrumbs: Observable; + breadCrumbs: Observable; - @Input() formGroup: FormGroup; - @Input() datasetProfile: FormGroup;// DatasetProfileModel; - @Input() datasetLabel: string; - editedDataset: boolean = false; - dataset: DatasetDescriptionFormEditorModel; - public datasetProfileDefinition: DatasetDescriptionFormEditorModel; - public lastIndexOfDataset = 0; - public toggleButton = 0; - public _inputValue: string; + @Input() formGroup: FormGroup; + @Input() datasetProfile: FormGroup;// DatasetProfileModel; + @Input() datasetLabel: string; + editedDataset: boolean = false; + dataset: DatasetDescriptionFormEditorModel; + public datasetProfileDefinition: DatasetDescriptionFormEditorModel; + public lastIndexOfDataset = 0; + public toggleButton = 0; + public _inputValue: string; - constructor( - private datasetWizardService: DatasetWizardService, - public language: TranslateService, - ) { - super(); - } + constructor( + private datasetWizardService: DatasetWizardService, + public language: TranslateService, + ) { + super(); + } + ngOnInit(): void { + this.datasetWizardService.getDefinition(this.datasetProfile.value["id"]) + .pipe(takeUntil(this._destroyed)) + .subscribe(item => { + this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item); + this.onValChange("list"); + const length = (this.formGroup.get('datasets').get('datasetsList') as FormArray).length; + if (length == 0) { + this.lastIndexOfDataset = length; + this.addDataset(); + this.onValChange("dataset"); + } + }); + } - ngOnInit(): void { - this.datasetWizardService.getDefinition(this.datasetProfile.value["id"]) - .pipe(takeUntil(this._destroyed)) - .subscribe(item => { - this.datasetProfileDefinition = new DatasetDescriptionFormEditorModel().fromModel(item); - this.onValChange("list"); - const length = (this.formGroup.get('datasets').get('datasetsList') as FormArray).length; - if (length == 0) { - this.lastIndexOfDataset = length; - this.addDataset(); - this.onValChange("dataset"); - } - }); - } + onValChange(event: any) { + if (event == "list") { + this.toggleButton = 0; + this.editedDataset = false; + this._inputValue = "list"; + } else if (event == "add") { + this.addDataset(); + this.toggleButton = 2; + this._inputValue = "dataset"; + } else if (event == "dataset") { + this.toggleButton = 2; + this._inputValue = "dataset"; + } + } - onValChange(event: any) { - if (event == "list") { - this.toggleButton = 0; - this.editedDataset = false; - this._inputValue = "list"; - } else if (event == "add") { - this.addDataset(); - this.toggleButton = 2; - this._inputValue = "dataset"; - } else if (event == "dataset") { - this.toggleButton = 2; - this._inputValue = "dataset"; - } + editDataset(index: number) { + this.lastIndexOfDataset = index; + this.toggleButton = 2; + this.editedDataset = true; + this._inputValue = "dataset" + } - } - editDataset(index: number) { - this.lastIndexOfDataset = index; - this.toggleButton = 2; - this.editedDataset = true; - this._inputValue = "dataset" - } + deleteDataset(index: number) {//TODO: delete Dataset From List + this.lastIndexOfDataset = index; + this.toggleButton = 0; + this.editedDataset = false; + this._inputValue = "list"; + (this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index); + } - deleteDataset(index: number) {//TODO: delete Dataset From List - this.lastIndexOfDataset = index; - this.toggleButton = 0; - this.editedDataset = false; - this._inputValue = "list"; - (this.formGroup.get('datasets').get('datasetsList') as FormArray).removeAt(index); - } + addDataset() { + const formArray: FormArray = (this.formGroup.get('datasets').get('datasetsList') as FormArray); + let dataset = new QuickWizardDatasetDescriptionModel().fromModel(this.datasetProfileDefinition); + let formGroup = dataset.buildForm(); - addDataset() { - 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); + formArray.push(formGroup); + this.lastIndexOfDataset = formArray.length - 1; + this.editedDataset = true; + } - 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); - formArray.push(formGroup); - this.lastIndexOfDataset = formArray.length - 1; - this.editedDataset = true; - } - - -} \ No newline at end of file + listingMode() { + if (this.toggleButton === 0) return true; + } +}