dmp editor small changes

This commit is contained in:
amentis 2024-01-31 17:07:16 +02:00
parent 8f7a3cf768
commit 6eea7d8088
8 changed files with 31 additions and 15 deletions

View File

@ -70,13 +70,13 @@ public class DmpPropertiesPersist {
protected List<Specification> specifications(DmpPropertiesPersist item) {
return Arrays.asList(
this.mapSpec()
.iff(() ->!this.isNull(item.getDmpBlueprintValues()))
.iff(() ->this.status == DmpStatus.Finalized && !this.isNull(item.getDmpBlueprintValues()))
.on(DmpPropertiesPersist._dmpBlueprintValues)
.over(item.getDmpBlueprintValues())
.mapKey((k) -> ((UUID)k).toString())
.using((itm) -> this.validatorFactory.validator(DmpBlueprintValuePersist.DmpBlueprintValuePersistValidator.class)),
this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getContacts()))
.iff(() -> this.status == DmpStatus.Finalized && !this.isListNullOrEmpty(item.getContacts()))
.on(DmpPropertiesPersist._contacts)
.over(item.getContacts())
.using((itm) -> this.validatorFactory.validator(DmpContactPersist.DmpContactPersistValidator.class))

View File

@ -15,6 +15,7 @@ import { catchError, map } from 'rxjs/operators';
import { nameof } from 'ts-simple-nameof';
import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpV2Service } from '../http/base-http-v2.service';
import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status';
@Injectable()
export class DmpBlueprintService {
@ -109,12 +110,13 @@ export class DmpBlueprintService {
valueAssign: (item: DmpBlueprint) => item.id,
};
private buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[]): DmpBlueprintLookup {
public buildAutocompleteLookup(like?: string, excludedIds?: Guid[], ids?: Guid[], statuses?: DmpBlueprintStatus[]): DmpBlueprintLookup {
const lookup: DmpBlueprintLookup = new DmpBlueprintLookup();
lookup.page = { size: 100, offset: 0 };
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
if (ids && ids.length > 0) { lookup.ids = ids; }
lookup.isActive = [IsActive.Active];
lookup.statuses = statuses;
lookup.project = {
fields: [
nameof<DmpBlueprint>(x => x.id),

View File

@ -55,7 +55,7 @@
<div class="heading2">{{'DMP-EDITOR.FIELDS.BLUEPRINT' | translate}} *</div>
<mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.BLUEPRINT' | translate}}</mat-label>
<app-single-auto-complete [required]="false" [formControl]="formGroup.get('blueprint')" placeholder="{{'DMP-EDITOR.PLACEHOLDER.BLUEPRINT' | translate}}" [configuration]="dmpBlueprintService.singleAutocompleteConfiguration">
<app-single-auto-complete [required]="false" [formControl]="formGroup.get('blueprint')" placeholder="{{'DMP-EDITOR.PLACEHOLDER.BLUEPRINT' | translate}}" [configuration]="singleAutocompleteBlueprintConfiguration">
</app-single-auto-complete>
</mat-form-field>
</div>
@ -132,7 +132,8 @@
<div class="row">
<div class="col-12">
<div *ngFor="let field of section.fields; let j=index">
<div class="heading">{{i + 1}}.{{j + 1}} {{field.label}}<span *ngIf="field.required">*</span></div>
<div class="heading" *ngIf="!field.label && field.category === dmpBlueprintSectionFieldCategoryEnum.SYSTEM">{{i + 1}}.{{j + 1}} {{enumUtils.toDmpBlueprintSystemFieldTypeString(field.systemFieldType)}}<span *ngIf="field.required">*</span></div>
<div class="heading" *ngIf="field.label">{{i + 1}}.{{j + 1}} {{field.label}}<span *ngIf="field.required">*</span></div>
<div *ngIf="field.description != null && field.description.length > 0" class="hint">{{field.description}}</div>
<div class="input-form">
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.SYSTEM">
@ -274,7 +275,9 @@
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.Date">
<mat-form-field class="w-100">
<mat-label>{{field.label}}</mat-label>
<input matInput placeholder="{{field.placeholder ?? field.label}}" type="date" name="value" [formControl]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('fieldValue')" [required]="field.required">
<input matInput placeholder="{{field.placeholder ?? field.label}}" name="value" [formControl]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('fieldValue')" [matDatepicker]="date" [required]="field.required">
<mat-datepicker-toggle matSuffix [for]="date"></mat-datepicker-toggle>
<mat-datepicker #date></mat-datepicker>
<mat-error *ngIf="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('fieldValue').hasError('backendError')">{{formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('fieldValue').getError('backendError').message}}</mat-error>
<mat-error *ngIf="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('fieldValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>

View File

@ -46,6 +46,8 @@ import { UserService } from '@app/core/services/user/user.service';
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { DmpContactType } from '@app/core/common/enum/dmp-contact-type';
import { MatButtonToggleChange } from '@angular/material/button-toggle';
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status';
@Component({
selector: 'app-dmp-editor',
@ -70,6 +72,14 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
dmpAccessTypeEnumValues = this.enumUtils.getEnumValues<DmpAccessType>(DmpAccessType);
dmpContactTypeEnum = DmpContactType;
dmpContactTypeEnumValues = this.enumUtils.getEnumValues<DmpContactType>(DmpContactType);
singleAutocompleteBlueprintConfiguration: SingleAutoCompleteConfiguration = {
initialItems: (data?: any) => this.dmpBlueprintService.query(this.dmpBlueprintService.buildAutocompleteLookup(null, null, null, [DmpBlueprintStatus.Finalized])).pipe(map(x => x.items)),
filterFn: (searchQuery: string, data?: any) => this.dmpBlueprintService.query(this.dmpBlueprintService.buildAutocompleteLookup(searchQuery, null, null, [DmpBlueprintStatus.Finalized])).pipe(map(x => x.items)),
getSelectedItem: (selectedItem: any) => this.dmpBlueprintService.query(this.dmpBlueprintService.buildAutocompleteLookup(null, null, [selectedItem])).pipe(map(x => x.items[0])),
displayFn: (item: DmpBlueprint) => item.label,
titleFn: (item: DmpBlueprint) => item.label,
valueAssign: (item: DmpBlueprint) => item.id,
};
protected get canDelete(): boolean {
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteDmp);
@ -111,7 +121,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
private configurationService: ConfigurationService,
// public visibilityRulesService: VisibilityRulesService,
private languageInfoService: LanguageInfoService,
private enumUtils: EnumUtils,
public enumUtils: EnumUtils,
public descriptionTemplateService: DescriptionTemplateService,
public userService: UserService

View File

@ -5,7 +5,6 @@
<mat-error *ngIf="form.hasError('backendError')">{{form.getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field>
{{form.errors | json}}
<div class="mb-4">
<span *ngIf="!form.disabled" class="not-found">{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}}</span>
<span *ngIf="!form.disabled" class="insert-manually" (click)="addReference($event)">{{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}}</span>

View File

@ -2245,8 +2245,7 @@
"ORGANIZATIONS": "Organizations",
"DATASET-IDENTIFIER": "Dataset Identifier",
"CURRENCY": "Currency",
"VALIDATION": "Validator",
"SELECT": "Select"
"VALIDATION": "Validator"
},
"DATASET-PROFILE-UPLOAD-TYPE": {
"DOWNLOAD": "Download file"

View File

@ -108,6 +108,9 @@ export abstract class BaseEditor<EditorModelType extends BaseEditorModel, Entity
const error: HttpError = this.httpErrorHandlingService.getError(errorResponse);
if (error.statusCode === 400) {
this.editorModel.validationErrorModel.fromJSONObject(errorResponse.error);
if(errorResponse.error.code === 120){
this.uiNotificationService.snackBarNotification(errorResponse.error.error, SnackBarNotificationLevel.Error);
}
this.formService.validateAllFormFields(this.formGroup);
} else {
this.uiNotificationService.snackBarNotification(error.getMessagesString(), SnackBarNotificationLevel.Warning);