File

feature-libs/organization/administration/components/user-group/services/current-user-group.service.ts

Extends

CurrentItemService

Index

Properties
Methods

Constructor

constructor(routingService: RoutingService, userGroupService: UserGroupService)
Parameters :
Name Type Optional
routingService RoutingService No
userGroupService UserGroupService No

Methods

getError
getError(code: string)
Inherited from CurrentItemService
Parameters :
Name Type Optional
code string No
Returns : Observable<boolean>
Protected getItem
getItem(code: string)
Inherited from CurrentItemService
Parameters :
Name Type Optional
code string No
Returns : Observable<UserGroup>
Protected getParamKey
getParamKey()
Inherited from CurrentItemService
Returns : any
getRouterParam
getRouterParam(paramKey: string)
Inherited from CurrentItemService
Parameters :
Name Type Optional
paramKey string No
Returns : Observable<string>

Properties

Readonly b2bUnit$
Type : Observable<string>
Default value : this.routingService .getParams() .pipe(pluck(ROUTE_PARAMS.unitCode), distinctUntilChanged())
Inherited from CurrentItemService

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

Observes the active item.

The active item is loaded by the active key$.

Readonly key$
Type : Observable<string>
Default value : this.routingService .getParams() .pipe(pluck(this.getParamKey()), distinctUntilChanged())
Inherited from CurrentItemService

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 getParamKey.

import { Injectable } from '@angular/core';
import { RoutingService } from '@spartacus/core';
import {
  UserGroup,
  UserGroupService,
} from '@spartacus/organization/administration/core';
import { ROUTE_PARAMS } from '@spartacus/organization/administration/root';
import { Observable } from 'rxjs';
import { CurrentItemService } from '../../shared/current-item.service';

@Injectable({
  providedIn: 'root',
})
export class CurrentUserGroupService extends CurrentItemService<UserGroup> {
  constructor(
    protected routingService: RoutingService,
    protected userGroupService: UserGroupService
  ) {
    super(routingService);
  }

  protected getParamKey() {
    return ROUTE_PARAMS.userGroupCode;
  }

  protected getItem(code: string): Observable<UserGroup> {
    return this.userGroupService.get(code);
  }

  getError(code: string): Observable<boolean> {
    return this.userGroupService.getErrorState(code);
  }
}

result-matching ""

    No results matching ""