feature-libs/product-configurator/rulebased/components/attribute/types/single-selection-bundle/configurator-attribute-single-selection-bundle.component.ts
ConfiguratorAttributeSingleSelectionBaseComponent
| changeDetection | ChangeDetectionStrategy.OnPush |
| selector | cx-configurator-attribute-single-selection-bundle |
| templateUrl | ./configurator-attribute-single-selection-bundle.component.html |
Properties |
Methods |
Inputs |
Outputs |
| attribute | |
Type : Configurator.Attribute
|
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|
| ownerKey | |
Type : string
|
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|
| selectionChange | |
Type : EventEmitter
|
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|
| extractProductCardParameters | ||||||||
extractProductCardParameters(value: Configurator.Value)
|
||||||||
|
Extract corresponding product card parameters
Parameters :
|
| Protected getFocusIdOfNearestValue | ||||||
getFocusIdOfNearestValue(currentValue: Configurator.Value)
|
||||||
|
Parameters :
Returns :
string
|
| extractPriceFormulaParameters |
extractPriceFormulaParameters()
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|
Extract corresponding price formula parameters. For the single-selection attribute types the complete price formula should be displayed at the attribute level.
Returns :
ConfiguratorPriceComponentOptions
|
| extractQuantityParameters | ||||||||
extractQuantityParameters(form?: FormControl)
|
||||||||
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
||||||||
|
Extract corresponding quantity parameters
Parameters :
|
| extractValuePriceFormulaParameters | ||||||||
extractValuePriceFormulaParameters(value?: Configurator.Value)
|
||||||||
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
||||||||
|
Extract corresponding value price formula parameters. For the single-selection attribute types only value price should be displayed at the value level.
Parameters :
|
| Protected getInitialQuantity | ||||||
getInitialQuantity(form?: FormControl)
|
||||||
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
||||||
|
Parameters :
Returns :
number
|
| Protected getSelectedValuePrice |
getSelectedValuePrice()
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|
Returns :
Configurator.PriceDetails | undefined
|
| onChangeQuantity | |||||||||
onChangeQuantity(eventObject: any, form?: FormControl)
|
|||||||||
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|||||||||
|
Parameters :
Returns :
void
|
| onHandleQuantity | ||||||
onHandleQuantity(quantity: number)
|
||||||
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
||||||
|
Parameters :
Returns :
void
|
| onSelect | ||||||
onSelect(value: string)
|
||||||
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
||||||
|
Parameters :
Returns :
void
|
| attribute |
Type : Configurator.Attribute
|
Decorators :
@Input()
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
| loading$ |
Default value : new BehaviorSubject<boolean>(false)
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
| ownerKey |
Type : string
|
Decorators :
@Input()
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
| selectionChange |
Default value : new EventEmitter<ConfigFormUpdateEvent>()
|
Decorators :
@Output()
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { Configurator } from '../../../../core/model/configurator.model';
import { ConfiguratorAttributeProductCardComponentOptions } from '../../product-card/configurator-attribute-product-card.component';
import { ConfiguratorAttributeSingleSelectionBaseComponent } from '../base/configurator-attribute-single-selection-base.component';
@Component({
selector: 'cx-configurator-attribute-single-selection-bundle',
templateUrl:
'./configurator-attribute-single-selection-bundle.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ConfiguratorAttributeSingleSelectionBundleComponent extends ConfiguratorAttributeSingleSelectionBaseComponent {
/**
* Extract corresponding product card parameters
*
* @param {Configurator.Value} value - Value
* @return {ConfiguratorAttributeProductCardComponentOptions} - New product card options
*/
extractProductCardParameters(
value: Configurator.Value
): ConfiguratorAttributeProductCardComponentOptions {
return {
hideRemoveButton: this.attribute.required,
fallbackFocusId: this.getFocusIdOfNearestValue(value),
productBoundValue: value,
loading$: this.loading$,
attributeId: this.getAttributeCode(this.attribute),
};
}
protected getFocusIdOfNearestValue(currentValue: Configurator.Value): string {
if (!this.attribute.values) {
return 'n/a';
}
let prevIdx = this.attribute.values.findIndex(
(value) => value?.valueCode === currentValue?.valueCode
);
prevIdx--;
if (prevIdx < 0) {
prevIdx = this.attribute.values?.length > 1 ? 1 : 0;
}
return this.createFocusId(
this.getAttributeCode(this.attribute).toString(),
this.attribute.values[prevIdx]?.valueCode
);
}
}
<div
id="{{ createAttributeIdForConfigurator(attribute) }}"
*ngIf="attribute?.values?.length"
>
<div *ngIf="withQuantity" class="cx-attribute-level-quantity-price">
<cx-configurator-attribute-quantity
(changeQuantity)="onChangeQuantity($event)"
[quantityOptions]="extractQuantityParameters()"
></cx-configurator-attribute-quantity>
<cx-configurator-price
[formula]="extractPriceFormulaParameters()"
></cx-configurator-price>
</div>
<cx-configurator-attribute-product-card
[id]="createAttributeValueIdForConfigurator(attribute, value?.valueCode)"
(handleDeselect)="onSelect('')"
(handleSelect)="onSelect($event)"
*ngFor="let value of attribute?.values"
[productCardOptions]="extractProductCardParameters(value)"
>
</cx-configurator-attribute-product-card>
</div>