diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java index 9b4c64840..5da228f05 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/DatasetManager.java @@ -308,7 +308,7 @@ public class DatasetManager { // Iterate through the versions and remove those that are not included in the DMP of the dataset in question. for (DescriptionTemplate version : profileVersions) { for (AssociatedProfile p : dataset.getDmp().getProfiles()) { - if (version.getId().toString().equals(p.getId().toString())) { + if (version.getId().toString().equals(p.getDescriptionTemplateId().toString())) { profileVersionsIncluded.add(version); } } diff --git a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/PrefillingManager.java b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/PrefillingManager.java index 0643ecbe4..a2c7e789b 100644 --- a/dmp-backend/web/src/main/java/eu/eudat/logic/managers/PrefillingManager.java +++ b/dmp-backend/web/src/main/java/eu/eudat/logic/managers/PrefillingManager.java @@ -68,8 +68,8 @@ public class PrefillingManager { public DatasetWizardModel getPrefilledDatasetUsingData(Map data, String configId, UUID profileId) throws Exception { PrefillingConfig prefillingConfig = configLoader.getExternalUrls().getPrefillings().get(configId); PrefillingGet prefillingGet = prefillingConfig.getPrefillingGet(); - DatasetProfile datasetProfile = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId); - return PrefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), datasetProfile, datasetManager, licenseManager); + DescriptionTemplate descriptionTemplate = apiContext.getOperationsContext().getDatabaseRepository().getDatasetProfileDao().find(profileId); + return PrefillingMapper.mapPrefilledEntityToDatasetWizard(data, prefillingGet, prefillingConfig.getType(), descriptionTemplate, datasetManager, licenseManager); } private Map getSingle(String url, String id) { diff --git a/dmp-db-scema/updates/00.00.016_Insert_default_blueprint_and_add_dmpSectionIndex_to datasets.sql b/dmp-db-scema/updates/00.00.016_Insert_default_blueprint_and_add_dmpSectionIndex_to datasets.sql index bb61227b6..f5d549762 100644 --- a/dmp-db-scema/updates/00.00.016_Insert_default_blueprint_and_add_dmpSectionIndex_to datasets.sql +++ b/dmp-db-scema/updates/00.00.016_Insert_default_blueprint_and_add_dmpSectionIndex_to datasets.sql @@ -4,10 +4,10 @@ BEGIN PERFORM * FROM "DBVersion" WHERE version = this_version; IF FOUND THEN RETURN; END IF; -INSERT INTO public."DMPProfile" VALUES ('1374c46d-55b5-472a-8e10-c6ee8c0b5f7f', 'Dmp Default Blueprint', '
',1, now(),now()); -UPDATE public."DMP" SET ("Profile") = '1374c46d-55b5-472a-8e10-c6ee8c0b5f7f' WHERE "Profile" IS NULL; -UPDATE public."Dataset" SET ("DmpSectionIndex") = '3' WHERE "DmpSectionIndex" IS NULL; -UPDATE public."DMPDatasetProfile" SET ("data") = '{"dmpSectionIndex":[3]}' WHERE "data" IS NULL; +INSERT INTO public."DMPProfile" VALUES ('86635178-36a6-484f-9057-a934e4eeecd5', 'Dmp Default Blueprint', '
',1, now(),now()); +UPDATE public."DMP" SET "Profile" = '86635178-36a6-484f-9057-a934e4eeecd5' WHERE "Profile" IS NULL; +UPDATE public."Dataset" SET "DmpSectionIndex" = '3' WHERE "DmpSectionIndex" IS NULL; +UPDATE public."DMPDatasetProfile" SET "data" = '{"dmpSectionIndex":[3]}' WHERE "data" IS NULL; ALTER TABLE public."Dataset" ALTER COLUMN "DmpSectionIndex" SET NOT NULL; diff --git a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html index d0b819ce2..b35b6b4c8 100644 --- a/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html +++ b/dmp-frontend/src/app/ui/dashboard/drafts/drafts.component.html @@ -102,7 +102,7 @@
-
{{'DATASET-LISTING.DATASET-DESCRIPTION' | translate}}
+
{{'DATASET-LISTING.DESCRIPTION' | translate}}
{{'DATASET-LISTING.STATES.EDITED' | translate}}: {{activity.modified | dateTimeCultureFormatter: "d MMMM y"}}
{{'DATASET-LISTING.STATES.PUBLISHED' | translate}}: {{activity.publishedAt | dateTimeCultureFormatter: "d MMMM y"}}
@@ -125,7 +125,7 @@
-
+

or continue with

@@ -303,7 +303,7 @@
Description templates
{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}} - + {{formGroup.get('profiles').getError('backendError').message}} diff --git a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts index b77b73ca1..cd27eceb3 100644 --- a/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts +++ b/dmp-frontend/src/app/ui/dmp/dmp-editor-blueprint/dmp-editor-blueprint.component.ts @@ -125,6 +125,8 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im profilesAutoCompleteConfiguration: MultipleAutoCompleteConfiguration; + readonly defaultBlueprintId = '86635178-36a6-484f-9057-a934e4eeecd5'; + constructor( private dmpProfileService: DmpProfileService, private authService: AuthService, @@ -414,7 +416,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im } selectDefaultBlueprint() { - this.dmpProfileService.getSingleBlueprint('86635178-36a6-484f-9057-a934e4eeecd5') + this.dmpProfileService.getSingleBlueprint(this.defaultBlueprintId) .pipe(takeUntil(this._destroyed)) .subscribe(result => { this.selectedDmpBlueprintDefinition = result.definition; @@ -455,8 +457,8 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im document.getElementById('editor-form').scrollTop = 0; } - hasProfile(): boolean { - return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.length > 0; + hasProfile(sectionIndex: number): boolean { + return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.filter(x => x.data.dmpSectionIndex.includes(sectionIndex)).length > 0; } addDataset(dmpSectionIndex: number) { @@ -967,11 +969,11 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im return false; } - onRemoveTemplate(event) { + onRemoveTemplate(event, sectionIndex: number) { let found = false; - const profiles = this.formGroup.get('profiles').value; + let profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[]; this.formGroup.get('datasets')['controls'].forEach(element => { - if (element.get('profile').value.id === event.id) { + if ((element.get('profile').value.id === event.id) && (element.get('dmpSectionIndex').value === sectionIndex)) { found = true; this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Success); } @@ -988,9 +990,33 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im }; } + else{ + this.sectionTemplates[sectionIndex] = this.sectionTemplates[sectionIndex].filter(sectionProfile => sectionProfile.id !== event.id); + profiles = profiles.filter(sectionProfile => sectionProfile.descriptionTemplateId !== event.id); + this.formGroup.get('profiles').setValue(profiles); + } } - onPreviewTemplate(event) { + addProfile(event, sectionIndex: number) { + const profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[]; + let found = profiles.find((value) => value.id === event.id); + if(found !== undefined) { + if(found.data.dmpSectionIndex.indexOf(sectionIndex) === -1){ + found.data.dmpSectionIndex.push(sectionIndex); + } + else{ + this.sectionTemplates[sectionIndex].pop(); + } + } + else{ + let dmpDatasetProfileSection: DmpDatasetProfileSectionsFormModel = new DmpDatasetProfileSectionsFormModel(); + dmpDatasetProfileSection.dmpSectionIndex = [sectionIndex]; + profiles.push({id: null, descriptionTemplateId: event.id, label: event.label, data: dmpDatasetProfileSection}); + } + this.formGroup.get('profiles').setValue(profiles); + } + + onPreviewTemplate(event, sectionIndex: number) { const dialogRef = this.dialog.open(DatasetPreviewDialogComponent, { width: '590px', minHeight: '200px', @@ -1002,9 +1028,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im }); dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => { if (result) { - let profiles = this.formGroup.get('profiles').value; - profiles.push(event); - this.formGroup.get('profiles').setValue(profiles); + this.addProfile(event, sectionIndex); 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))), @@ -1018,22 +1042,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im } onOptionSelected(event, sectionIndex: number){ try{ - const profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[]; - let found = profiles.find((value) => value.id === event.id); - if(found !== undefined) { - if(found.data.dmpSectionIndex.indexOf(sectionIndex) === -1){ - found.data.dmpSectionIndex.push(sectionIndex); - } - else{ - this.sectionTemplates[sectionIndex].pop(); - } - } - else{ - let dmpDatasetProfileSection: DmpDatasetProfileSectionsFormModel = new DmpDatasetProfileSectionsFormModel(); - dmpDatasetProfileSection.dmpSectionIndex = [sectionIndex]; - profiles.push({id: null, descriptionTemplateId: event.id, label: event.label, data: dmpDatasetProfileSection}); - } - this.formGroup.get('profiles').setValue(profiles); + this.addProfile(event, sectionIndex); // const profileCounts: Map = new Map(); // profiles.forEach((value) => profileCounts.set(value.id, (profileCounts.get(value.id) !== undefined ? profileCounts.get(value.id): 0 ) + 1)); // const duplicateProfiles = profiles.filter((value) => { diff --git a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts index e06095ce6..c9afb34ed 100644 --- a/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts +++ b/dmp-frontend/src/app/ui/dmp/editor/funding-info/funding-info.component.ts @@ -417,7 +417,7 @@ export class FundingInfoComponent extends BaseComponent implements OnInit { funderValueChanged(funder: any) { if ((funder.label !== "" && funder.label !== null && funder.label !== undefined && !isNullOrUndefined(funder.reference) && funder.reference.length ) || (funder.existFunder !== null && funder.existFunder !== undefined && funder.existFunder.id !== undefined)) { - this.grantformGroup.reset(); + //this.grantformGroup.reset(); this.grantformGroup.enable(); this.setGrantValidators(); } else {