feature-libs/organization/administration/components/user/services/user-item.service.ts
Properties |
Methods |
|
constructor(currentItemService: CurrentUserService, routingService: RoutingService, formService: UserFormService, userService: B2BUserService)
|
|||||||||||||||
|
Parameters :
|
| Protected create | ||||||
create(value: B2BUser)
|
||||||
|
Inherited from
ItemService
|
||||||
|
Defined in
ItemService:36
|
||||||
|
Parameters :
|
| Protected getDetailsRoute |
getDetailsRoute()
|
|
Inherited from
ItemService
|
|
Defined in
ItemService:43
|
|
Returns :
string
|
| launchDetails | ||||||
launchDetails(item: B2BUser)
|
||||||
|
Inherited from
ItemService
|
||||||
|
Defined in
ItemService:48
|
||||||
|
Parameters :
Returns :
void
|
| load | ||||||
load(code: string)
|
||||||
|
Inherited from
ItemService
|
||||||
|
Defined in
ItemService:25
|
||||||
|
Parameters :
Returns :
Observable<B2BUser>
|
| update | |||||||||
update(code, value: B2BUser)
|
|||||||||
|
Inherited from
ItemService
|
|||||||||
|
Defined in
ItemService:30
|
|||||||||
|
Parameters :
|
| 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 :
Returns :
any
|
| Optional delete |
delete(key: string, additionalParam?: string)
|
|
Inherited from
ItemService
|
|
Defined in
ItemService:61
|
|
Deletes an item.
Returns :
Observable<OrganizationItemStatus<T>>
|
| getForm | ||||||
getForm(item?: T)
|
||||||
|
Inherited from
ItemService
|
||||||
|
Defined in
ItemService:85
|
||||||
|
Parameters :
Returns :
FormGroup
|
| getRouterParam | ||||||
getRouterParam(key: string)
|
||||||
|
Inherited from
ItemService
|
||||||
|
Defined in
ItemService:113
|
||||||
|
Parameters :
Returns :
Observable<string>
|
| save |
save(form: FormGroup, key?: string)
|
|
Inherited from
ItemService
|
|
Defined in
ItemService:41
|
|
Returns :
Observable<OrganizationItemStatus<T>>
|
| 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 :
Returns :
void
|
| 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);
}
}
}