diff --git a/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html b/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html index 589ed2cd2c..ec73bda006 100644 --- a/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html +++ b/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.html @@ -1,15 +1,9 @@ - + - - - - - + - + diff --git a/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts b/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts index f82c552b93..7a004003eb 100644 --- a/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts +++ b/npm/ng-packs/packages/permission-management/src/lib/components/permission-management.component.ts @@ -7,11 +7,8 @@ import { Output, Renderer2, SimpleChanges, - TemplateRef, TrackByFunction, - ViewChild, } from '@angular/core'; -import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'; import { Select, Store } from '@ngxs/store'; import { from, Observable } from 'rxjs'; import { map, pluck, take } from 'rxjs/operators'; @@ -35,23 +32,33 @@ export class PermissionManagementComponent implements OnInit, OnChanges { @Input() providerKey: string; + protected _visible; + @Input() - visible: boolean; + get visible(): boolean { + return this._visible; + } + + set visible(value: boolean) { + if (!this.selectedGroup) return; + + this._visible = value; + this.visibleChange.emit(value); + + if (!value) { + this.selectedGroup = null; + } + } @Output() visibleChange = new EventEmitter(); - @ViewChild('modalContent', { static: false }) - modalContent: TemplateRef; - @Select(PermissionManagementState.getPermissionGroups) groups$: Observable; @Select(PermissionManagementState.getEntitiyDisplayName) entityName$: Observable; - modalRef: NgbModalRef; - selectedGroup: PermissionManagement.Group; permissions: PermissionManagement.Permission[] = []; @@ -80,7 +87,7 @@ export class PermissionManagementComponent implements OnInit, OnChanges { ); } - constructor(private modalService: NgbModal, private store: Store, private renderer: Renderer2) {} + constructor(private store: Store, private renderer: Renderer2) {} ngOnInit(): void {} @@ -186,9 +193,11 @@ export class PermissionManagementComponent implements OnInit, OnChanges { permissions: changedPermissions, }), ) - .subscribe(() => this.modalRef.close()); + .subscribe(() => { + this.visible = false; + }); } else { - this.modalRef.close(); + this.visible = false; } } @@ -206,39 +215,22 @@ export class PermissionManagementComponent implements OnInit, OnChanges { this.selectedGroup = permissionRes.groups[0]; this.permissions = getPermissions(permissionRes.groups); - this.modalRef = this.modalService.open(this.modalContent, { size: 'lg' }); - this.visibleChange.emit(true); + this.visible = true; setTimeout(() => { this.setTabCheckboxState(); this.setGrantCheckboxState(); }, 0); - - from(this.modalRef.result) - .pipe(take(1)) - .subscribe( - data => { - this.setVisible(false); - }, - reason => { - this.setVisible(false); - }, - ); }); } - setVisible(value: boolean) { - this.visible = value; - this.visibleChange.emit(value); - } - ngOnChanges({ visible }: SimpleChanges): void { if (!visible) return; if (visible.currentValue) { this.openModal(); - } else if (visible.currentValue === false && this.modalService.hasOpenModals()) { - this.modalRef.close(); + } else if (visible.currentValue === false && this.visible) { + this.visible = false; } } }