Skip to content

Commit 505c49a

Browse files
author
Salim Terres
committed
Bug #15468 [Profile Groups] – The “Next” button becomes clickable before the name is validated.
1 parent 5aba3c5 commit 505c49a

File tree

5 files changed

+27
-24
lines changed

5 files changed

+27
-24
lines changed

ui/ui-frontend/projects/identity/src/app/external-param-profile/external-param-profile-create/external-param-profile-create.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
]"
88
></vitamui-dialog-header>
99

10-
<form [formGroup]="externalParamProfileForm" (ngSubmit)="onSubmit()">
10+
<form [formGroup]="form" (ngSubmit)="onSubmit()">
1111
<vitamui-stepper #stepper>
1212
<cdk-step>
1313
<mat-dialog-content class="gap-3 align-items-stretch">
1414
<vitamui-slide-toggle formControlName="enabled"
15-
>{{ 'EXTERNAL_PARAM_PROFILE.PROFILE' | translate }} <span *ngIf="!externalParamProfileForm.get('enabled').value">in</span
15+
>{{ 'EXTERNAL_PARAM_PROFILE.PROFILE' | translate }} <span *ngIf="!form.get('enabled').value">in</span
1616
>{{ 'COMMON.ACTIVE' | translate }}</vitamui-slide-toggle
1717
>
1818

@@ -51,7 +51,7 @@
5151
{{ 'EXTERNAL_PARAM_PROFILE.USE_PLATFORM_BULK_OPERATIONS_THRESHOLD_TITLE' | translate }}
5252
</vitamui-slide-toggle>
5353

54-
<div class="select-threshold" *ngIf="!externalParamProfileForm.get('usePlatformThreshold').value">
54+
<div class="select-threshold" *ngIf="!form.get('usePlatformThreshold').value">
5555
<vitamui-select
5656
class="w-100"
5757
formControlName="bulkOperationsThreshold"
@@ -71,7 +71,7 @@
7171

7272
<mat-dialog-actions>
7373
<div>
74-
<button type="submit" class="btn primary" [disabled]="onValidate()">
74+
<button type="submit" class="btn primary" [disabled]="isFormInvalid()">
7575
{{ 'COMMON.SUBMIT' | translate }}
7676
</button>
7777
<button type="button" class="btn link cancel" (click)="onCancel()">

