File

feature-libs/product-configurator/rulebased/components/attribute/types/single-selection-bundle-dropdown/configurator-attribute-single-selection-bundle-dropdown.component.ts

Extends

ConfiguratorAttributeSingleSelectionBaseComponent

Implements

OnInit

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector cx-configurator-attribute-single-selection-bundle-dropdown
templateUrl ./configurator-attribute-single-selection-bundle-dropdown.component.html

Index

Properties
Methods
Inputs
Outputs

Inputs

group
Type : string
attribute
Type : Configurator.Attribute
ownerKey
Type : string

Outputs

selectionChange
Type : EventEmitter

Methods

extractProductCardParameters
extractProductCardParameters()

Extract corresponding product card parameters

  • New product card options
ngOnInit
ngOnInit()
Returns : void
extractPriceFormulaParameters
extractPriceFormulaParameters()

Extract corresponding price formula parameters. For the single-selection attribute types the complete price formula should be displayed at the attribute level.

  • New price formula
extractQuantityParameters
extractQuantityParameters(form?: FormControl)

Extract corresponding quantity parameters

Parameters :
Name Type Optional Description
form FormControl Yes
  • Form control
  • New quantity options
extractValuePriceFormulaParameters
extractValuePriceFormulaParameters(value?: Configurator.Value)

Extract corresponding value price formula parameters. For the single-selection attribute types only value price should be displayed at the value level.

Parameters :
Name Type Optional Description
value Configurator.Value Yes
  • Configurator value
  • New price formula
Protected getInitialQuantity
getInitialQuantity(form?: FormControl)
Parameters :
Name Type Optional
form FormControl Yes
Returns : number
Protected getSelectedValuePrice
getSelectedValuePrice()
onChangeQuantity
onChangeQuantity(eventObject: any, form?: FormControl)
Parameters :
Name Type Optional
eventObject any No
form FormControl Yes
Returns : void
onHandleQuantity
onHandleQuantity(quantity: number)
Parameters :
Name Type Optional
quantity number No
Returns : void
onSelect
onSelect(value: string)
Parameters :
Name Type Optional
value string No
Returns : void

Properties

attributeDropDownForm
Default value : new FormControl('')
group
Type : string
Decorators :
@Input()
selectionValue
Type : Configurator.Value
attribute
Type : Configurator.Attribute
Decorators :
@Input()
loading$
Default value : new BehaviorSubject<boolean>(false)
ownerKey
Type : string
Decorators :
@Input()
selectionChange
Default value : new EventEmitter<ConfigFormUpdateEvent>()
Decorators :
@Output()
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>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""