small fixes, (wip) remove description template chip from dmp editor

This commit is contained in:
Bernaldo Mihasi 2023-09-13 15:55:38 +03:00
parent cf6e041154
commit b1a832074d
7 changed files with 49 additions and 40 deletions

View File

@ -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);
}
}

View File

@ -68,8 +68,8 @@ public class PrefillingManager {
public DatasetWizardModel getPrefilledDatasetUsingData(Map<String, Object> 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<String, Object> getSingle(String url, String id) {

View File

@ -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', '<root><sections><section id="f94e50e0-cb97-4c65-8b88-e5db6badd41d" label="Main Info" description="A DMP in Argos consists of key information about research, such as purpose, objectives and researchers involved, but also about documentation of research datasets that highlight the steps followed and the means used across data management activities." ordinal="1" hasTemplates="false"><systemFields><systemField id="e62c3fa2-4cbe-41bf-a00e-ad722c7c7da1" type="0" label="Title of DMP" placeholder="Title of DMP" description="" required="true" ordinal="1"></systemField><systemField id="eed2871d-5201-401e-8453-87afbeac77e3" type="1" label="Description" placeholder="Fill with description" description="Briefly describe the context and purpose of the DMP" required="true" ordinal="2"></systemField><systemField id="41a0b1db-b186-467d-8edf-7d3b2456f95e" type="2" label="Researchers" placeholder="Select researchers" description="Add here the names of people that have produced, processed, analysed the data described in the DMP." required="false" ordinal="3"></systemField><systemField id="0f0afb55-a11b-41db-a4d0-67ebb74d8685" type="3" label="Organizations" placeholder="Select organization" description="Add here the names of the organizations contributing to the creation and revision of the DMPs" required="false" ordinal="4"></systemField><systemField id="db493026-3130-4730-9b93-da6b77d2eea4" type="4" label="Language" placeholder="Language" description="Select the language of your DMP" required="true" ordinal="5"></systemField><systemField id="22deb104-1c46-4ea8-8261-8fdc9500dca2" type="5" label="Contact" placeholder="Contact" description="" required="true" ordinal="6"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="3c2608e5-9320-4d94-9ed7-1eab9500d84b" label="Funding" description="Add here information about the scope, funding, actors of your DMP and decide on access and re-use issues for the DMP output that you are creating." ordinal="2" hasTemplates="false"><systemFields><systemField id="527af8fe-27b0-4715-9e1e-35a2fce834a1" type="6" label="Funding organizations" placeholder="Funder" description="Select a funder of your research or add new" required="true" ordinal="1"></systemField><systemField id="4d12904e-2501-4d57-8d2b-1ac795c297e7" type="7" label="Grants" placeholder="Grant" description="Find the grant of your research or add new" required="true" ordinal="2"></systemField><systemField id="82f235c8-98fc-48d1-8245-36ab08f01036" type="8" label="Project" placeholder="Project" description="Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted." required="false" ordinal="3"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="2a77e1f6-9989-4aeb-acd9-48e911a92abd" label="License" description="Each DMP can contain specific license informatation over how much open and available it is, that way you can determine who can see your dataset and for how long that data will be private." ordinal="3" hasTemplates="false"><systemFields><systemField id="75c31705-6731-45dd-9853-75c5d0627439" type="9" label="License" placeholder="License" description="Assign a license to your DMP by selecting the most appropriate from the list." required="false" ordinal="1"></systemField><systemField id="990df932-eae6-44ca-85da-5378b010f439" type="10" label="Access Rights" placeholder="Access Rights" description="Choose how the DMP is displayed after is published on Zenodo. By choosing Open Access, the DMP will be open on Zenodo after the Publication Date. By choosing Restricted Access, the DMP will be restricted after the publication is made." required="false" ordinal="2"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="0db7845b-0e7c-41df-8d91-cbca97995fd5" label="Dataset Info" description="Datasets are documented following pre-defined templates which set the content of dataset descriptions. In Argos, a DMP can contain as many dataset descriptions as the datasets it documents." ordinal="4" hasTemplates="true"><systemFields></systemFields><descriptionTemplates></descriptionTemplates></section></sections></root>',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', '<root><sections><section id="f94e50e0-cb97-4c65-8b88-e5db6badd41d" label="Main Info" description="A DMP in Argos consists of key information about research, such as purpose, objectives and researchers involved, but also about documentation of research datasets that highlight the steps followed and the means used across data management activities." ordinal="1" hasTemplates="false"><systemFields><systemField id="e62c3fa2-4cbe-41bf-a00e-ad722c7c7da1" type="0" label="Title of DMP" placeholder="Title of DMP" description="" required="true" ordinal="1"></systemField><systemField id="eed2871d-5201-401e-8453-87afbeac77e3" type="1" label="Description" placeholder="Fill with description" description="Briefly describe the context and purpose of the DMP" required="true" ordinal="2"></systemField><systemField id="41a0b1db-b186-467d-8edf-7d3b2456f95e" type="2" label="Researchers" placeholder="Select researchers" description="Add here the names of people that have produced, processed, analysed the data described in the DMP." required="false" ordinal="3"></systemField><systemField id="0f0afb55-a11b-41db-a4d0-67ebb74d8685" type="3" label="Organizations" placeholder="Select organization" description="Add here the names of the organizations contributing to the creation and revision of the DMPs" required="false" ordinal="4"></systemField><systemField id="db493026-3130-4730-9b93-da6b77d2eea4" type="4" label="Language" placeholder="Language" description="Select the language of your DMP" required="true" ordinal="5"></systemField><systemField id="22deb104-1c46-4ea8-8261-8fdc9500dca2" type="5" label="Contact" placeholder="Contact" description="" required="true" ordinal="6"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="3c2608e5-9320-4d94-9ed7-1eab9500d84b" label="Funding" description="Add here information about the scope, funding, actors of your DMP and decide on access and re-use issues for the DMP output that you are creating." ordinal="2" hasTemplates="false"><systemFields><systemField id="527af8fe-27b0-4715-9e1e-35a2fce834a1" type="6" label="Funding organizations" placeholder="Funder" description="Select a funder of your research or add new" required="true" ordinal="1"></systemField><systemField id="4d12904e-2501-4d57-8d2b-1ac795c297e7" type="7" label="Grants" placeholder="Grant" description="Find the grant of your research or add new" required="true" ordinal="2"></systemField><systemField id="82f235c8-98fc-48d1-8245-36ab08f01036" type="8" label="Project" placeholder="Project" description="Projects in Argos are perceived as distinct activities falling under a grant or common activities under different grants in collaborative schemas, eg open call for contributions. Please complete it for the grant associated to your organization if your project falls under this category. In all other cases, please leave blank and it will be autocompleted." required="false" ordinal="3"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="2a77e1f6-9989-4aeb-acd9-48e911a92abd" label="License" description="Each DMP can contain specific license informatation over how much open and available it is, that way you can determine who can see your dataset and for how long that data will be private." ordinal="3" hasTemplates="false"><systemFields><systemField id="75c31705-6731-45dd-9853-75c5d0627439" type="9" label="License" placeholder="License" description="Assign a license to your DMP by selecting the most appropriate from the list." required="false" ordinal="1"></systemField><systemField id="990df932-eae6-44ca-85da-5378b010f439" type="10" label="Access Rights" placeholder="Access Rights" description="Choose how the DMP is displayed after is published on Zenodo. By choosing Open Access, the DMP will be open on Zenodo after the Publication Date. By choosing Restricted Access, the DMP will be restricted after the publication is made." required="false" ordinal="2"></systemField></systemFields><descriptionTemplates></descriptionTemplates></section><section id="0db7845b-0e7c-41df-8d91-cbca97995fd5" label="Dataset Info" description="Datasets are documented following pre-defined templates which set the content of dataset descriptions. In Argos, a DMP can contain as many dataset descriptions as the datasets it documents." ordinal="4" hasTemplates="true"><systemFields></systemFields><descriptionTemplates></descriptionTemplates></section></sections></root>',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;

View File

@ -102,7 +102,7 @@
<!-- <a (click)="redirect(activity.id, activity.type)" class="pointer"> -->
<a [routerLink]="navigateToUrl(activity.id, activity.type)" class="pointer">
<div class="d-flex flex-direction-row">
<div class="col-auto dataset-label">{{'DATASET-LISTING.DATASET-DESCRIPTION' | translate}}</div>
<div class="col-auto dataset-label">{{'DATASET-LISTING.DESCRIPTION' | translate}}</div>
<div *ngIf="!publicMode" class="col-auto ml-auto edited-date">{{'DATASET-LISTING.STATES.EDITED' | translate}}: {{activity.modified | dateTimeCultureFormatter: "d MMMM y"}}</div>
<div *ngIf="publicMode" class="col-auto ml-auto edited-date">{{'DATASET-LISTING.STATES.PUBLISHED' | translate}}: {{activity.publishedAt | dateTimeCultureFormatter: "d MMMM y"}}</div>
</div>
@ -125,7 +125,7 @@
<div class="dataset-card-actions">
<a class="col-auto border-right pointer" [matMenuTriggerFor]="exportMenu"><span class="material-icons icon-align pr-2">open_in_new</span>{{'DATASET-LISTING.ACTIONS.EXPORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="openShareDialog(getDmpId(activity), getDmp(activity))"><span class="material-icons icon-align pr-2">group_add</span>{{'DATASET-LISTING.ACTIONS.INVITE-SHORT' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="openDmpSearchDialogue(activity)"><span class="material-icons icon-align pr-2">file_copy</span>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="openDmpSearchDialogue(activity)"><span class="material-icons icon-align pr-2">file_copy</span>{{'DATASET-WIZARD.ACTIONS.COPY-DESCRIPTION' | translate}}</a>
<a class="col-auto border-right pointer" *ngIf="isAuthenticated()" (click)="deleteDatasetClicked(activity.id)"><span class="material-icons icon-align pr-2">delete</span>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}</a>
<!-- <a class="col-auto pointer" [matMenuTriggerFor]="actionsMenu"><span class="material-icons icon-align pl-2">more_horiz</span></a> -->
@ -133,7 +133,7 @@
</div>
<mat-menu #actionsMenu="matMenu">
<button mat-menu-item (click)="openDmpSearchDialogue(activity)" class="menu-item">
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DATASET' | translate}}
<mat-icon>file_copy</mat-icon>{{'DATASET-WIZARD.ACTIONS.COPY-DESCRIPTION' | translate}}
</button>
<button mat-menu-item (click)="deleteDatasetClicked(activity.id)" class="menu-item">
<mat-icon>delete</mat-icon>{{ 'DATASET-WIZARD.ACTIONS.DELETE' | translate }}

View File

@ -51,7 +51,7 @@
</div>
</li>
</ol>
<ul *ngIf="hasProfile()" class="add-dataset-option">
<ul *ngIf="hasProfile(i)" class="add-dataset-option">
<li>
<a class="add-dataset-action" (click)="addDataset(i)">
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DESCRIPTION-SHORT' | translate}}
@ -112,7 +112,7 @@
<div class="col-5">
<button mat-button class="action-btn" [disabled]="selectedDmpBlueprintDefinition == null" (click)="selectBlueprint()">Next</button>
</div>
<div class="col-7" *ngIf="formGroup.get('profile').value == null || (formGroup.get('profile').value && formGroup.get('profile').value.id !== '86635178-36a6-484f-9057-a934e4eeecd5')">
<div class="col-7" *ngIf="formGroup.get('profile').value == null || (formGroup.get('profile').value && formGroup.get('profile').value.id !== defaultBlueprintId)">
<div class="row">
<div class="col-6">
<p>or continue with</p>
@ -303,7 +303,7 @@
<div class="heading">Description templates</div>
<mat-form-field>
<mat-label>{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}</mat-label>
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}" [hidePlaceholder]="true" required='true' [value]="sectionTemplates[section.ordinal - 1]" [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event)" (optionActionClicked)="onPreviewTemplate($event)" (optionSelected)="onOptionSelected($event, i)">
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}" [hidePlaceholder]="true" required='true' [value]="sectionTemplates[section.ordinal - 1]" [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event, i)" (optionActionClicked)="onPreviewTemplate($event, i)" (optionSelected)="onOptionSelected($event, i)">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>

View File

@ -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,36 +990,14 @@ 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) {
const dialogRef = this.dialog.open(DatasetPreviewDialogComponent, {
width: '590px',
minHeight: '200px',
restoreFocus: false,
data: {
template: event
},
panelClass: 'custom-modalbox'
});
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.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'],
popupItemActionIcon: 'visibility'
};
}
});
}
onOptionSelected(event, sectionIndex: number){
try{
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) {
@ -1034,6 +1014,35 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
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',
restoreFocus: false,
data: {
template: event
},
panelClass: 'custom-modalbox'
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
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))),
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
subtitleFn: (item) => item['description'],
popupItemActionIcon: 'visibility'
};
}
});
}
onOptionSelected(event, sectionIndex: number){
try{
this.addProfile(event, sectionIndex);
// const profileCounts: Map<String, number> = new Map<String, number>();
// profiles.forEach((value) => profileCounts.set(value.id, (profileCounts.get(value.id) !== undefined ? profileCounts.get(value.id): 0 ) + 1));
// const duplicateProfiles = profiles.filter((value) => {

View File

@ -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 {