File

feature-libs/product-configurator/rulebased/components/attribute/types/radio-button/configurator-attribute-radio-button.component.ts

Extends

ConfiguratorAttributeSingleSelectionBaseComponent

Implements

OnInit

Metadata

changeDetection ChangeDetectionStrategy.OnPush
selector cx-configurator-attribute-radio-button
templateUrl ./configurator-attribute-radio-button.component.html

Index

Properties
Methods
Inputs
Outputs

Constructor

constructor(quantityService: ConfiguratorAttributeQuantityService)
Parameters :
Name Type Optional
quantityService ConfiguratorAttributeQuantityService No

Inputs

attribute
Type : Configurator.Attribute
ownerKey
Type : string

Outputs

selectionChange
Type : EventEmitter

Methods

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

attributeRadioButtonForm
Default value : new FormControl('')
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, OnInit } from '@angular/core';
import { FormControl } from '@angular/forms';
import { ConfiguratorAttributeQuantityService } from '../../quantity/configurator-attribute-quantity.service';
import { ConfiguratorAttributeSingleSelectionBaseComponent } from '../base/configurator-attribute-single-selection-base.component';

@Component({
  selector: 'cx-configurator-attribute-radio-button',
  templateUrl: './configurator-attribute-radio-button.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
})
export class ConfiguratorAttributeRadioButtonComponent
  extends ConfiguratorAttributeSingleSelectionBaseComponent
  implements OnInit
{
  attributeRadioButtonForm = new FormControl('');

  constructor(protected quantityService: ConfiguratorAttributeQuantityService) {
    super(quantityService);
  }

  ngOnInit(): void {
    this.attributeRadioButtonForm.setValue(this.attribute.selectedSingleValue);
  }
}
<fieldset>
  <legend style="display: none">{{ attribute.label }}</legend>
  <div id="{{ createAttributeIdForConfigurator(attribute) }}">
    <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>

    <div class="form-check" *ngFor="let value of attribute.values">
      <div class="cx-value-label-pair">
        <input
          id="{{
            createAttributeValueIdForConfigurator(attribute, value.valueCode)
          }}"
          class="form-check-input"
          type="radio"
          formcontrolname="attributeRadioButtonForm"
          [formControl]="attributeRadioButtonForm"
          [attr.required]="attribute.required"
          [value]="value.valueCode"
          name="{{ createAttributeIdForConfigurator(attribute) }}"
          attr.name="{{ createAttributeIdForConfigurator(attribute) }}"
          [cxFocus]="{ key: attribute.name + '-' + value.name }"
          attr.aria-labelledby="{{
            createAriaLabelledBy('label', attribute.name, value.valueCode)
          }}"
          [attr.aria-checked]="
            attributeRadioButtonForm.value === value.valueCode ? true : false
          "
          [attr.checked]="
            attributeRadioButtonForm.value === value.valueCode
              ? 'checked'
              : null
          "
          (change)="onSelect(value.valueCode)"
        />
        <label
          id="{{ createValueUiKey('label', attribute.name, value.valueCode) }}"
          for="{{
            createAttributeValueIdForConfigurator(attribute, value.valueCode)
          }}"
          class="form-check-label form-radio-label"
          >{{ value.valueDisplay }}</label
        >
      </div>
      <div class="cx-value-price">
        <cx-configurator-price
          [formula]="extractValuePriceFormulaParameters(value)"
        ></cx-configurator-price>
      </div>
    </div>
  </div>
</fieldset>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""