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.DESCRIPTION}'", "dfdsfsdf");
if(this.textSegmentExists(p,"'{ARGOS.DMP.DESCRIPTION}'")) {
descrParPos = parPos;
descrPar = p;

View File

@ -37,5 +37,6 @@ export interface MultipleAutoCompleteConfiguration {
autoSelectFirstOptionOnBlur?: 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) {
event.stopPropagation();
}
if (this.configuration.canRemoveItem != null && !this.configuration.canRemoveItem(item)) {
event.stopPropagation();
return;
}
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.optionRemoved.emit(item);

View File

@ -156,7 +156,7 @@
</div>
<div *ngIf="field.type == 2">
<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>
<mat-error *ngIf="formGroup.get('researchers').hasError('backendError')">
@ -174,7 +174,7 @@
</div>
<div *ngIf="field.type == 3">
<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>
<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 { DmpProfileStatus } from '@app/core/common/enum/dmp-profile-status';
import { DatasetService } from '@app/core/services/dataset/dataset.service';
import { runInThisContext } from 'vm';
interface Visible {
value: boolean;
@ -230,7 +231,8 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
subtitleFn: (item) => item['description'],
popupItemActionIcon: 'visibility'
popupItemActionIcon: 'visibility',
canRemoveItem: (item) => this.canRemoveItem(item)
};
}
@ -1088,32 +1090,24 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
return false;
}
onRemoveTemplate(event, sectionIndex: number) {
canRemoveItem(item): boolean {
let found = false;
let profiles = this.formGroup.get('profiles').value as DmpDatasetProfile[];
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;
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Success);
}
});
if (found) {
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'
};
if (found) return false
else return true;
}
}
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);
}
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);
profiles = profiles.filter(sectionProfile => sectionProfile.descriptionTemplateId !== event.id || !sectionProfile.data.dmpSectionIndex.includes(sectionIndex));
this.formGroup.get('profiles').setValue(profiles);
}
addProfile(event, sectionIndex: number) {
@ -1149,7 +1143,7 @@ export class DmpEditorBlueprintComponent extends CheckDeactivateBaseComponent im
if (result) {
this.addProfile(event, sectionIndex);
const items = this.sectionTemplates[sectionIndex];
items.push({id: event.id, label: event.label, description: ""});
items.push({ id: event.id, label: event.label, description: "" });
this.sectionTemplates[sectionIndex] = [...items];
}
});