From 66ae3e5a783d7c4d28d58faea8ee15c4e5f7c8ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B8=D0=BC=D0=BE=D1=84=D0=B5=D0=B9=20=D0=90=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B5=D0=B5=D0=B2?= Date: Tue, 18 Nov 2025 17:38:12 +0300 Subject: [PATCH 1/4] MD-535 --- .../entity-properties-dialog.component.html | 6 +- .../entity-properties-dialog.component.ts | 1 + .../core/validators/domainformat.directive.ts | 3 + .../core/validators/max-length.directive.ts | 5 +- .../required-with-message.directive.ts | 11 +- .../user-properties-general.component.html | 184 +++++++++--------- .../user-properties-general.component.ts | 23 ++- .../user-properties.component.html | 2 +- .../user-properties.component.ts | 12 +- 9 files changed, 142 insertions(+), 105 deletions(-) diff --git a/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.html b/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.html index 1a44bed5..97bc966d 100644 --- a/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.html +++ b/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.html @@ -5,7 +5,7 @@
@switch (entityType) { @case (EntityTypes.User) { - + } @case (EntityTypes.Group) { @@ -25,8 +25,8 @@ {{ 'properties-modal.close' | transloco }} - {{ 'properties-modal.approve' | transloco }} + {{ 'properties-modal.approve' | transloco }}
diff --git a/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.ts b/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.ts index f5f075d9..15f08ef9 100644 --- a/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.ts +++ b/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.ts @@ -50,6 +50,7 @@ import { LdapEntryType } from '@models/core/ldap/ldap-entry-type'; export class EntityPropertiesDialogComponent implements OnInit { dialogData: EntityPropertiesDialogData = inject(DIALOG_DATA); + @ViewChild('userProps') userProps!: UserPropertiesComponent; @ViewChild(DialogComponent, { static: true }) dialogComponent!: DialogComponent; EntityTypes = LdapEntryType; diff --git a/projects/multidirectory-app/src/app/core/validators/domainformat.directive.ts b/projects/multidirectory-app/src/app/core/validators/domainformat.directive.ts index c808d221..186de1a6 100644 --- a/projects/multidirectory-app/src/app/core/validators/domainformat.directive.ts +++ b/projects/multidirectory-app/src/app/core/validators/domainformat.directive.ts @@ -25,6 +25,9 @@ export class DomainFormatValidatorDirective implements Validator { patternValidator = new PatternValidator(); validate(control: AbstractControl): ValidationErrors | null { + if (!control.value) { + return null; + } const result = new RegExp(this.domainPattern()).test(control.value); return result ? null : { DomainFormat: this.domainErrorMessage() }; } diff --git a/projects/multidirectory-app/src/app/core/validators/max-length.directive.ts b/projects/multidirectory-app/src/app/core/validators/max-length.directive.ts index bf09535b..4fdbb778 100644 --- a/projects/multidirectory-app/src/app/core/validators/max-length.directive.ts +++ b/projects/multidirectory-app/src/app/core/validators/max-length.directive.ts @@ -36,7 +36,10 @@ export class MaxLengthValidatorDirective implements Validator { return null; } - const exceededMaxLength = this.maxLength ? value.length > this.maxLength : false; + // todo: убрать в рамках рефакторинга форм + const normalizedValue = value instanceof Array ? value[0] : value; + + const exceededMaxLength = this.maxLength ? normalizedValue.length > this.maxLength : false; return exceededMaxLength ? { MaxLengthExceeded: this.maxLengthErrorMessage } : null; } diff --git a/projects/multidirectory-app/src/app/core/validators/required-with-message.directive.ts b/projects/multidirectory-app/src/app/core/validators/required-with-message.directive.ts index 57fa2ca6..5ef3d135 100644 --- a/projects/multidirectory-app/src/app/core/validators/required-with-message.directive.ts +++ b/projects/multidirectory-app/src/app/core/validators/required-with-message.directive.ts @@ -23,12 +23,13 @@ export class RequiredWithMessageDirective extends RequiredValidator { override validate(control: AbstractControl): ValidationErrors | null { const appRequiredErrorLabel = this.appRequiredErrorLabel(); - return control.value !== null && control.value !== undefined && control.value !== '' + const normalizedValue = control.value instanceof Array ? control.value[0] : control.value; + return normalizedValue !== null && normalizedValue !== undefined && normalizedValue !== '' ? null : { - required: appRequiredErrorLabel - ? appRequiredErrorLabel - : translate('error-message.required'), - }; + required: appRequiredErrorLabel + ? appRequiredErrorLabel + : translate('error-message.required'), + }; } } diff --git a/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/general/user-properties-general.component.html b/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/general/user-properties-general.component.html index 05dd238a..3131be27 100644 --- a/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/general/user-properties-general.component.html +++ b/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/general/user-properties-general.component.html @@ -9,102 +9,108 @@
- -
- - + + +
+ + - - -
+ + +
- -
- - -
+ +
+ + +
- -
- - -
+ +
+ + +
- -
- - -
+ +
+ + +
- -
- - -
+ +
+ + +
-
+
- -
- - - - {{ 'user-properties-generals.other' | transloco }} - -
+ +
+ + + + {{ 'user-properties-generals.other' | transloco }} + +
- -
- - -
+ +
+ + +
- -
- - - - {{ 'user-properties-generals.other' | transloco }} - -
+ +
+ + + + {{ 'user-properties-generals.other' | transloco }} + +
+ } diff --git a/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/general/user-properties-general.component.ts b/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/general/user-properties-general.component.ts index 122b94f6..83082931 100644 --- a/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/general/user-properties-general.component.ts +++ b/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/general/user-properties-general.component.ts @@ -1,10 +1,10 @@ -import { Component, inject, Input } from '@angular/core'; -import { AbstractControl, FormsModule, ValidationErrors, ValidatorFn } from '@angular/forms'; +import { Component, inject, Input, ViewChild, AfterViewInit } from '@angular/core'; +import { FormsModule } from '@angular/forms'; import { LdapAttributes } from '@core/ldap/ldap-attributes/ldap-attributes'; import { RequiredWithMessageDirective } from '@core/validators/required-with-message.directive'; import { AvatarUploadComponent } from '@features/ldap-properties/avatar-upload/avatar-upload.component'; import { translate, TranslocoPipe } from '@jsverse/transloco'; -import { ButtonComponent, TextboxComponent } from 'multidirectory-ui-kit'; +import { ButtonComponent, TextboxComponent, MdFormComponent } from 'multidirectory-ui-kit'; import { ToastrService } from 'ngx-toastr'; import { AttributeListDialogComponent } from '../../../../components/modals/components/dialogs/attribute-list-dialog/attribute-list-dialog.component'; import { @@ -14,6 +14,7 @@ import { import { DialogService } from '../../../../components/modals/services/dialog.service'; import { ValidationFunctions } from '@core/validators/validator-functions'; import { DomainFormatValidatorDirective } from '@core/validators/domainformat.directive'; +import { MaxLengthValidatorDirective } from '@core/validators/max-length.directive'; @Component({ selector: 'app-user-properties-general', @@ -22,18 +23,25 @@ import { DomainFormatValidatorDirective } from '@core/validators/domainformat.di imports: [ AvatarUploadComponent, TextboxComponent, + MdFormComponent, FormsModule, RequiredWithMessageDirective, TranslocoPipe, ButtonComponent, DomainFormatValidatorDirective, + MaxLengthValidatorDirective, ], }) -export class UserPropertiesGeneralComponent { +export class UserPropertiesGeneralComponent implements AfterViewInit { private dialogService: DialogService = inject(DialogService); @Input() accessor: LdapAttributes | null = null; + @ViewChild('form') userPropsForm!: MdFormComponent; toastr = inject(ToastrService); + ngAfterViewInit() { + this.userPropsForm?.validate(); + } + changeOtherAttributeList(title: string, field: string) { if (!this.accessor) { return; @@ -66,4 +74,11 @@ export class UserPropertiesGeneralComponent { this.accessor![field] = result; }); } + + get formValid(): boolean { + if (!this.userPropsForm) { + return true; + } + return this.userPropsForm.valid; + } } diff --git a/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/user-properties.component.html b/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/user-properties.component.html index 6dacf7d0..d915cc92 100644 --- a/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/user-properties.component.html +++ b/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/user-properties.component.html @@ -23,7 +23,7 @@ {{ 'user-properties-tabs.password-policy' | transloco }} - + diff --git a/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/user-properties.component.ts b/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/user-properties.component.ts index 9906910b..e75ce1ee 100644 --- a/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/user-properties.component.ts +++ b/projects/multidirectory-app/src/app/features/ldap-properties/user-properties/user-properties.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectorRef, Component, inject, input } from '@angular/core'; +import {ChangeDetectorRef, Component, inject, input, ViewChild} from '@angular/core'; import { LdapAttributes } from '@core/ldap/ldap-attributes/ldap-attributes'; import { TranslocoPipe } from '@jsverse/transloco'; import { TabComponent, TabDirective, TabPaneComponent } from 'multidirectory-ui-kit'; @@ -25,10 +25,11 @@ import { UserPropertiesProfileComponent } from './profile/user-properties-profil UserPropertiesProfileComponent, UserPropertiesAccountComponent, MemberOfComponent, - PasswordPolicyComponent, + PasswordPolicyComponent ], }) export class UserPropertiesComponent { + @ViewChild('ug') generalProperties!: UserPropertiesGeneralComponent; private cdr = inject(ChangeDetectorRef); readonly accessor = input.required(); properties?: any[]; @@ -40,4 +41,11 @@ export class UserPropertiesComponent { onTabChanged() { this.cdr.detectChanges(); } + + get generalPropertiesValid(): boolean { + if (!this.generalProperties) { + return true; + } + return this.generalProperties.formValid; + } } From 42f99b97d4d2fbdf65d54b8b9f23d38a0672d5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B8=D0=BC=D0=BE=D1=84=D0=B5=D0=B9=20=D0=90=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B5=D0=B5=D0=B2?= Date: Wed, 3 Dec 2025 17:56:25 +0300 Subject: [PATCH 2/4] MD-535 --- .../user-create/general-info/general-info.component.html | 7 +++++++ .../user-create/general-info/general-info.component.ts | 2 ++ 2 files changed, 9 insertions(+) diff --git a/projects/multidirectory-app/src/app/features/forms/user-create/general-info/general-info.component.html b/projects/multidirectory-app/src/app/features/forms/user-create/general-info/general-info.component.html index 62a595af..460c411d 100644 --- a/projects/multidirectory-app/src/app/features/forms/user-create/general-info/general-info.component.html +++ b/projects/multidirectory-app/src/app/features/forms/user-create/general-info/general-info.component.html @@ -9,6 +9,7 @@ appRequired class="col-span-1 w-full" name="first-name" + [maxLength]="256" (change)="onNameChange()" [(ngModel)]="setupRequest.firstName" > @@ -19,6 +20,7 @@ @@ -32,6 +34,7 @@ @@ -45,6 +48,7 @@ @@ -57,6 +61,7 @@ @@ -70,6 +75,7 @@ @@ -83,6 +89,7 @@ diff --git a/projects/multidirectory-app/src/app/features/forms/user-create/general-info/general-info.component.ts b/projects/multidirectory-app/src/app/features/forms/user-create/general-info/general-info.component.ts index d3bcc5d7..ff4c64fb 100644 --- a/projects/multidirectory-app/src/app/features/forms/user-create/general-info/general-info.component.ts +++ b/projects/multidirectory-app/src/app/features/forms/user-create/general-info/general-info.component.ts @@ -25,6 +25,7 @@ import { TextboxComponent, } from 'multidirectory-ui-kit'; import { from, Subject, take, takeUntil } from 'rxjs'; +import { MaxLengthValidatorDirective } from '@core/validators/max-length.directive'; @Component({ selector: 'app-user-create-general-info', @@ -39,6 +40,7 @@ import { from, Subject, take, takeUntil } from 'rxjs'; DropdownComponent, MdFormComponent, CommonModule, + MaxLengthValidatorDirective ], }) export class UserCreateGeneralInfoComponent implements OnInit, AfterViewInit, OnDestroy { From d3481e163fb37ffc20ccde0eeb05c44d8dca0f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A2=D0=B8=D0=BC=D0=BE=D1=84=D0=B5=D0=B9=20=D0=90=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=81=D0=B5=D0=B5=D0=B2?= Date: Thu, 4 Dec 2025 15:12:00 +0300 Subject: [PATCH 3/4] MD-535 --- .../entity-properties-dialog.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.html b/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.html index 97bc966d..32ab7ebd 100644 --- a/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.html +++ b/projects/multidirectory-app/src/app/components/modals/components/dialogs/entity-properties-dialog/entity-properties-dialog.component.html @@ -22,7 +22,7 @@