File

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

Extends

ConfiguratorAttributeSingleSelectionBaseComponent

Metadata

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

Index

Properties
Methods
Inputs
Outputs

Inputs

attribute
Type : Configurator.Attribute
ownerKey
Type : string

Outputs

selectionChange
Type : EventEmitter

Methods

extractProductCardParameters
extractProductCardParameters(value: Configurator.Value)

Extract corresponding product card parameters

Parameters :
Name Type Optional Description
value Configurator.Value No
  • Value
  • New product card options
Protected getFocusIdOfNearestValue
getFocusIdOfNearestValue(currentValue: Configurator.Value)
Parameters :
Name Type Optional
currentValue Configurator.Value No
Returns : string
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

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 } 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>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""