File

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

Extends

ItemService

Index

Properties
Methods

Constructor

constructor(currentItemService: CurrentUserService, routingService: RoutingService, formService: UserFormService, userService: B2BUserService)
Parameters :
Name Type Optional
currentItemService CurrentUserService No
routingService RoutingService No
formService UserFormService No
userService B2BUserService No

Methods

Protected create
create(value: B2BUser)
Inherited from ItemService
Defined in ItemService:36
Parameters :
Name Type Optional
value B2BUser No
Protected getDetailsRoute
getDetailsRoute()
Inherited from ItemService
Defined in ItemService:43
Returns : string
launchDetails
launchDetails(item: B2BUser)
Inherited from ItemService
Defined in ItemService:48
Parameters :
Name Type Optional
item B2BUser No
Returns : void
load
load(code: string)
Inherited from ItemService
Defined in ItemService:25
Parameters :
Name Type Optional
code string No
Returns : Observable<B2BUser>
update
update(code, value: B2BUser)
Inherited from ItemService
Defined in ItemService:30
Parameters :
Name Type Optional
code No
value B2BUser No
Protected buildRouteParams
buildRouteParams(item: T)
Inherited from ItemService
Defined in ItemService:109

Returns the route parameters that are used when launching the details page. The route parameters default to the actual item, but can be further populated in implementations.

Customized route parameters are useful in case the actual item doesn't match the expected route parameters. You can manipulate the parameter data.

Parameters :
Name Type Optional
item T No
Returns : any
Optional delete
delete(key: string, additionalParam?: string)
Inherited from ItemService
Defined in ItemService:61

Deletes an item.

Parameters :
Name Type Optional
key string No
additionalParam string Yes
getForm
getForm(item?: T)
Inherited from ItemService
Defined in ItemService:85
Parameters :
Name Type Optional
item T Yes
Returns : FormGroup
getRouterParam
getRouterParam(key: string)
Inherited from ItemService
Defined in ItemService:113
Parameters :
Name Type Optional
key string No
Returns : Observable<string>
save
save(form: FormGroup, key?: string)
Inherited from ItemService
Defined in ItemService:41
Parameters :
Name Type Optional
form FormGroup No
key string Yes
setEditMode
setEditMode(isInEdit: boolean)
Inherited from ItemService
Defined in ItemService:120

Sets to true when the user is on the entity item form page

Parameters :
Name Type Optional
isInEdit boolean No
Returns : void

Properties

current$
Default value : this.currentItemService.item$
Inherited from ItemService
Defined in ItemService:26
error$
Type : Observable<boolean>
Default value : this.key$.pipe( switchMap((key) => this.currentItemService.getError(key)) )
Inherited from ItemService
Defined in ItemService:37
isInEditMode$
Type : Observable<boolean>
Default value : new BehaviorSubject<boolean>(false)
Inherited from ItemService
Defined in ItemService:28
key$
Default value : this.currentItemService.key$
Inherited from ItemService
Defined in ItemService:25
unit$
Type : Observable<string>
Default value : this.currentItemService.b2bUnit$
Inherited from ItemService
Defined in ItemService:35

Returns the current business unit code.

The current unit is driven by the route parameter.

import { Injectable } from '@angular/core';
import { B2BUser, RoutingService } from '@spartacus/core';
import {
  B2BUserService,
  OrganizationItemStatus,
} from '@spartacus/organization/administration/core';
import { Observable } from 'rxjs';
import { ItemService } from '../../shared/item.service';
import { UserFormService } from '../form/user-form.service';
import { CurrentUserService } from './current-user.service';

@Injectable({
  providedIn: 'root',
})
export class UserItemService extends ItemService<B2BUser> {
  constructor(
    protected currentItemService: CurrentUserService,
    protected routingService: RoutingService,
    protected formService: UserFormService,
    protected userService: B2BUserService
  ) {
    super(currentItemService, routingService, formService);
  }

  load(code: string): Observable<B2BUser> {
    this.userService.load(code);
    return this.userService.get(code);
  }

  update(code, value: B2BUser): Observable<OrganizationItemStatus<B2BUser>> {
    delete value.approvers;
    this.userService.update(code, value);
    return this.userService.getLoadingStatus(code);
  }

  protected create(
    value: B2BUser
  ): Observable<OrganizationItemStatus<B2BUser>> {
    this.userService.create(value);
    return this.userService.getLoadingStatus(null);
  }

  protected getDetailsRoute(): string {
    return 'orgUserDetails';
  }

  // @override to avoid errors while creation
  launchDetails(item: B2BUser): void {
    if (item.customerId !== null) {
      super.launchDetails(item);
    }
  }
}

result-matching ""

    No results matching ""