This commit is contained in:
Diamantis Tziotzios 2024-01-24 14:47:37 +02:00
parent 83342f5afa
commit 192220161b
5 changed files with 22 additions and 25 deletions

View File

@ -1047,8 +1047,6 @@ public class WordBuilder {
} }
this.replaceTextSegment(p, "'{ARGOS.DMP.ORGANIZATIONS}'", organisationsNames, 15); this.replaceTextSegment(p, "'{ARGOS.DMP.ORGANIZATIONS}'", organisationsNames, 15);
this.replaceTextSegment(p, "'{ARGOS.DMP.DESCRIPTION}'", "dfdsfsdf");
if(this.textSegmentExists(p,"'{ARGOS.DMP.DESCRIPTION}'")) { if(this.textSegmentExists(p,"'{ARGOS.DMP.DESCRIPTION}'")) {
descrParPos = parPos; descrParPos = parPos;
descrPar = p; descrPar = p;

View File

@ -37,5 +37,6 @@ export interface MultipleAutoCompleteConfiguration {
autoSelectFirstOptionOnBlur?: boolean; autoSelectFirstOptionOnBlur?: boolean;
appendClassToItem?: {class: string, applyFunc: (item:any) => boolean}[]; appendClassToItem?: {class: string, applyFunc: (item:any) => boolean}[];
canRemoveItem?: (selectedItem: any) => boolean;
} }

View File

@ -483,6 +483,10 @@ export class MultipleAutoCompleteComponent extends _CustomComponentMixinBase imp
if (event != null) { if (event != null) {
event.stopPropagation(); event.stopPropagation();
} }
if (this.configuration.canRemoveItem != null && !this.configuration.canRemoveItem(item)) {
event.stopPropagation();
return;
}
const valueToDelete = this._valueToAssign(item); const valueToDelete = this._valueToAssign(item);
this.value = this.value.filter(x => this.stringify(x) !== this.stringify(valueToDelete)); //TODO, maybe we need to implement equality here differently. this.value = this.value.filter(x => this.stringify(x) !== this.stringify(valueToDelete)); //TODO, maybe we need to implement equality here differently.
this.optionRemoved.emit(item); this.optionRemoved.emit(item);

View File

@ -156,7 +156,7 @@
</div> </div>
<div *ngIf="field.type == 2"> <div *ngIf="field.type == 2">
<mat-form-field> <mat-form-field>
<mat-label>{{'DMP-EDITOR.PLACEHOLDER.RESEARCHERS' | translate}}</mat-label> <mat-label>{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.PLACEHOLDER.RESEARCHERS' | translate)}}</mat-label>
<app-multiple-auto-complete [formControl]="formGroup.get('researchers')" [configuration]="researchersAutoCompleteConfiguration"> <app-multiple-auto-complete [formControl]="formGroup.get('researchers')" [configuration]="researchersAutoCompleteConfiguration">
</app-multiple-auto-complete> </app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('researchers').hasError('backendError')"> <mat-error *ngIf="formGroup.get('researchers').hasError('backendError')">
@ -174,7 +174,7 @@
</div> </div>
<div *ngIf="field.type == 3"> <div *ngIf="field.type == 3">
<mat-form-field> <mat-form-field>
<mat-label>{{'DMP-EDITOR.PLACEHOLDER.ORGANIZATION' | translate}}</mat-label> <mat-label>{{field?.placeholder?.length > 0 ? field.placeholder : ('DMP-EDITOR.PLACEHOLDER.ORGANIZATION' | translate)}}</mat-label>
<app-multiple-auto-complete [formControl]="formGroup.get('organisations')" [configuration]="organisationsAutoCompleteConfiguration"> <app-multiple-auto-complete [formControl]="formGroup.get('organisations')" [configuration]="organisationsAutoCompleteConfiguration">
</app-multiple-auto-complete> </app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('organisations').hasError('backendError')"> <mat-error *ngIf="formGroup.get('organisations').hasError('backendError')">

View File

@ -57,6 +57,7 @@ import { GrantEditorModel } from '@app/ui/grant/editor/grant-editor.model';
import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component'; import { CheckDeactivateBaseComponent } from '@app/library/deactivate/deactivate.component';
import { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status'; import { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status';
import { DatasetService } from '@app/core/services/dataset/dataset.service'; import { DatasetService } from '@app/core/services/dataset/dataset.service';
import { runInThisContext } from 'vm';
interface Visible { interface Visible {
value: boolean; value: boolean;
@ -230,7 +231,8 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
displayFn: (item) => item['label'], displayFn: (item) => item['label'],
titleFn: (item) => item['label'], titleFn: (item) => item['label'],
subtitleFn: (item) => item['description'], subtitleFn: (item) => item['description'],
popupItemActionIcon: 'visibility' popupItemActionIcon: 'visibility',
canRemoveItem: (item) => this.canRemoveItem(item)
}; };
} }
@ -1088,33 +1090,25 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
return false; return false;
} }
onRemoveTemplate(event, sectionIndex: number) { canRemoveItem(item): boolean {
let found = false; let found = false;
let profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[];
this.formGroup.get('datasets')['controls'].forEach(element => { this.formGroup.get('datasets')['controls'].forEach(element => {
if ((element.get('profile').value.id === event.id) && (element.get('dmpSectionIndex').value === sectionIndex)) { if ((element.get('profile').value.id === item.id) && (element.get('dmpSectionIndex').value === (this.step - 1))) {
found = true; found = true;
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Success);
} }
}); });
if (found) { if (found) return false
this.formGroup.get('profiles').setValue(profiles); else return true;
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'
};
}
else { onRemoveTemplate(event, sectionIndex: number) {
let profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[];
this.sectionTemplates[sectionIndex] = this.sectionTemplates[sectionIndex].filter(sectionProfile => sectionProfile.id !== event.id); this.sectionTemplates[sectionIndex] = this.sectionTemplates[sectionIndex].filter(sectionProfile => sectionProfile.id !== event.id);
profiles = profiles.filter(sectionProfile => sectionProfile.descriptionTemplateId !== event.id); profiles = profiles.filter(sectionProfile => sectionProfile.descriptionTemplateId !== event.id || !sectionProfile.data.dmpSectionIndex.includes(sectionIndex));
this.formGroup.get('profiles').setValue(profiles); this.formGroup.get('profiles').setValue(profiles);
} }
}
addProfile(event, sectionIndex: number) { addProfile(event, sectionIndex: number) {
const profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[]; const profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[];