diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html index 4d2ee2618..073ce1794 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.html @@ -6,9 +6,9 @@

1.4 {{'DATASET-EDITOR.FIELDS.TAGS' | translate}}

- -
+ + +
diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts index bbb59b775..8cb03c9e2 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/external-references/dataset-external-references-editor.component.ts @@ -1,4 +1,4 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnInit, Output, EventEmitter } from '@angular/core'; import { FormArray, FormGroup } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; @@ -39,6 +39,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl @Input() formGroup: FormGroup = null; @Input() viewOnly = false; + @Output() formChanged: EventEmitter = new EventEmitter(); readonly separatorKeysCodes: number[] = [ENTER, COMMA]; @@ -47,7 +48,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1), displayFn: (item) => item ? item.name : null, titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') + subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') }; registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { @@ -63,7 +64,7 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl initialItems: (type) => this.searchDatasetExternalDataRepositories('', type), displayFn: (item) => item ? item.name : null, titleFn: (item) => item ? item.name : null, - subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') + subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE') }; servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = { @@ -109,11 +110,17 @@ export class DatasetExternalReferencesEditorComponent extends BaseComponent impl this.externalSourcesConfiguration.registries.push({ key: '', label: 'All' }); this.externalSourcesConfiguration.services.push({ key: '', label: 'All' }); if (!isNullOrUndefined(this.externalSourcesConfiguration.tags)) { - this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' }); + this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' }); } else { this.externalSourcesConfiguration.tags = [{ key: '', label: 'All' }]; } }); + + this.formGroup.valueChanges + .pipe(takeUntil(this._destroyed)) + .subscribe(val => { + this.formChanged.emit(val); + }); } public cancel(): void { diff --git a/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.html b/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.html index 6687b27cd..4dd1d0fab 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.html +++ b/dmp-frontend/src/app/ui/dmp/editor/dataset-editor-details/dataset-editor-details.component.html @@ -51,8 +51,8 @@
- - + + 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 80efe116f..9f984e848 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 @@ -223,6 +223,10 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn }); } + onFormChanged(event) { + this.formChanged.emit(event); + } + getDefinition(profileId: string) { // if (this.formGroup.invalid) { setTimeout(() => this.stepper.selectedIndex = 0); return; } this.datasetWizardService.getDefinition(profileId) 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 1fa7b59d2..e364e83cf 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 @@ -17,7 +17,7 @@ import { DmpProfileDefinition } from '@app/core/model/dmp-profile/dmp-profile'; import { DmpProfileService } from '@app/core/services/dmp/dmp-profile.service'; import { AvailableProfilesComponent } from '../available-profiles/available-profiles.component'; import { DmpEditorModel } from '../dmp-editor.model'; -import { Router } from '@angular/router'; +import { Router, Params, ActivatedRoute } from '@angular/router'; import { RequestItem } from '@app/core/query/request-item'; import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-wizard.service'; import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model'; @@ -35,6 +35,7 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit { // @Input() datasetFormGroup: FormGroup = null; @Input() isUserOwner: boolean; @Input() dmp: DmpEditorModel; + @Input() hasDmpId: boolean; @Input() isPublic: boolean; @Input() isFinalized: boolean; @Input() isNewVersion: boolean; @@ -57,7 +58,8 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit { private dialog: MatDialog, private _service: DmpService, private dmpProfileService: DmpProfileService, - private router: Router + private router: Router, + private route: ActivatedRoute ) { super(); } @@ -85,6 +87,16 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit { this.formGroup.get('extraProperties').get('publicDate').patchValue(new Date()); } + if (this.hasDmpId) { + this.loadDatasetProfiles(); + this.profilesAutoCompleteConfiguration = { + filterFn: this.filterProfiles.bind(this), + initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))), + displayFn: (item) => item['label'], + titleFn: (item) => item['label'], + subtitleFn: (item) => item['description'] + }; + } if (this.formGroup.get('datasets')['controls'][0]) { this.formGroup.get('datasets')['controls'][0].get('dmp').valueChanges.pipe(takeUntil(this._destroyed)) .subscribe(x => { 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 6aa571842..248ef5755 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 @@ -47,7 +47,8 @@
-
{{'DMP-EDITOR.TITLE.CREATE-DATASET' | translate}}
+
{{'DMP-EDITOR.TITLE.CREATE-DATASET' | translate}}
+
{{'DMP-EDITOR.TITLE.ADD-DATASET' | translate}} {{formGroup.get('datasets')['controls'][0].get('dmp').value.label}}
@@ -110,11 +111,11 @@ - - + +
- +
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 d6be86b0b..7e766c162 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 @@ -1,6 +1,6 @@ import { Component, OnInit, SimpleChanges } from '@angular/core'; -import { FormGroup, AbstractControl, FormControl, FormArray } from '@angular/forms'; +import { FormGroup, AbstractControl, FormControl, FormArray, FormBuilder } from '@angular/forms'; import { MatDialog } from '@angular/material/dialog'; import { ActivatedRoute, Params, Router } from '@angular/router'; import { DmpStatus } from '@app/core/common/enum/dmp-status'; @@ -65,6 +65,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC hasChanges = false; isDiscarded = false; isNewDataset = false; + hasDmpId = false; isUserOwner: boolean = true; dmp: DmpEditorModel; @@ -73,6 +74,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC formGroupRawValue: any; datasetId: string = null; datasets = new FormArray([]); + datasetWizardEditorModel: DatasetWizardEditorModel; createNewVersion; associatedUsers: Array; @@ -108,7 +110,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC } ngOnInit() { - if (this.router.url.toString().localeCompare('/new/dataset') === 0) { + if (this.router.url.toString().includes('/new/dataset')) { this.isNewDataset = true; this.stepsBeforeDatasets = 2; this.maxStep = 2; @@ -120,6 +122,7 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC const publicId = params['publicId']; const queryParams = this.route.snapshot.queryParams; const tabToNav = queryParams['tab']; + const dmpId = params['dmpId']; this.datasetId = queryParams['dataset']; // if (queryParams['step']) { this.step = queryParams['step']; } @@ -273,17 +276,34 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC this.dmp.extraProperties = new ExtraPropertiesFormModel(); this.dmp.extraProperties.visible = false; this.dmp.extraProperties.contact = this.authService.current().id; - const datasetWizardEditorModel = new DatasetWizardEditorModel(); - // this.datasetFormGroup = datasetWizardEditorModel.buildForm(); + this.datasetWizardEditorModel = new DatasetWizardEditorModel(); - // datasetWizardEditorModel.datasetProfileDefinition = new DatasetDescriptionFormEditorModel(); - this.dmp.datasets.push(datasetWizardEditorModel); - this.formGroup = this.dmp.buildForm(); + if (dmpId) { + this.hasDmpId = true; + this.dmpService.getSingle(dmpId).pipe(map(data => data as DmpModel)) + .pipe(takeUntil(this._destroyed)) + .subscribe(data => { + setTimeout(() => { + this.datasetWizardEditorModel.dmp = data; + this.dmp.datasets.push(this.datasetWizardEditorModel); + this.formGroup = this.dmp.buildForm(); + this.formGroup.get('datasets')['controls'][0].get('dmp').disable(); - this.datasets = this.formGroup.get('datasets') as FormArray; - this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); - // this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.get('datasets')['controls'][0].getRawValue())); - this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; + this.datasets = this.formGroup.get('datasets') as FormArray; + this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; + // this.loadDatasetProfiles(); + // this.registerFormListeners(); + }); + }); + + } else { + this.dmp.datasets.push(this.datasetWizardEditorModel); + this.formGroup = this.dmp.buildForm(); + this.datasets = this.formGroup.get('datasets') as FormArray; + this.formGroupRawValue = JSON.parse(JSON.stringify(this.formGroup.getRawValue())); + this.maxStep = this.formGroup.get('datasets') ? this.maxStep + this.formGroup.get('datasets').value.length - 1 : this.maxStep; + } this.registerFormEventsForNewItem(); } else { @@ -742,11 +762,20 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC public discardChanges() { this.isDiscarded = true; this.hasChanges = false; - if (this.isNewDataset) { + if (this.isNewDataset && !this.hasDmpId) { this.formGroup.get('datasets')['controls'].forEach(element => { element.removeControl('datasetProfileDefinition'); }); this.formGroup.reset(); + } else if (this.hasDmpId) { + Object.keys(this.formGroup.get('datasets')['controls'][0].controls).forEach((key: string) => { + if (key === 'datasetProfileDefinition') { + this.formGroup.get('datasets')['controls'][0].removeControl(key); + } + if (key !== 'dmp' && key !== 'datasetProfileDefinition') { + this.formGroup.get('datasets')['controls'][0].get(key).reset(); + } + }); } else { this.formGroup.patchValue(JSON.parse(JSON.stringify(this.formGroupRawValue))); } diff --git a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html index 044eb1ccc..2e3b2c86d 100644 --- a/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html +++ b/dmp-frontend/src/app/ui/dmp/listing/listing-item/dmp-listing-item.component.html @@ -29,7 +29,8 @@
open_in_new{{'DMP-LISTING.ACTIONS.EXPORT' | translate}} - add{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}} + add{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}} + group_add{{'DMP-LISTING.ACTIONS.INVITE-SHORT' | translate}} filter_none{{'DMP-LISTING.ACTIONS.CLONE' | translate}} more_horiz diff --git a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.html b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.html index 48c017bda..d92f20cbe 100644 --- a/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.html +++ b/dmp-frontend/src/app/ui/misc/dataset-description-form/components/form-section/form-section.component.html @@ -29,6 +29,7 @@ [isChild]="true" [showDelete]="true">
+ {{compositeFieldFormGroup.get('multiplicity').value | json}}