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) { protected List<Specification> specifications(DmpPropertiesPersist item) {
return Arrays.asList( return Arrays.asList(
this.mapSpec() this.mapSpec()
.iff(() ->!this.isNull(item.getDmpBlueprintValues())) .iff(() ->this.status == DmpStatus.Finalized && !this.isNull(item.getDmpBlueprintValues()))
.on(DmpPropertiesPersist._dmpBlueprintValues) .on(DmpPropertiesPersist._dmpBlueprintValues)
.over(item.getDmpBlueprintValues()) .over(item.getDmpBlueprintValues())
.mapKey((k) -> ((UUID)k).toString()) .mapKey((k) -> ((UUID)k).toString())
.using((itm) -> this.validatorFactory.validator(DmpBlueprintValuePersist.DmpBlueprintValuePersistValidator.class)), .using((itm) -> this.validatorFactory.validator(DmpBlueprintValuePersist.DmpBlueprintValuePersistValidator.class)),
this.navSpec() this.navSpec()
.iff(() -> !this.isListNullOrEmpty(item.getContacts())) .iff(() -> this.status == DmpStatus.Finalized && !this.isListNullOrEmpty(item.getContacts()))
.on(DmpPropertiesPersist._contacts) .on(DmpPropertiesPersist._contacts)
.over(item.getContacts()) .over(item.getContacts())
.using((itm) -> this.validatorFactory.validator(DmpContactPersist.DmpContactPersistValidator.class)) .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 { nameof } from 'ts-simple-nameof';
import { ConfigurationService } from '../configuration/configuration.service'; import { ConfigurationService } from '../configuration/configuration.service';
import { BaseHttpV2Service } from '../http/base-http-v2.service'; import { BaseHttpV2Service } from '../http/base-http-v2.service';
import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status';
@Injectable() @Injectable()
export class DmpBlueprintService { export class DmpBlueprintService {
@ -109,12 +110,13 @@ export class DmpBlueprintService {
valueAssign: (item: DmpBlueprint) => item.id, 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(); const lookup: DmpBlueprintLookup = new DmpBlueprintLookup();
lookup.page = { size: 100, offset: 0 }; lookup.page = { size: 100, offset: 0 };
if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; } if (excludedIds && excludedIds.length > 0) { lookup.excludedIds = excludedIds; }
if (ids && ids.length > 0) { lookup.ids = ids; } if (ids && ids.length > 0) { lookup.ids = ids; }
lookup.isActive = [IsActive.Active]; lookup.isActive = [IsActive.Active];
lookup.statuses = statuses;
lookup.project = { lookup.project = {
fields: [ fields: [
nameof<DmpBlueprint>(x => x.id), nameof<DmpBlueprint>(x => x.id),

View File

@ -55,7 +55,7 @@
<div class="heading2">{{'DMP-EDITOR.FIELDS.BLUEPRINT' | translate}} *</div> <div class="heading2">{{'DMP-EDITOR.FIELDS.BLUEPRINT' | translate}} *</div>
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{'DMP-EDITOR.FIELDS.BLUEPRINT' | translate}}</mat-label> <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> </app-single-auto-complete>
</mat-form-field> </mat-form-field>
</div> </div>
@ -132,7 +132,8 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<div *ngFor="let field of section.fields; let j=index"> <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 *ngIf="field.description != null && field.description.length > 0" class="hint">{{field.description}}</div>
<div class="input-form"> <div class="input-form">
<div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.SYSTEM"> <div *ngIf="field.category === dmpBlueprintSectionFieldCategoryEnum.SYSTEM">
@ -274,7 +275,9 @@
<div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.Date"> <div *ngIf="field.dataType === dmpBlueprintExtraFieldDataTypeEnum.Date">
<mat-form-field class="w-100"> <mat-form-field class="w-100">
<mat-label>{{field.label}}</mat-label> <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('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-error *ngIf="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('fieldValue').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </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 { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { DmpContactType } from '@app/core/common/enum/dmp-contact-type'; import { DmpContactType } from '@app/core/common/enum/dmp-contact-type';
import { MatButtonToggleChange } from '@angular/material/button-toggle'; 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({ @Component({
selector: 'app-dmp-editor', selector: 'app-dmp-editor',
@ -70,6 +72,14 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
dmpAccessTypeEnumValues = this.enumUtils.getEnumValues<DmpAccessType>(DmpAccessType); dmpAccessTypeEnumValues = this.enumUtils.getEnumValues<DmpAccessType>(DmpAccessType);
dmpContactTypeEnum = DmpContactType; dmpContactTypeEnum = DmpContactType;
dmpContactTypeEnumValues = this.enumUtils.getEnumValues<DmpContactType>(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 { protected get canDelete(): boolean {
return !this.isDeleted && !this.isNew && this.hasPermission(this.authService.permissionEnum.DeleteDmp); 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, private configurationService: ConfigurationService,
// public visibilityRulesService: VisibilityRulesService, // public visibilityRulesService: VisibilityRulesService,
private languageInfoService: LanguageInfoService, private languageInfoService: LanguageInfoService,
private enumUtils: EnumUtils, public enumUtils: EnumUtils,
public descriptionTemplateService: DescriptionTemplateService, public descriptionTemplateService: DescriptionTemplateService,
public userService: UserService 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('backendError')">{{form.getError('backendError').message}}</mat-error>
<mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="form.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</mat-form-field> </mat-form-field>
{{form.errors | json}}
<div class="mb-4"> <div class="mb-4">
<span *ngIf="!form.disabled" class="not-found">{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}}</span> <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> <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", "ORGANIZATIONS": "Organizations",
"DATASET-IDENTIFIER": "Dataset Identifier", "DATASET-IDENTIFIER": "Dataset Identifier",
"CURRENCY": "Currency", "CURRENCY": "Currency",
"VALIDATION": "Validator", "VALIDATION": "Validator"
"SELECT": "Select"
}, },
"DATASET-PROFILE-UPLOAD-TYPE": { "DATASET-PROFILE-UPLOAD-TYPE": {
"DOWNLOAD": "Download file" "DOWNLOAD": "Download file"

View File

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