Skip to content

Commit

Permalink
fix: if permission should use else block for undefined permissions (o…
Browse files Browse the repository at this point in the history
  • Loading branch information
markuczy authored Nov 12, 2024
1 parent 2940931 commit 137a2a1
Showing 1 changed file with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,24 @@ export class IfPermissionDirective implements OnInit {
}

ngOnInit() {
if (this.permission) {
if (this.negate === this.hasPermission(Array.isArray(this.permission) ? this.permission : [this.permission])) {
if (this.ocxIfPermissionElseTemplate) {
this.viewContainer.createEmbeddedView(this.ocxIfPermissionElseTemplate)
} else {
if (this.onMissingPermission === 'disable') {
this.renderer.setAttribute(this.el.nativeElement, 'disabled', 'disabled')
} else {
this.viewContainer.clear()
}
}
if (
(this.permission &&
this.negate === this.hasPermission(Array.isArray(this.permission) ? this.permission : [this.permission])) ||
!this.permission
) {
if (this.ocxIfPermissionElseTemplate) {
this.viewContainer.createEmbeddedView(this.ocxIfPermissionElseTemplate)
} else {
if (this.templateRef) {
this.viewContainer.createEmbeddedView(this.templateRef)
if (this.onMissingPermission === 'disable') {
this.renderer.setAttribute(this.el.nativeElement, 'disabled', 'disabled')
} else {
this.viewContainer.clear()
}
}
} else {
if (this.templateRef) {
this.viewContainer.createEmbeddedView(this.templateRef)
}
}
}

Expand Down

0 comments on commit 137a2a1

Please sign in to comment.