diff --git a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts index c368b2638..add6e1cdd 100644 --- a/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts +++ b/dmp-frontend/src/app/core/services/dataset-profile/dataset-profile.service.ts @@ -34,11 +34,11 @@ export class DatasetProfileService extends BaseService { return this.http.post(this.actionUrl + 'addDmp', data); } - updateForm(id, data) { + updateForm(id, data): Observable { return this.http.post(this.actionUrl + 'addDmp/' + id, data); } - getDatasetProfileById(datasetProfileID) { + getDatasetProfileById(datasetProfileID): Observable { return this.http.get(this.actionUrl + 'get/' + datasetProfileID); } diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts index eba315de4..1a771fe4a 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-activity/recent-edited-activity.component.ts @@ -209,7 +209,7 @@ export class RecentEditedActivityComponent extends BaseComponent implements OnIn this.dmpModel.status = DmpStatus.Draft; this.dmpFormGroup = this.dmpModel.buildForm(); if (!isNewVersion) { - this.formGroup.get('label').setValue(dmp.title + " New"); + this.dmpFormGroup.get('label').setValue(dmp.title + " New"); } this.openCloneDialog(isNewVersion); }); diff --git a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts index 3ce6a6d1f..dba7a0808 100644 --- a/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts +++ b/dmp-frontend/src/app/ui/dashboard/recent-edited-dmp-activity/recent-edited-dmp-activity.component.ts @@ -179,7 +179,7 @@ export class RecentEditedDmpActivityComponent extends BaseComponent implements O this.dmpModel.status = DmpStatus.Draft; this.dmpFormGroup = this.dmpModel.buildForm(); if (!isNewVersion) { - this.formGroup.get('label').setValue(dmp.label + " New"); + this.dmpFormGroup.get('label').setValue(dmp.label + " New"); } this.openCloneDialog(isNewVersion); }); diff --git a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html index e77a148d1..e1cb11c34 100644 --- a/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html +++ b/dmp-frontend/src/app/ui/dataset/dataset-wizard/dataset-wizard.component.html @@ -65,7 +65,8 @@ - + + {{profile.label}} 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 e7b219c94..312fea820 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 @@ -3,6 +3,19 @@ {{'DATASET-EDITOR.TITLE.INTRO' | translate}}
+ +
1.0 {{'DATASET-EDITOR.FIELDS.PROFILE' | translate}}*
+
+ + + + {{profile.label}} + + + {{formGroup.get('profile').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}} + +
@@ -13,10 +26,8 @@
- - {{formGroup.get('label').getError('backendError').message}} - - {{'GENERAL.VALIDATION.REQUIRED' | translate}} + {{formGroup.get('label').getError('backendError').message}} + {{'GENERAL.VALIDATION.REQUIRED' | translate}}
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 589ac0b1f..468a423b7 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 @@ -29,6 +29,9 @@ import { DatasetWizardEditorModel, ExternalTagEditorModel } from '@app/ui/datase import { ENTER, COMMA } from '@angular/cdk/keycodes'; import { GuidedTour, Orientation } from '@app/library/guided-tour/guided-tour.constants'; import { GuidedTourService } from '@app/library/guided-tour/guided-tour.service'; +import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration'; +import { DataTableRequest } from '@app/core/model/data-table/data-table-request'; +import { AvailableProfilesComponent } from '../available-profiles/available-profiles.component'; @Component({ @@ -68,6 +71,8 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn @Output() formChanged: EventEmitter = new EventEmitter(); readonly separatorKeysCodes: number[] = [ENTER, COMMA]; + profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + constructor( private datasetWizardService: DatasetWizardService, private route: ActivatedRoute, @@ -98,6 +103,19 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn this.datasetWizardModel = new DatasetWizardEditorModel(); this.registerFormListeners(); + // console.log(this.formGroup); + 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.isNewDataset) { + this.loadDatasetProfiles(); + } + if (this.datasetId) { this.datasetWizardService.getSingle(this.datasetId) .pipe(takeUntil(this._destroyed)) @@ -244,7 +262,7 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn loadDatasetProfiles() { const datasetProfileRequestItem: RequestItem = new RequestItem(); datasetProfileRequestItem.criteria = new DatasetProfileCriteria(); - datasetProfileRequestItem.criteria.id = this.formGroup.get('dmp').value.id; + datasetProfileRequestItem.criteria.id = this.dmpId; if (datasetProfileRequestItem.criteria.id) { this.datasetWizardService.getAvailableProfiles(datasetProfileRequestItem) .pipe(takeUntil(this._destroyed)) @@ -297,4 +315,21 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn hasProfileId(): boolean { return !isNullOrUndefined(this.getProfileId()); } + + filterProfiles(value: string): Observable { + const request = new DataTableRequest(null, null, { fields: ['+label'] }); + const criteria = new DatasetProfileCriteria(); + criteria.like = value; + request.criteria = criteria; + return this.dmpService.searchDMPProfiles(request); + } + allAvailableProfiles(event: MouseEvent) { + event.stopPropagation(); + const dialogRef = this.dialog.open(AvailableProfilesComponent, { + data: { + profiles: this.formGroup.get('profiles') + } + }); + return 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 248ef5755..948d3122e 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 @@ -14,7 +14,7 @@ -
+
{{'DMP-EDITOR.ACTIONS.SAVE' | translate}}
@@ -83,13 +83,22 @@
  • {{'DMP-EDITOR.STEPPER.DATASET' | translate}}
    - check{{'TYPES.DATASET-STATUS.FINALISED' | translate}} + + check{{'TYPES.DATASET-STATUS.FINALISED' | translate}} +
      -
    • {{ dataset.get('label').value }} (8)
    • +
    • {{ dataset.get('label').value }} (9)
    • {{ dataset.get('label').value }}
  • +