@kuzntsv/uikit 1.0.16 → 1.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -491,6 +491,8 @@ class BaseEditClass {
|
|
|
491
491
|
loaderService = inject(LoaderService);
|
|
492
492
|
/** Сервис уведомлений. */
|
|
493
493
|
notificationService = inject(NotificationService);
|
|
494
|
+
/** Сервис ролей. */
|
|
495
|
+
roleService = inject(RoleService);
|
|
494
496
|
/** Объект для отписки (вызывается метод unsubscribe при уничтожении компонента). */
|
|
495
497
|
subscription = new Subscription();
|
|
496
498
|
ngOnDestroy() {
|
|
@@ -504,11 +506,12 @@ class BaseEditClass {
|
|
|
504
506
|
if (this.form) {
|
|
505
507
|
if (this.form.valid) {
|
|
506
508
|
if (this.dialogData)
|
|
507
|
-
Object.keys(this.form.controls).forEach(controlName => this.dialogData.entity[controlName] =
|
|
509
|
+
Object.keys(this.form.controls).forEach((controlName) => (this.dialogData.entity[controlName] =
|
|
510
|
+
this.form?.controls[controlName].value));
|
|
508
511
|
this.dialogRef?.close(this.dialogData);
|
|
509
512
|
}
|
|
510
513
|
else {
|
|
511
|
-
Object.keys(this.form.controls).forEach(controlName => this.form?.controls[controlName].markAsTouched());
|
|
514
|
+
Object.keys(this.form.controls).forEach((controlName) => this.form?.controls[controlName].markAsTouched());
|
|
512
515
|
}
|
|
513
516
|
}
|
|
514
517
|
}
|
|
@@ -518,6 +521,26 @@ class BaseEditClass {
|
|
|
518
521
|
formActionIsEdit() {
|
|
519
522
|
return this.dialogData?.action === Action.Edit;
|
|
520
523
|
}
|
|
524
|
+
/**
|
|
525
|
+
* Определяет видимость элемента на основе ЧЕРНОГО списка ролей.
|
|
526
|
+
* По умолчанию элемент ВИДИМ. Скрывается (возвращает false), если у пользователя
|
|
527
|
+
* есть запрещенная роль или если передан маркер скрытия фичи HIDE_ROLE_MARKER.
|
|
528
|
+
*/
|
|
529
|
+
isVisibleForForbiddenRoles(forbiddenRoles) {
|
|
530
|
+
// Если роль запрещена, метод roleService вернет true.
|
|
531
|
+
// Мы инвертируем (!), чтобы видимость (isMenuVisible) стала false.
|
|
532
|
+
return !this.roleService.hasForbiddenRole(forbiddenRoles);
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Определяет видимость элемента на основе БЕЛОГО списка ролей.
|
|
536
|
+
* По умолчанию элемент СКРЫТ. Показывается (возвращает true), только если у пользователя
|
|
537
|
+
* есть хотя бы одна из разрешенных ролей. Администратор (ADMIN) всегда видит элемент.
|
|
538
|
+
*/
|
|
539
|
+
isVisibleForAllowedRoles(allowedRoles) {
|
|
540
|
+
// Проверяем, есть ли у пользователя хотя бы одна роль из разрешенного списка.
|
|
541
|
+
// (Предполагается, что у вашего roleService есть соответствующий метод, например, hasAnyRole)
|
|
542
|
+
return this.roleService.hasAnyRole(allowedRoles);
|
|
543
|
+
}
|
|
521
544
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.25", ngImport: i0, type: BaseEditClass, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
522
545
|
static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "21.2.25", type: BaseEditClass, isStandalone: true, ngImport: i0 });
|
|
523
546
|
}
|
|
@@ -564,7 +587,7 @@ class BaseNavBarMenuClass {
|
|
|
564
587
|
* По умолчанию пункт меню ВИДИМ. Скрывается (возвращает false), если у пользователя
|
|
565
588
|
* есть запрещенная роль или если передан маркер скрытия фичи HIDE_ROLE_MARKER.
|
|
566
589
|
*/
|
|
567
|
-
|
|
590
|
+
isVisibleForForbiddenRoles(forbiddenRoles) {
|
|
568
591
|
// Если роль запрещена, метод roleService вернет true.
|
|
569
592
|
// Мы инвертируем (!), чтобы видимость (isMenuVisible) стала false.
|
|
570
593
|
return !this.roleService.hasForbiddenRole(forbiddenRoles);
|
|
@@ -574,7 +597,7 @@ class BaseNavBarMenuClass {
|
|
|
574
597
|
* По умолчанию пункт меню СКРЫТ. Показывается (возвращает true), только если у пользователя
|
|
575
598
|
* есть хотя бы одна из разрешенных ролей. Администратор (ADMIN) всегда видит элемент.
|
|
576
599
|
*/
|
|
577
|
-
|
|
600
|
+
isVisibleForAllowedRoles(allowedRoles) {
|
|
578
601
|
// Проверяем, есть ли у пользователя хотя бы одна роль из разрешенного списка.
|
|
579
602
|
// (Предполагается, что у вашего roleService есть соответствующий метод, например, hasAnyRole)
|
|
580
603
|
return this.roleService.hasAnyRole(allowedRoles);
|