@@ -41,16 +41,18 @@ export class OrganizationService {
41
41
42
42
constructor ( ) {
43
43
// Fetch current org data whenever user org id changes
44
- this . _userService . currentOrganizationId$ . pipe (
45
- takeUntil ( this . _unsubscribeAll$ ) ,
46
- switchMap ( ( organizationId ) => {
47
- return combineLatest ( [
48
- this . getById ( organizationId ) ,
49
- this . getOrganizationUsers ( organizationId ) ,
50
- this . getOrganizationAccessLevelTree ( organizationId ) ,
51
- ] )
52
- } ) ,
53
- ) . subscribe ( )
44
+ this . _userService . currentOrganizationId$
45
+ . pipe (
46
+ takeUntil ( this . _unsubscribeAll$ ) ,
47
+ switchMap ( ( organizationId ) => {
48
+ return combineLatest ( [
49
+ this . getById ( organizationId ) ,
50
+ this . getOrganizationUsers ( organizationId ) ,
51
+ this . getOrganizationAccessLevelTree ( organizationId ) ,
52
+ ] )
53
+ } ) ,
54
+ )
55
+ . subscribe ( )
54
56
}
55
57
56
58
get ( org_id ?: number ) : Observable < Organization [ ] > | Observable < Organization > {
@@ -81,39 +83,35 @@ export class OrganizationService {
81
83
82
84
getOrganizationUsers ( orgId : number ) : Observable < OrganizationUser [ ] > {
83
85
const url = `/api/v3/organizations/${ orgId } /users/`
84
- return this . _httpClient
85
- . get < OrganizationUsersResponse > ( url )
86
- . pipe (
87
- map ( ( response ) => response . users . sort ( ( a , b ) => naturalSort ( a . last_name , b . last_name ) ) ) ,
88
- tap ( ( users ) => {
89
- this . _organizationUsers . next ( users )
90
- } ) ,
91
- catchError ( ( error : HttpErrorResponse ) => {
92
- return this . _errorService . handleError ( error , 'Error fetching organization users' )
93
- } ) ,
94
- )
86
+ return this . _httpClient . get < OrganizationUsersResponse > ( url ) . pipe (
87
+ map ( ( response ) => response . users . sort ( ( a , b ) => naturalSort ( a . last_name , b . last_name ) ) ) ,
88
+ tap ( ( users ) => {
89
+ this . _organizationUsers . next ( users )
90
+ } ) ,
91
+ catchError ( ( error : HttpErrorResponse ) => {
92
+ return this . _errorService . handleError ( error , 'Error fetching organization users' )
93
+ } ) ,
94
+ )
95
95
}
96
96
97
97
getOrganizationAccessLevelTree ( orgId : number ) : Observable < AccessLevelTree > {
98
98
const url = `/api/v3/organizations/${ orgId } /access_levels/tree`
99
- return this . _httpClient
100
- . get < AccessLevelTreeResponse > ( url )
101
- . pipe (
102
- map ( ( response ) => {
103
- // update response to include more usable accessLevelInstancesByDepth
104
- this . _accessLevelInstancesByDepth = this . _calculateAccessLevelInstancesByDepth ( response . access_level_tree , 0 )
105
- return {
106
- accessLevelNames : response . access_level_names ,
107
- accessLevelInstancesByDepth : this . _accessLevelInstancesByDepth ,
108
- }
109
- } ) ,
110
- tap ( ( accessLevelTree ) => {
111
- this . _accessLevelTree . next ( accessLevelTree )
112
- } ) ,
113
- catchError ( ( error : HttpErrorResponse ) => {
114
- return this . _errorService . handleError ( error , 'Error fetching organization access level tree' )
115
- } ) ,
116
- )
99
+ return this . _httpClient . get < AccessLevelTreeResponse > ( url ) . pipe (
100
+ map ( ( response ) => {
101
+ // update response to include more usable accessLevelInstancesByDepth
102
+ this . _accessLevelInstancesByDepth = this . _calculateAccessLevelInstancesByDepth ( response . access_level_tree , 0 )
103
+ return {
104
+ accessLevelNames : response . access_level_names ,
105
+ accessLevelInstancesByDepth : this . _accessLevelInstancesByDepth ,
106
+ }
107
+ } ) ,
108
+ tap ( ( accessLevelTree ) => {
109
+ this . _accessLevelTree . next ( accessLevelTree )
110
+ } ) ,
111
+ catchError ( ( error : HttpErrorResponse ) => {
112
+ return this . _errorService . handleError ( error , 'Error fetching organization access level tree' )
113
+ } ) ,
114
+ )
117
115
}
118
116
119
117
deleteOrganizationUser ( userId : number , orgId : number ) {
0 commit comments