File

projects/congarevenuecloud/elements/src/lib/line-item-table-row/services/user-view-mapping.service.ts

Description

User view mapping service maps the response from user view service to CartItemView interface.

Usage

Example :
import { UserViewMappingService, AObjectService  } from '@congarevenuecloud/ecommerce';
constructor(private mappingService: UserViewMappingService) { }
// or
export class MyService extends AObjectService {
private mappingService: UserViewMappingService = this.injector.get(UserViewMappingService);
}

Index

Properties
Methods

Constructor

constructor(userViewService: UserViewService, userService: UserService)
Parameters :
Name Type Optional
userViewService UserViewService No
userService UserService No

Methods

getCurrentView
getCurrentView()

This method returns the list of CartItemView records, for all cart item field selections available on cart page, for default flow.

Example:

Example :
import { UserViewMappingService } from '@congarevenuecloud/ecommerce';
constructor(private mappingService: UserViewMappingService) { }
ngOnInit(): void {
this.menuItems$ = this.mappingService.getCurrentView();
}
Returns : BehaviorSubject<Array<CartItemView>>

Behavior subject containing list of all CartItemView records.

getMyView
getMyView()

This method returns the list of CartItemView records, for all cart item field selections available on cart page, for user specific view.

Example:

Example :
import { UserViewMappingService } from '@congarevenuecloud/ecommerce';
constructor(private mappingService: UserViewMappingService) { }
ngOnInit(): void {
this.menuItems$ = this.mappingService.getMyView();
}
Returns : BehaviorSubject<Array<CartItemView>>

Behavior subject containing list of all CartItemView records.

getSelectedItems
getSelectedItems()

This method returns the list of CartItemView records, for the selected cart item fields on cart page.

Example:

Example :
import { UserViewMappingService } from '@congarevenuecloud/ecommerce';
constructor(private mappingService: UserViewMappingService) { }
ngOnInit(): void {
this.menuItems$ = this.mappingService.getSelectedItems();
}
Returns : BehaviorSubject<Array<CartItemView>>

Behavior subject containing list of selected cart item view.

getView
getView(cartItemView$: BehaviorSubject>, storageKey: string)

Initializes BehaviorSubject containing an array of CartItemView objects.

Example:

Example :
import { UserViewMappingService } from '@congarevenuecloud/ecommerce';
constructor(private mappingService: UserViewMappingService) { }
getView(): void {
this.mappingService.getView(cartItemView$: BehaviorSubject<Array<CartItemView>>,storageKey: string).subscribe(...);
}
Parameters :
Name Type Optional Description
cartItemView$ BehaviorSubject<Array<CartItemView>> No

A BehaviorSubject that holds an array of CartItemView objects.

storageKey string No

A string representing the key to access the data in the local storage.

Returns : BehaviorSubject<Array<CartItemView>>

A BehaviorSubject containing the array of CartItemView objects.

mapUserView
mapUserView(cartColumns: Array)

This method maps list of cart column records to a list of CartItemView.

Example:

Example :
import { UserViewMappingService } from '@congarevenuecloud/ecommerce';
constructor(private mappingService: UserViewMappingService) { }
this.subscriptions.push(this.userViewService.mapUserView(cartColumns).subscribe(res => {
const myView = this.mappingService.mapUserView(cartColumns);
}));
}
Parameters :
Name Type Optional
cartColumns Array<CartColumn> No
Returns : Array<CartItemView>

list of mapped CartItemView records.

saveCartColumnView
saveCartColumnView(cartColumnView: CartColumnView)

Saves a CartColumnView to a user's view. This function updates the user's view by either adding a new CartColumnView or updating an existing one.

Example:

Example :
import { UserViewMappingService } from '@congarevenuecloud/ecommerce';
constructor(private mappingService: UserViewMappingService) { }
saveCartColumnView(): void {
this.mappingService.saveCartColumnView(cartColumnView:CartColumnView).subscribe(...);
}
Parameters :
Name Type Optional Description
cartColumnView CartColumnView No

The CartColumnView object to be saved.

An Observable emitting an array of CartColumnView object.

updateUserSelections
updateUserSelections(view: Array, targetview: "system" | "user")

This method updates the cart page with cart item fields selected from line item menu component. The changes are available in browser storage and won't be persisted to system.

Example:

Example :
import { UserViewMappingService } from '@congarevenuecloud/ecommerce';
constructor(private mappingService: UserViewMappingService) { }
saveSelections(): void {
this.mappingService.updateUserSelections(cartItemView: Array<CartItemView>).subscribe(...);
}
Parameters :
Name Type Optional Description
view Array<CartItemView> No

list of cart item view records.

targetview "system" | "user" No
Returns : void

Properties

cartItemMyView$
Type : BehaviorSubject<Array<CartItemView>>
Default value : new BehaviorSubject(null)

Behavior subject containing list of cart item views, for all cart item field selections available on cart page for user specific view.

cartItemView$
Type : BehaviorSubject<Array<CartItemView>>
Default value : new BehaviorSubject(null)

Behavior subject containing list of cart item views, for all cart item field selections available on cart page.

selectedItems$
Type : BehaviorSubject<Array<CartItemView>>
Default value : new BehaviorSubject(null)

Behavior subject containing list of cart item views, for the selected cart item fields on cart page.

results matching ""

    No results matching ""