Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS will be completely phased out by mid-2025. To see alternatives please check here

Skip to content
Snippets Groups Projects
Commit 86076590 authored by Joze RIHTARSIC's avatar Joze RIHTARSIC
Browse files

Pull request #137: Bugfix/EDELIVERY-13874 ui updates

Merge in EDELIVERY/smp from bugfix/EDELIVERY-13874-ui-updates to development

* commit 'e05c9220':
  [EDELIVERY-13787] fix the UI property dialog not show boolean proeprtues correctly
  [EDELIVERY-13740, EDELIVERY-13738] fix UI domain-property dialog description and close button
  [EDELIVERY-13874] fix UI group dialog name validation
parents 12eb7dd7 e05c9220
Branches bugfix/EDELIVERY-13839-rest-error-fix-redirection
No related tags found
No related merge requests found
Pipeline #208297 failed
Showing
with 56 additions and 39 deletions
......@@ -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>
......
......@@ -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 {
......
......@@ -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%">
......
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) {
......
......@@ -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",
......
......@@ -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));
......
......@@ -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() {
}
}
......@@ -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;
......
......@@ -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)
......
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment