diff --git a/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.html b/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.html index 07ebf260fe3efda685b253d84dd32d758a48f4b4..71059655f3ca439e43b422c46a9d4e2fee0c46ac 100644 --- a/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.html +++ b/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.html @@ -49,8 +49,7 @@ <mat-icon>check_circle</mat-icon> <span>{{ "property.details.dialog.button.ok" | translate }}</span> </button> - <button mat-raised-button color="primary" mat-dialog-close - [disabled]="!isDirty" > + <button mat-raised-button color="primary" mat-dialog-close> <mat-icon>cancel</mat-icon> <span>{{ "property.details.dialog.button.cancel" | translate }}</span> </button> diff --git a/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.ts b/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.ts index 834b77646ad3a054b38188b66ea241eb1ecef493..f766d05fea20387a5582efd4d835df9c5d9c0fe3 100644 --- a/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.ts +++ b/smp-angular/src/app/common/dialogs/property-details-dialog/property-details-dialog.component.ts @@ -11,13 +11,13 @@ import { } from "@angular/forms"; import { AlertMessageService -} from "../../../common/alert-message/alert-message.service"; -import {EntityStatus} from "../../../common/enums/entity-status.enum"; +} from "../../alert-message/alert-message.service"; +import {EntityStatus} from "../../enums/entity-status.enum"; import {SmpConstants} from "../../../smp.constants"; import {HttpClient} from "@angular/common/http"; import { HttpErrorHandlerService -} from "../../../common/error/http-error-handler.service"; +} from "../../error/http-error-handler.service"; import { PropertyRo } from "../../../system-settings/admin-properties/property-ro.model"; @@ -57,7 +57,7 @@ export class PropertyDetailsDialogComponent implements OnInit { this.editMode = data.edit; this.propertyType = data.propertyType; this.propertyType = !data.propertyType ? PropertySourceEnum.SYSTEM : data.propertyType; - (async () => await this.updateFormTitle()) (); + (async () => await this.updateFormTitle())(); this.current = this.editMode ? { @@ -80,13 +80,12 @@ export class PropertyDetailsDialogComponent implements OnInit { 'value': new UntypedFormControl({value: ''}), 'valuePattern': new UntypedFormControl({value: ''}), 'errorMessage': new UntypedFormControl({value: ''}), - 'systemDefault': new UntypedFormControl({value: 'true'}), + 'systemDefault': new UntypedFormControl({value: false}), }); this.propertyForm.controls['property'].setValue(this.current.property); this.propertyForm.controls['desc'].setValue(this.current.desc); this.propertyForm.controls['type'].setValue(this.current.type); - this.propertyForm.controls['value'].setValue(this.valueFromPropertyStringValue(this.current.value, this.current.type)); this.propertyForm.controls['valuePattern'].setValue(this.current.valuePattern); this.propertyForm.controls['systemDefault'].setValue(this.current.systemDefault); @@ -96,8 +95,8 @@ export class PropertyDetailsDialogComponent implements OnInit { async updateFormTitle() { this.formTitle = this.editMode - ? await lastValueFrom(this.translateService.get("property.details.dialog.title.edit.mode", {type: this.capitalize(this.propertyType)})) - : await lastValueFrom(this.translateService.get("property.details.dialog.title.new.mode", {type: this.capitalize(this.propertyType)})); + ? await lastValueFrom(this.translateService.get("property.details.dialog.title.edit.mode", {type: this.capitalize(this.propertyType)})) + : await lastValueFrom(this.translateService.get("property.details.dialog.title.new.mode", {type: this.capitalize(this.propertyType)})); } ngOnInit() { @@ -124,7 +123,6 @@ export class PropertyDetailsDialogComponent implements OnInit { let validationObservable = this.http .post<PropertyValidationRo>(SmpConstants.REST_INTERNAL_PROPERTY_VALIDATE, request); - this.showSpinner = true; try { @@ -164,25 +162,32 @@ export class PropertyDetailsDialogComponent implements OnInit { /** * Method casts string value to correct property type for dialog component used for editing. - * @param value - * @param propertyType + * At the moment only BOOLEAN needs to be updated, other types are returned as is. + * @param value - string value + * @param propertyType - property type */ - public valueFromPropertyStringValue(value: string, propertyType: string) { - switch (propertyType) { - case 'BOOLEAN': - return value === 'true'; - default: - return value; + public valueFromPropertyStringValue(value: any, propertyType: string) { + + if (propertyType === 'BOOLEAN') { + // make sure that the value is lower case string! + const valToString = value?.toString().toLowerCase(); + return valToString === 'true' || valToString === '1' || valToString === 'yes'; } + return value; } + /** + * Method casts value to string for property value. At the moment only BOOLEAN needs to be updated. + * @param value - value + * @param propertyType - property type + */ public valueToPropertyStringValue(value: string, propertyType: string) { - switch (propertyType) { - case 'BOOLEAN': - return value === 'true'; - default: - return value; + if (propertyType === 'BOOLEAN') { + // make sure that the value is lower case string! + const valToString = value?.toString().toLowerCase(); + return valToString === 'true' || valToString === '1' || valToString === 'yes' ? 'true' : 'false'; } + return value; } getInputType(propertyType: string) { @@ -235,7 +240,7 @@ export class PropertyDetailsDialogComponent implements OnInit { public getCurrent(): PropertyRo { this.current.status = EntityStatus.UPDATED; - this.current.value = this.propertyForm.value['value']; + this.current.value = this.valueToPropertyStringValue(this.propertyForm.value['value'], this.current.type); this.current.systemDefault = this.propertyForm.value['systemDefault']; return this.current; } @@ -245,21 +250,22 @@ export class PropertyDetailsDialogComponent implements OnInit { } get isSystemDefault(): boolean { - let systemDefault = this.propertyForm.value['systemDefault']; - return systemDefault; + return this.propertyForm.value['systemDefault']; } /** * Method updates the state of the value field based on the system default checkbox. */ updateValueState(): void { + let value; if (!this.isDomainProperty || !this.isSystemDefault) { + value = this.valueFromPropertyStringValue(this.current.value, this.current.type); this.propertyForm.controls['value'].enable(); - this.propertyForm.controls['value'].setValue(this.current.value); } else { - this.propertyForm.controls['value'].setValue(this.current.systemDefaultValue); + value = this.valueFromPropertyStringValue(this.current.systemDefaultValue, this.current.type); this.propertyForm.controls['value'].disable(); } + this.propertyForm.controls['value'].setValue(value); } get isDomainProperty(): boolean { diff --git a/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.html b/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.html index d231650c1ffa3495f680654bdcc587e6caeeee66..a852c864c2988cff7dbfc87921924d0b8801fcee 100644 --- a/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.html +++ b/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.html @@ -7,6 +7,8 @@ <input id="name_id" type="text" matInput formControlName="name" required> <mat-hint >{{ "group.dialog.hint.group.name" | translate }}</mat-hint> + <smp-field-error *ngIf="inputDataError('name', 'maxlength')">{{ "group.dialog.error.group.name.length" | translate }} + </smp-field-error > </mat-form-field> <mat-form-field style="width: 100%"> diff --git a/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.ts b/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.ts index 3a887d49be5811aae83684de9f4b448ba368bcfe..7bb18b0fb79550aec3c14b84941a9e43dbff710e 100644 --- a/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.ts +++ b/smp-angular/src/app/edit/edit-domain/domain-group-panel/group-dialog/group-dialog.component.ts @@ -1,6 +1,6 @@ import {Component, Inject, Input} from '@angular/core'; import {MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; -import {FormBuilder, FormControl, FormGroup} from "@angular/forms"; +import {FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms"; import {DomainRo} from "../../../../common/model/domain-ro.model"; import {AlertMessageService} from "../../../../common/alert-message/alert-message.service"; import {VisibilityEnum} from "../../../../common/enums/visibility.enum"; @@ -38,7 +38,7 @@ export class GroupDialogComponent { this._currentDomain = data.domain; this.groupForm = formBuilder.group({ - 'name': new FormControl({value: null}), + 'name': new FormControl({value: null}, Validators.maxLength(512)), 'description': new FormControl({value: null}), 'visibility': new FormControl({value: null}), '': new FormControl({value: null}) @@ -117,7 +117,10 @@ export class GroupDialogComponent { }, (error) => { this.alertService.error(error.error?.errorDescription) }); + } + public inputDataError = (controlName: string, errorName: string) => { + return this.groupForm.controls[controlName].hasError(errorName); } public saveGroup(group: GroupRo) { diff --git a/smp-angular/src/assets/i18n/en.json b/smp-angular/src/assets/i18n/en.json index baf7e2719b59ac13c0166c3d7d4e97c40685b4d9..5ad2da014c6803854d2b179244906d986714d664 100644 --- a/smp-angular/src/assets/i18n/en.json +++ b/smp-angular/src/assets/i18n/en.json @@ -246,6 +246,7 @@ "group.dialog.label.group.visibility": "Group visibility", "group.dialog.placeholder.group.visibility": "Group visibility", "group.dialog.tooltip.group.visibility": "Group visibility.", + "group.dialog.error.group.name": "Group name must not be empty and shorter than 512 characters.", "domain.group.button.create": "Create", "domain.group.button.delete": "Delete", "domain.group.button.edit": "Edit data", diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/DBDomainConfToDomainPropROConverter.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/DBDomainConfToDomainPropROConverter.java index 8a7ea6735afc0965a218da54d1e8ee2e64103537..63c2d9b852d7b045595d4f53f2c1d7cada9034ef 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/DBDomainConfToDomainPropROConverter.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/conversion/DBDomainConfToDomainPropROConverter.java @@ -41,6 +41,7 @@ public class DBDomainConfToDomainPropROConverter implements Converter<DBDomainCo target.setProperty(source.getProperty()); target.setSystemDefault(source.isUseSystemDefault()); target.setValue(source.getValue()); + target.setDesc(source.getDescription()); target.setValuePattern(enumType.getValuePattern().pattern()); target.setType(enumType.getPropertyType().name()); target.setSystemDefaultValue(configurationService.getDefaultDomainConfiguration(enumType)); diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/CommonColumnsLengths.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/CommonColumnsLengths.java index 21ffc472a4ad03f2210173d2e2ec86765f34ce26..bd1c32123bb77c4eab3afaa41d3bca55b3e41881 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/CommonColumnsLengths.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/CommonColumnsLengths.java @@ -21,8 +21,12 @@ package eu.europa.ec.edelivery.smp.data.model; /** * Created by gutowpa on 01/02/2017. + * + * @since 3.0 + * @author Pawel GUTOWSKI */ public class CommonColumnsLengths { + public static final int MAX_DOMAIN_CODE_LENGTH = 256; public static final int MAX_FREE_TEXT_LENGTH = 4000; public static final int MAX_MEDIUM_TEXT_LENGTH = 1024; @@ -36,13 +40,14 @@ public class CommonColumnsLengths { public static final int MAX_SML_SUBDOMAIN_LENGTH = 256; public static final int MAX_SML_SMP_ID_LENGTH = 256; public static final int MAX_USER_ROLE_LENGTH = 256; - public static final int MAX_TEXT_LENGTH_256 = 512; + public static final int MAX_TEXT_LENGTH_256 = 256; public static final int MAX_TEXT_LENGTH_512 = 512; public static final int MAX_TEXT_LENGTH_128 = 128; public static final int MAX_TEXT_LENGTH_64 = 64; - - - - + /** + * Private constructor to prevent instantiation. + */ + private CommonColumnsLengths() { + } } diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBExtension.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBExtension.java index ab596200a43af59104856f1ad70b281590d8ae3f..1d0bf09decf5f0096247008152d1597b20623d32 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBExtension.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBExtension.java @@ -68,7 +68,7 @@ public class DBExtension extends BaseEntity { @Column(name = "DESCRIPTION", length = CommonColumnsLengths.MAX_TEXT_LENGTH_512 ) private String description; - @Column(name = "IMPLEMENTATION_NAME", length = CommonColumnsLengths.MAX_TEXT_LENGTH_256 ) + @Column(name = "IMPLEMENTATION_NAME", length = CommonColumnsLengths.MAX_TEXT_LENGTH_512 ) private String implementationName; diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBResourceDef.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBResourceDef.java index f2721d48c98bf38d0f69ede2ae85b8f8b7aa9737..20ad5bfe7a0c3e0c95361171c594532d2b6efb9e 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBResourceDef.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBResourceDef.java @@ -101,7 +101,7 @@ public class DBResourceDef extends BaseEntity { @ColumnDescription(comment = "resources are published under url_segment.") String urlSegment; - @Column(name = "HANDLER_IMPL_NAME", length = CommonColumnsLengths.MAX_TEXT_LENGTH_256 ) + @Column(name = "HANDLER_IMPL_NAME", length = CommonColumnsLengths.MAX_TEXT_LENGTH_512 ) private String handlerImplementationName; @ManyToOne(fetch = FetchType.LAZY) diff --git a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBSubresourceDef.java b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBSubresourceDef.java index d25ff836c28e4d33cd386fa5da7c351b51a66000..453c9e470028fb112926bf65eb4af4e33cdb7533 100644 --- a/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBSubresourceDef.java +++ b/smp-server-library/src/main/java/eu/europa/ec/edelivery/smp/data/model/ext/DBSubresourceDef.java @@ -76,7 +76,7 @@ public class DBSubresourceDef extends BaseEntity { @ColumnDescription(comment = "Subresources are published under url_segment. It must be unique for resource type") private String urlSegment; - @Column(name = "HANDLER_IMPL_NAME", length = CommonColumnsLengths.MAX_TEXT_LENGTH_256 ) + @Column(name = "HANDLER_IMPL_NAME", length = CommonColumnsLengths.MAX_TEXT_LENGTH_512 ) private String handlerImplementationName; @Override