Skip to content

Commits on Source 5

## [7.0.6](https://gitlab.ics.muni.cz/perun/perun-proxyidp/v1/perun-spRegistration-app/compare/v7.0.5...v7.0.6) (2025-07-10)
### Bug Fixes
* fixed form validation especially for boolean items ([5e72600](https://gitlab.ics.muni.cz/perun/perun-proxyidp/v1/perun-spRegistration-app/commit/5e72600a716ba3808c93da44b697d1836274e373))
* make sure required flag is respected when editing requests ([666a648](https://gitlab.ics.muni.cz/perun/perun-proxyidp/v1/perun-spRegistration-app/commit/666a6489aeceef95c694c71add7ac1d7ee4c9e6e))
* validation on map items, validate on blur ([fa2e898](https://gitlab.ics.muni.cz/perun/perun-proxyidp/v1/perun-spRegistration-app/commit/fa2e89842e56635668f1f9f56005b99f46def9f3))
## [7.0.5](https://gitlab.ics.muni.cz/perun/perun-proxyidp/v1/perun-spRegistration-app/compare/v7.0.4...v7.0.5) (2025-06-24)
......
......@@ -60,7 +60,14 @@
*ngFor="let applicationItems of commentedServiceAttrs">
<request-input-item
#commentedServiceItems
[applicationItem]="applicationItems"></request-input-item>
[applicationItem]="applicationItems"
[required]="
applicationItems.isRequired(
request.providedService !== null
? request.providedService.environment
: 'TEST'
)
"></request-input-item>
</ng-container>
</div>
</div>
......@@ -73,7 +80,14 @@
<ng-container *ngFor="let applicationItems of serviceAttrs">
<request-input-item
#serviceItems
[applicationItem]="applicationItems"></request-input-item>
[applicationItem]="applicationItems"
[required]="
applicationItems.isRequired(
request.providedService !== null
? request.providedService.environment
: 'TEST'
)
"></request-input-item>
</ng-container>
</div>
</div>
......@@ -106,7 +120,14 @@
*ngFor="let applicationItems of commentedOrganizationAttrs">
<request-input-item
#commentedOrgItems
[applicationItem]="applicationItems"></request-input-item>
[applicationItem]="applicationItems"
[required]="
applicationItems.isRequired(
request.providedService !== null
? request.providedService.environment
: 'TEST'
)
"></request-input-item>
</ng-container>
</div>
</div>
......@@ -121,7 +142,14 @@
<ng-container *ngFor="let applicationItems of organizationAttrs">
<request-input-item
#orgItems
[applicationItem]="applicationItems"></request-input-item>
[applicationItem]="applicationItems"
[required]="
applicationItems.isRequired(
request.providedService !== null
? request.providedService.environment
: 'TEST'
)
"></request-input-item>
</ng-container>
</div>
</div>
......@@ -152,7 +180,14 @@
*ngFor="let applicationItems of commentedProtocolAttrs">
<request-input-item
#commentedProtocolItems
[applicationItem]="applicationItems"></request-input-item>
[applicationItem]="applicationItems"
[required]="
applicationItems.isRequired(
request.providedService !== null
? request.providedService.environment
: 'TEST'
)
"></request-input-item>
</ng-container>
</div>
</div>
......@@ -165,7 +200,14 @@
<ng-container *ngFor="let applicationItems of protocolAttrs">
<request-input-item
#protocolItems
[applicationItem]="applicationItems"></request-input-item>
[applicationItem]="applicationItems"
[required]="
applicationItems.isRequired(
request.providedService !== null
? request.providedService.environment
: 'TEST'
)
"></request-input-item>
</ng-container>
</div>
</div>
......@@ -198,7 +240,14 @@
*ngFor="let applicationItems of commentedAccessControlAttrs">
<request-input-item
#commentedAccessItems
[applicationItem]="applicationItems"></request-input-item>
[applicationItem]="applicationItems"
[required]="
applicationItems.isRequired(
request.providedService !== null
? request.providedService.environment
: 'TEST'
)
"></request-input-item>
</ng-container>
</div>
</div>
......@@ -213,7 +262,14 @@
<ng-container *ngFor="let applicationItems of accessControlAttrs">
<request-input-item
#accessItems
[applicationItem]="applicationItems"></request-input-item>
[applicationItem]="applicationItems"
[required]="
applicationItems.isRequired(
request.providedService !== null
? request.providedService.environment
: 'TEST'
)
"></request-input-item>
</ng-container>
</div>
</div>
......
......@@ -118,7 +118,7 @@ export class RequestsEditComponent implements OnInit {
ngOnInit() {
this.clearArrays();
this.translate
.get('REQUESTS.ERRORS.VALUES_ERROR_MESSAGE')
.get('REQUESTS.ERRORS.EDIT_VALUES_ERROR_MESSAGE')
.subscribe(value => (this.errorText = value));
this.translate
.get('REQUESTS.SUCCESSFULLY_SUBMITTED')
......@@ -180,6 +180,7 @@ export class RequestsEditComponent implements OnInit {
submitRequest() {
if (!this.hasCorrectValues()) {
this.snackBar.open(this.errorText, null, { duration: 6000 });
return;
}
......
......@@ -5,8 +5,10 @@
[(ngModel)]="value"
name="{{ applicationItem.name }}"
[class.perun-warn]="hasError()"
[required]="required">
{{ applicationItem.displayName | itemLocale }}
[required]="required"
(ngModelChange)="hasCorrectValue()"
(blur)="hasCorrectValue()">
{{ applicationItem.displayName | itemLocale }}{{ required ? ' *' : '' }}
</mat-checkbox>
<hr class="hr" />
<div
......@@ -14,6 +16,13 @@
[innerHTML]="applicationItem.description | itemLocale"></div>
</div>
</div>
<div class="row" *ngIf="missingValueError">
<request-item-input-error
*ngIf="missingValueError"
[messageKey]="
'REQUESTS.ERRORS.CHECK_REQUIRED_ERROR'
"></request-item-input-error>
</div>
<div class="row" *ngIf="expectedValueChangedError">
<request-item-input-error
[messageKey]="
......
......@@ -19,6 +19,7 @@ export class RequestItemInputBooleanComponent implements OnInit, RequestItem {
value = false;
expectedValueChangedError = false;
missingValueError = false;
ngOnInit(): void {
this.value = this.applicationItem.oldValue;
......@@ -29,7 +30,10 @@ export class RequestItemInputBooleanComponent implements OnInit, RequestItem {
}
hasCorrectValue(): boolean {
this.resetErrors();
if (!this.value && this.required) {
this.form.form.setErrors({ incorrect: true });
this.missingValueError = true;
return false;
}
return this.newApp || this.checkChangeMade();
......@@ -48,7 +52,7 @@ export class RequestItemInputBooleanComponent implements OnInit, RequestItem {
}
hasError(): boolean {
return this.expectedValueChangedError;
return this.expectedValueChangedError || this.missingValueError;
}
private checkChangeMade() {
......@@ -61,4 +65,9 @@ export class RequestItemInputBooleanComponent implements OnInit, RequestItem {
}
return true;
}
private resetErrors() {
this.expectedValueChangedError = false;
this.missingValueError = false;
}
}
......@@ -10,11 +10,9 @@
</button>
</p>
</div>
<div class="row">
<p
class="col-12 pl-0 pr-0 text-muted small"
[innerHTML]="applicationItem.description | itemLocale"></p>
</div>
<div
class="row text-muted small mt-2"
[innerHTML]="applicationItem.description | itemLocale"></div>
<div class="row" *ngIf="missingValueError">
<request-item-input-error
[messageKey]="
......@@ -48,7 +46,9 @@
[type]="this.applicationItem.regex === 'URL' ? 'url' : 'text'"
name="value-{{ i }}"
id="{{ applicationItem.name }}-{{ i }}"
[(ngModel)]="values[i]" />
[(ngModel)]="values[i]"
(ngModelChange)="hasCorrectValue()"
(blur)="hasCorrectValue()" />
</mat-form-field>
</div>
<div class="col-sm-1 pl-0 pr-0">
......
......@@ -14,11 +14,9 @@
</button>
</p>
</div>
<div class="row">
<p
class="col-12 pl-0 pr-0 text-muted small"
[innerHTML]="applicationItem.description | itemLocale"></p>
</div>
<div
class="row text-muted small mt-2"
[innerHTML]="applicationItem.description | itemLocale"></div>
<div class="row" *ngIf="missingValueError">
<request-item-input-error
[messageKey]="
......@@ -53,10 +51,12 @@
type="text"
required
placeholder="{{ 'REQUESTS.MAP_KEY' | translate }}"
name="key-{{ i }}"
name="{{ applicationItem.name }}-key-{{ i }}"
[disabled]="allowCustomKeys"
id="{{ applicationItem.name }}-key-{{ i }}"
[(ngModel)]="keys[i]" />
[(ngModel)]="keys[i]"
(ngModelChange)="hasCorrectValue()"
(blur)="hasCorrectValue()" />
</mat-form-field>
</div>
<div [class]="!allowCustomKeys ? 'col-sm-8' : 'col-sm-9'" class="pr-0">
......@@ -67,9 +67,11 @@
[required]="required"
placeholder="{{ 'REQUESTS.VALUE' | translate }}"
[pattern]="applicationItem.hasRegex() ? applicationItem.regex : null"
name="value-{{ i }}"
name="{{ applicationItem.name }}-value-{{ i }}"
id="{{ applicationItem.name }}-value-{{ i }}"
[(ngModel)]="values[i]" />
[(ngModel)]="values[i]"
(ngModelChange)="hasCorrectValue()"
(blur)="hasCorrectValue()" />
</mat-form-field>
</div>
<div class="col-sm-1 pl-0 pr-0" *ngIf="!allowCustomKeys">
......
......@@ -96,14 +96,21 @@ export class RequestItemInputMapComponent implements RequestItem, OnInit {
onFormSubmitted(): void {
if (!this.hasCorrectValue()) {
this.form.form.controls[this.applicationItem.name].markAsTouched();
this.form.form.controls[this.applicationItem.name].setErrors({
for (let i = 0; i < this.values.length; i++) {
this.form.form.controls[
this.applicationItem.name + '-value-' + i
].markAsTouched();
this.form.form.controls[
this.applicationItem.name + '-value-' + i
].setErrors({
incorrect: true,
});
this.form.form.controls[
this.applicationItem.name
this.applicationItem.name + '-value-' + i
].updateValueAndValidity();
}
this.form.form.setErrors({ incorrect: true });
}
}
customTrackBy(index: number, _: any): any {
......@@ -113,20 +120,24 @@ export class RequestItemInputMapComponent implements RequestItem, OnInit {
showErredValues(errIndexes: number[]) {
for (let i = 0; i < errIndexes.length; i++) {
const index = this.indexes[i];
const input = this.form.form.controls['value-' + index];
const input =
this.form.form.controls[this.applicationItem.name + '-value-' + index];
input.markAsTouched();
input.setErrors({ incorrect: true });
this.form.form.setErrors({ incorrect: true });
}
}
showErredKeys(errIndexes: number[]) {
for (let i = 0; i < errIndexes.length; i++) {
const index = this.indexes[i];
const input = this.form.form.controls['key-' + index];
const input =
this.form.form.controls[this.applicationItem.name + '-key-' + index];
input.markAsTouched();
input.setErrors({ incorrect: true });
this.form.form.setErrors({ incorrect: true });
}
}
......@@ -134,7 +145,7 @@ export class RequestItemInputMapComponent implements RequestItem, OnInit {
return (
this.missingValueError ||
this.duplicateKeysError ||
this.missingValueError ||
this.expectedValueChangedError ||
this.regexMismatchError
);
}
......
......@@ -7,7 +7,9 @@
placeholder="{{ applicationItem.displayName | itemLocale }}"
name="{{ applicationItem.name }}"
[required]="required"
[class.perun-warn]="hasError()">
[class.perun-warn]="hasError()"
(ngModelChange)="hasCorrectValue()"
(blur)="hasCorrectValue()">
<mat-option
*ngFor="let value of applicationItem.allowedValues"
[value]="value"
......
......@@ -6,7 +6,9 @@
placeholder="{{ applicationItem.displayName | itemLocale }}"
name="{{ applicationItem.name }}"
[required]="required"
[class.perun-warn]="hasError()">
[class.perun-warn]="hasError()"
(ngModelChange)="hasCorrectValue()"
(blur)="hasCorrectValue()">
<mat-option
*ngFor="let value of applicationItem.allowedValues"
[value]="value"
......
......@@ -11,7 +11,9 @@
[type]="applicationItem.regex === 'URL' ? 'url' : 'text'"
[class.perun-warn]="hasError()"
placeholder="{{ applicationItem.displayName | itemLocale }}"
name="{{ applicationItem.name }}" />
name="{{ applicationItem.name }}"
(ngModelChange)="hasCorrectValue()"
(blur)="hasCorrectValue()" />
<div
class="text-muted small mt-2"
[innerHTML]="applicationItem.description | itemLocale"></div>
......
......@@ -50,7 +50,7 @@ export class RequestItemInputComponent implements RequestItem, AfterViewInit {
}
ngAfterViewInit(): void {
console.log(this.applicationItem.name + ' ' + this.required);
//console.log(this.applicationItem.name + ' ' + this.required);
switch (this.applicationItem.type) {
case 'java.lang.String':
{
......
......@@ -48,7 +48,9 @@
"DUPLICATE_KEYS_ERROR": "Hodnota klíče musí být unikátní!",
"NO_VALUE_ERROR": "Hodnota musí být vyplněna!",
"EXPECTED_CHANGED_VALUE_ERROR": "Některé vyžádané změny nebyly vykonány!",
"REGEX_MISMATCH_ERROR": "Hodnota nemá požadovaný formát!"
"REGEX_MISMATCH_ERROR": "Hodnota nemá požadovaný formát!",
"CHECK_REQUIRED_ERROR": "Položka musí být zaškrtnuta!",
"EDIT_VALUES_ERROR_MESSAGE": "Formulář obsahuje chyby! Zkontrolujte všechny položky."
},
"OVERVIEW": {
"ID": "#",
......
......@@ -51,7 +51,9 @@
"DUPLICATE_KEYS_ERROR": "Key must be unique!",
"NO_VALUE_ERROR": "Value is not filled!",
"EXPECTED_CHANGED_VALUE_ERROR": "Some requested changes were not made!",
"REGEX_MISMATCH_ERROR": "Value does not satisfy required format!"
"REGEX_MISMATCH_ERROR": "Value does not satisfy required format!",
"CHECK_REQUIRED_ERROR": "Checkbox needs to be checked!",
"EDIT_VALUES_ERROR_MESSAGE": "Form contains errors! Check all form fields."
},
"OVERVIEW": {
"ID": "#",
......
......@@ -12,7 +12,7 @@
<groupId>cz.metacentrum.perun</groupId>
<artifactId>spRegistration</artifactId>
<version>7.0.5</version>
<version>7.0.6</version>
<packaging>war</packaging>
<name>perun-spRegistration</name>
......@@ -264,13 +264,14 @@
</plugins>
</build>
<!--
<repositories>
<repository>
<id>spring-releases</id>
<url>https://repo.spring.io/libs-release</url>
</repository>
</repositories>
-->
<organization>
<name>CESNET, z.s.p.o.</name>
<url>https://www.cesnet.cz/</url>
......