feature-libs/product-configurator/rulebased/components/attribute/types/single-selection-bundle-dropdown/configurator-attribute-single-selection-bundle-dropdown.component.ts
ConfiguratorAttributeSingleSelectionBaseComponent
| changeDetection | ChangeDetectionStrategy.OnPush |
| selector | cx-configurator-attribute-single-selection-bundle-dropdown |
| templateUrl | ./configurator-attribute-single-selection-bundle-dropdown.component.html |
Properties |
Methods |
Inputs |
Outputs |
| group | |
Type : string
|
|
| attribute | |
Type : Configurator.Attribute
|
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|
| ownerKey | |
Type : string
|
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|
| selectionChange | |
Type : EventEmitter
|
|
|
Inherited from
ConfiguratorAttributeSingleSelectionBaseComponent
|
|
| extractProductCardParameters |
extractProductCardParameters()
|
|
Extract corresponding product card parameters
|
| ngOnInit |
ngOnInit()
|
|
Returns :
void
|
| 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
|
| attributeDropDownForm |
Default value : new FormControl('')
|
| group |
Type : string
|
Decorators :
@Input()
|
| selectionValue |
Type : Configurator.Value
|
| 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,
Input,
OnInit,
} from '@angular/core';
import { FormControl } from '@angular/forms';
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-dropdown',
templateUrl:
'./configurator-attribute-single-selection-bundle-dropdown.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ConfiguratorAttributeSingleSelectionBundleDropdownComponent
extends ConfiguratorAttributeSingleSelectionBaseComponent
implements OnInit
{
attributeDropDownForm = new FormControl('');
selectionValue: Configurator.Value;
@Input() group: string;
ngOnInit() {
this.attributeDropDownForm.setValue(this.attribute.selectedSingleValue);
const values = this.attribute.values;
if (values && values.length > 0) {
const value = values.find((value) => value.selected);
if (value) {
this.selectionValue = value;
}
}
}
/**
* Extract corresponding product card parameters
*
* @return {ConfiguratorAttributeProductCardComponentOptions} - New product card options
*/
extractProductCardParameters(): ConfiguratorAttributeProductCardComponentOptions {
return {
hideRemoveButton: true,
productBoundValue: this.selectionValue,
singleDropdown: true,
withQuantity: false,
loading$: this.loading$,
attributeId: this.getAttributeCode(this.attribute),
};
}
}
<div
id="{{ createAttributeIdForConfigurator(attribute) }}"
class="form-group"
*ngIf="attribute?.values?.length"
>
<select
class="form-control"
[formControl]="attributeDropDownForm"
[cxFocus]="{ key: attribute.name }"
(change)="onSelect(attributeDropDownForm.value)"
>
<option
*ngFor="let item of attribute.values"
[label]="item.valueDisplay"
[selected]="item.selected"
[value]="item.valueCode"
>
{{ item.valueDisplay }}
</option>
</select>
</div>
<cx-configurator-attribute-product-card
*ngIf="selectionValue?.valueCode !== '0'"
id="{{
createAttributeValueIdForConfigurator(attribute, selectionValue.valueCode)
}}"
(handleDeselect)="onSelect('0')"
[productCardOptions]="extractProductCardParameters()"
>
</cx-configurator-attribute-product-card>
<div *ngIf="withQuantity" class="cx-attribute-level-quantity-price">
<cx-configurator-attribute-quantity
(changeQuantity)="onChangeQuantity($event, attributeDropDownForm)"
[quantityOptions]="extractQuantityParameters(attributeDropDownForm)"
></cx-configurator-attribute-quantity>
<cx-configurator-price
[formula]="extractPriceFormulaParameters()"
></cx-configurator-price>
</div>