feature-libs/organization/administration/components/user/services/current-user.service.ts
Properties |
Methods |
|
constructor(routingService: RoutingService, b2bUserService: B2BUserService)
|
|||||||||
|
Parameters :
|
| getError | ||||||
getError(code: string)
|
||||||
|
Inherited from
CurrentItemService
|
||||||
|
Defined in
CurrentItemService:32
|
||||||
|
Parameters :
Returns :
Observable<boolean>
|
| Protected getItem | ||||||
getItem(code: string)
|
||||||
|
Inherited from
CurrentItemService
|
||||||
|
Defined in
CurrentItemService:28
|
||||||
|
Parameters :
Returns :
Observable<B2BUser>
|
| Protected getParamKey |
getParamKey()
|
|
Inherited from
CurrentItemService
|
|
Defined in
CurrentItemService:24
|
|
Returns :
any
|
| getRouterParam | ||||||
getRouterParam(paramKey: string)
|
||||||
|
Inherited from
CurrentItemService
|
||||||
|
Defined in
CurrentItemService:55
|
||||||
|
Parameters :
Returns :
Observable<string>
|
| Readonly name$ |
Type : Observable<string>
|
Default value : this.item$.pipe(
map((user: B2BUser) => user.name)
)
|
| Readonly b2bUnit$ |
Type : Observable<string>
|
Default value : this.routingService
.getParams()
.pipe(pluck(ROUTE_PARAMS.unitCode), distinctUntilChanged())
|
|
Inherited from
CurrentItemService
|
|
Defined in
CurrentItemService:40
|
|
Observes the b2bUnit based on the unitCode route parameter. |
| Readonly item$ |
Type : Observable<T>
|
Default value : this.key$.pipe(
switchMap((code: string) => (code ? this.getItem(code) : of(null)))
)
|
|
Inherited from
CurrentItemService
|
|
Defined in
CurrentItemService:33
|
|
Observes the active item. The active item is loaded by the active |
| Readonly key$ |
Type : Observable<string>
|
Default value : this.routingService
.getParams()
.pipe(pluck(this.getParamKey()), distinctUntilChanged())
|
|
Inherited from
CurrentItemService
|
|
Defined in
CurrentItemService:24
|
|
Observes the key for the active organization item. The active key is observed from the list of route parameters. The full route parameter list is evaluated, including child routes. To allow for specific ("semantic") route parameters, the route parameter key is
retrieved from the |
import { Injectable } from '@angular/core';
import { B2BUser, RoutingService } from '@spartacus/core';
import { B2BUserService } from '@spartacus/organization/administration/core';
import { ROUTE_PARAMS } from '@spartacus/organization/administration/root';
import { Observable } from 'rxjs';
import { map } from 'rxjs/operators';
import { CurrentItemService } from '../../shared/current-item.service';
@Injectable({
providedIn: 'root',
})
export class CurrentUserService extends CurrentItemService<B2BUser> {
readonly name$: Observable<string> = this.item$.pipe(
map((user: B2BUser) => user.name)
);
constructor(
protected routingService: RoutingService,
protected b2bUserService: B2BUserService
) {
super(routingService);
}
protected getParamKey() {
return ROUTE_PARAMS.userCode;
}
protected getItem(code: string): Observable<B2BUser> {
return this.b2bUserService.get(code);
}
getError(code: string): Observable<boolean> {
return this.b2bUserService.getErrorState(code);
}
}