ui/ui-frontend/projects/identity/src/app/external-param-profile/external-param-profile-create/external-param-profile-create.component.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ import { DecimalPipe } from '@angular/common';
5252
standalone: false,
5353
})
5454
export class ExternalParamProfileCreateComponent implements OnInit, OnDestroy {
55-
externalParamProfileForm: FormGroup;
55+
form: FormGroup;
5656
activeAccessContractsIdentifiers$: Observable<string[]>;
5757
private keyPressSubscription: Subscription;
5858
tenantIdentifier: string;
@@ -91,7 +91,7 @@ export class ExternalParamProfileCreateComponent implements OnInit, OnDestroy {
9191
}
9292

9393
private initForm(tenantIdentifier: string) {
94-
this.externalParamProfileForm = this.formBuilder.group({
94+
this.form = this.formBuilder.group({
9595
enabled: true,
9696
accessContract: [null, Validators.required],
9797
description: [null, [Validators.required, Validators.minLength(2), Validators.maxLength(250)]],
@@ -100,16 +100,16 @@ export class ExternalParamProfileCreateComponent implements OnInit, OnDestroy {
100100
bulkOperationsThreshold: [null, []],
101101
});
102102

103-
this.externalParamProfileForm
103+
this.form
104104
.get('name')
105-
.setAsyncValidators(this.externalParamProfileValidators.nameExists(+tenantIdentifier, ApplicationId.EXTERNAL_PARAM_PROFILE_APP));
105+
.setAsyncValidators(this.externalParamProfileValidators.nameExists(+tenantIdentifier, ApplicationId.EXTERNAL_PARAMS));
106106
}
107107

108108
onSubmit() {
109-
if (this.externalParamProfileForm.invalid) {
109+
if (this.form.invalid) {
110110
return;
111111
}
112-
const externalParamProfile: ExternalParamProfile = this.externalParamProfileForm.getRawValue();
112+
const externalParamProfile: ExternalParamProfile = this.form.getRawValue();
113113
if (externalParamProfile.usePlatformThreshold) {
114114
externalParamProfile.bulkOperationsThreshold = null;
115115
}
@@ -126,22 +126,22 @@ export class ExternalParamProfileCreateComponent implements OnInit, OnDestroy {
126126
}
127127

128128
onCancel() {
129-
if (this.externalParamProfileForm.dirty) {
129+
if (this.form.dirty) {
130130
this.confirmDialogService.confirmBeforeClosing(this.dialogRef);
131131
} else {
132132
this.dialogRef.close();
133133
}
134134
}
135135

136-
onValidate() {
137-
return false;
136+
isFormInvalid() {
137+
return this.form.pending || this.form.invalid;
138138
}
139139

140140
firstStepInvalid(): boolean {
141-
return this.externalParamProfileForm.get('name').invalid || this.externalParamProfileForm.get('description').invalid;
142-
}
141+
const nameControl = this.form.controls.name;
142+
const descriptionControl = this.form.controls.description;
143+
const accessContractControl = this.form.controls.accessContract;
143144

144-
formValid(): boolean {
145-
return this.externalParamProfileForm.pending || this.externalParamProfileForm.invalid;
145+
return nameControl.invalid || nameControl.pending || descriptionControl.invalid || accessContractControl.invalid;
146146
}
147147
}

ui/ui-frontend/projects/identity/src/app/external-param-profile/external-param-profile-detail/information-tab/information-tab.component.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ export class InformationTabComponent implements OnDestroy, OnInit, OnChanges {
128128
this.form
129129
.get('name')
130130
.setAsyncValidators(
131-
this.externalParamProfileValidators.nameExists(
132-
+this.tenantIdentifier,
133-
ApplicationId.EXTERNAL_PARAM_PROFILE_APP,
134-
externalParamProfile.name,
135-
),
131+
this.externalParamProfileValidators.nameExists(+this.tenantIdentifier, ApplicationId.EXTERNAL_PARAMS, externalParamProfile.name),
136132
);
137133
}
138134

ui/ui-frontend/projects/identity/src/app/group/group-create/group-create.component.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,17 @@ export class GroupCreateComponent implements OnInit, OnDestroy {
108108
}
109109

110110
firstStepInvalid(): boolean {
111-
return this.form.get('name').invalid || this.form.get('description').invalid || this.form.get('level').invalid;
111+
const nameControl = this.form.controls.name;
112+
const descriptionControl = this.form.controls.description;
113+
const levelControl = this.form.controls.level;
114+
115+
return nameControl.invalid || nameControl.pending || descriptionControl.invalid || levelControl.invalid;
112116
}
113117

114118
secondStepInvalid(): boolean {
115-
return this.form.get('profileIds').invalid;
119+
const profileIdsControl = this.form.controls.profileIds;
120+
121+
return profileIdsControl.invalid || profileIdsControl.pending;
116122
}
117123

118124
formValid(): boolean {

ui/ui-frontend/projects/vitamui-library/src/app/modules/application-id.enum.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export enum ApplicationId {
6464
INGEST_APP_REF = 'INGEST_APP',
6565
LOGBOOK_MANAGEMENT_OPERATION_APP = 'LOGBOOK_MANAGEMENT_OPERATION_APP',
6666
EXTERNAL_PARAM_PROFILE_APP = 'EXTERNAL_PARAM_PROFILE_APP',
67+
EXTERNAL_PARAMS = 'EXTERNAL_PARAMS',
6768
MANAGEMENT_CONTRACT_APP = 'MANAGEMENT_CONTRACT_APP',
6869
COLLECT_APP = 'COLLECT_APP',
6970
}

0 commit comments

Comments
 (0)