11import { AfterContentInit , AfterViewChecked , Component , DoCheck , OnChanges , OnInit } from '@angular/core' ;
22import { Router } from '@angular/router' ;
33import { Organisation } from '@app/admin/organisation/organisation.model' ;
4+ import { PermissionType } from '@app/admin/permission/permission.model' ;
45import { UserResponse } from '@app/admin/users/user.model' ;
56import { AuthService } from '@app/auth/auth.service' ;
67import { SharedVariableService } from '@app/shared-variable/shared-variable.service' ;
@@ -12,7 +13,7 @@ import { TranslateService } from '@ngx-translate/core';
1213 templateUrl : './organisation-dropdown.component.html' ,
1314 styleUrls : [ './organisation-dropdown.component.scss' ]
1415} )
15- export class OrganisationDropdownComponent implements OnInit {
16+ export class OrganisationDropdownComponent implements OnInit , OnChanges {
1617 public organisations : Organisation [ ] ;
1718 public user : UserResponse ;
1819
@@ -33,9 +34,9 @@ export class OrganisationDropdownComponent implements OnInit {
3334 this . getAllowedOrganizations ( ) ;
3435 }
3536
36- // ngOnChanges(): void {
37- // this.getAllowedOrganizations();
38- // }
37+ ngOnChanges ( ) : void {
38+ this . getAllowedOrganizations ( ) ;
39+ }
3940
4041 getAllowedOrganizations ( ) {
4142 this . authService . me ( ) . subscribe ( ( response ) => {
@@ -54,6 +55,10 @@ export class OrganisationDropdownComponent implements OnInit {
5455 } ) ;
5556 }
5657
58+ isOrganisationAdmin ( orgId : number ) {
59+ return this . user . permissions . some ( x => x . type === PermissionType . OrganizationAdmin && x . organization . id === + orgId ) ;
60+ }
61+
5762 public onChange ( value ) {
5863 this . setSelectedOrganisation ( value ) ;
5964 this . sharedVariable . setValue ( value ) ;
0 commit comments