feature-libs/organization/administration/components/user-group/users/user-group-user-list.service.ts
Properties |
|
Methods |
|
constructor(tableService: TableService, userGroupService: UserGroupService, userService: B2BUserService)
|
||||||||||||
|
Parameters :
|
| assign |
assign(userGroupCode: string, customerId: string)
|
|
Inherited from
SubListService
|
|
Defined in
SubListService:47
|
|
Assign user to the user group. |
| Protected load | ||||||||||||
load(pagination: PaginationModel, code: string)
|
||||||||||||
|
Inherited from
ListService
|
||||||||||||
|
Defined in
ListService:36
|
||||||||||||
|
Loads all b2b users.
Parameters :
Returns :
Observable<EntitiesModel<B2BUser>>
|
| unassign |
unassign(userGroupCode: string, customerId: string)
|
|
Inherited from
SubListService
|
|
Defined in
SubListService:59
|
|
Unassigns the user from the user group. |
| unassignAllMembers | ||||||
unassignAllMembers(userGroupCode: string)
|
||||||
|
Parameters :
|
| Protected filterSelected | ||||||
filterSelected(list: EntitiesModel<T>)
|
||||||
|
Inherited from
SubListService
|
||||||
|
Defined in
SubListService:43
|
||||||
|
As we can't filter with the backend API, we do this client side.
Parameters :
Returns :
EntitiesModel<T>
|
| getData | ||||||
getData(...args: any)
|
||||||
|
Inherited from
ListService
|
||||||
|
Defined in
ListService:93
|
||||||
|
Loads the data by delegating to the The load method is streamed from the
Parameters :
Returns :
Observable<EntitiesModel<T>>
|
| getStructure |
getStructure()
|
|
Inherited from
ListService
|
|
Defined in
ListService:112
|
|
Returns the The table structure is build by the
Returns :
Observable<TableStructure>
|
| hasGhostData | ||||||
hasGhostData(data: EntitiesModel<T>)
|
||||||
|
Inherited from
ListService
|
||||||
|
Defined in
ListService:143
|
||||||
|
Indicates whether the given data equals to the ghost data. This is used to validate the initial loading state, which is different from the loading state; the loading state occurs while sorting and paginating, where as the initial loading state only happens at the very first load.
Parameters :
Returns :
boolean
|
| key |
key()
|
|
Inherited from
ListService
|
|
Defined in
ListService:82
|
|
Indicates the unique key for the item model. The key is different for various
organizations, i.e.
Returns :
string
|
| sort | |||||||||
sort(pagination: P, _obsoleteSort?: string)
|
|||||||||
|
Inherited from
ListService
|
|||||||||
|
Defined in
ListService:131
|
|||||||||
|
Updates the sort code for the PaginationModel. The
Parameters :
Returns :
void
|
| view | |||||||||
view(pagination: P, nextPage?: number)
|
|||||||||
|
Inherited from
ListService
|
|||||||||
|
Defined in
ListService:122
|
|||||||||
|
Views the page.
Parameters :
Returns :
void
|
| Protected _domainType |
Default value : OrganizationTableType.USER
|
|
Inherited from
ListService
|
|
Defined in
ListService:19
|
| Protected tableType |
Default value : OrganizationTableType.USER_GROUP_USERS
|
|
Inherited from
ListService
|
|
Defined in
ListService:18
|
| Protected defaultTableStructure |
Type : ResponsiveTableConfiguration
|
Default value : {
options: { layout: TableLayout.VERTICAL },
}
|
|
Inherited from
ListService
|
|
Defined in
ListService:19
|
|
The default table structure for sub lists is only showing tables with vertical layout. |
| Protected ghostData |
Default value : { values: new Array(3) } as EntitiesModel<T>
|
|
Inherited from
ListService
|
|
Defined in
ListService:26
|
| notification$ |
Type : Subject<any>
|
Default value : new Subject()
|
|
Inherited from
ListService
|
|
Defined in
ListService:42
|
| Protected pagination$ |
Type : BehaviorSubject<P>
|
Default value : new BehaviorSubject({
pageSize: 10,
} as any as P)
|
|
Inherited from
ListService
|
|
Defined in
ListService:72
|
|
The pagination state of the listing. The pagination size defaults to 10, but can be overridden by the table configuration for each entity type. |
import { Injectable } from '@angular/core';
import { EntitiesModel, PaginationModel, B2BUser } from '@spartacus/core';
import {
UserGroup,
UserGroupService,
B2BUserService,
OrganizationItemStatus,
} from '@spartacus/organization/administration/core';
import { TableService } from '@spartacus/storefront';
import { Observable } from 'rxjs';
import { SubListService } from '../../shared/sub-list/sub-list.service';
import { OrganizationTableType } from '../../shared/organization.model';
@Injectable({
providedIn: 'root',
})
export class UserGroupUserListService extends SubListService<B2BUser> {
protected tableType = OrganizationTableType.USER_GROUP_USERS;
protected _domainType = OrganizationTableType.USER;
constructor(
protected tableService: TableService,
protected userGroupService: UserGroupService,
protected userService: B2BUserService
) {
super(tableService);
}
/**
*
* @override
* Loads all b2b users.
*
* @param code The user group code.
*/
protected load(
pagination: PaginationModel,
code: string
): Observable<EntitiesModel<B2BUser>> {
return this.userGroupService.getAvailableOrgCustomers(code, pagination);
}
/**
* @override
* Assign user to the user group.
*/
assign(
userGroupCode: string,
customerId: string
): Observable<OrganizationItemStatus<B2BUser>> {
this.userGroupService.assignMember(userGroupCode, customerId);
return this.userService.getLoadingStatus(customerId);
}
/**
* @override
* Unassigns the user from the user group.
*/
unassign(
userGroupCode: string,
customerId: string
): Observable<OrganizationItemStatus<B2BUser>> {
this.userGroupService.unassignMember(userGroupCode, customerId);
return this.userService.getLoadingStatus(customerId);
}
unassignAllMembers(
userGroupCode: string
): Observable<OrganizationItemStatus<UserGroup>> {
this.userGroupService.unassignAllMembers(userGroupCode);
return this.userGroupService.getLoadingStatus(userGroupCode);
}
}