From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 20 Feb 2023 10:15:11 +0000 (-0800) Subject: Fix dyanmic disabling checkboxes in permissions select X-Git-Tag: v1.14.0-beta.rc1~91^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75c5cccceceeb06dd86c6f5fd84796156eb126dc;p=thirdparty%2Fpaperless-ngx.git Fix dyanmic disabling checkboxes in permissions select --- diff --git a/src-ui/src/app/components/common/permissions-select/permissions-select.component.html b/src-ui/src/app/components/common/permissions-select/permissions-select.component.html index 1907f4e3fe..f3e85a5439 100644 --- a/src-ui/src/app/components/common/permissions-select/permissions-select.component.html +++ b/src-ui/src/app/components/common/permissions-select/permissions-select.component.html @@ -18,7 +18,7 @@
- +
diff --git a/src-ui/src/app/components/common/permissions-select/permissions-select.component.ts b/src-ui/src/app/components/common/permissions-select/permissions-select.component.ts index fa97a3b558..4b968f6e58 100644 --- a/src-ui/src/app/components/common/permissions-select/permissions-select.component.ts +++ b/src-ui/src/app/components/common/permissions-select/permissions-select.component.ts @@ -1,5 +1,6 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core' import { + AbstractControl, ControlValueAccessor, FormControl, FormGroup, @@ -54,6 +55,8 @@ export class PermissionsSelectComponent this._inheritedPermissions = newInheritedPermissions this.writeValue(this.permissions) // updates visual checks etc. } + + this.updateDisabledStates() } inheritedWarning: string = $localize`Inerhited from group` @@ -98,6 +101,8 @@ export class PermissionsSelectComponent this.typesWithAllActions.delete(type) } }) + + this.updateDisabledStates() } onChange = (newValue: string[]) => {} @@ -185,12 +190,16 @@ export class PermissionsSelectComponent } } - // if checkbox is disabled either because "All", inhereted or entire component disabled - isDisabled(typeKey: string, actionKey: string) { - return this.typesWithAllActions.has(typeKey) || - this.isInherited(typeKey, actionKey) || - this.disabled - ? true - : null + updateDisabledStates() { + for (const type in PermissionType) { + const control = this.form.get(type) + let actionControl: AbstractControl + for (const action in PermissionAction) { + actionControl = control.get(action) + this.isInherited(type, action) || this.disabled + ? actionControl.disable() + : actionControl.enable() + } + } } }