Sha256: d91846d53ce313104055c56e85b67cd9a7fbbeacadb846692ba8ad23613e2d4a

Contents?: true

Size: 845 Bytes

Versions: 7

Compression:

Stored size: 845 Bytes

Contents

class NumberWithCurrency extends HTMLElement {
  connectedCallback() {
    this.currencySelector = this.querySelector('.number-with-currency-select');
    this.render()
    this.addEventListener('change', this);
  }

  handleEvent() {
    this.render()
  }

  get currency() {
    if (this.currencySelector) {
      return this.currencySelector.value;
    } else {
      return this.querySelector('.number-with-currency-addon')?.dataset?.currency;
    }
  }

  get currencySymbol() {
    const currency = this.currency;
    if (currency) {
      const currencyInfo = Spree.currencyInfo[currency];
      return currencyInfo[0];
    } else {
      return '';
    }
  }

  render() {
    this.querySelector('.number-with-currency-symbol').textContent = this.currencySymbol;
  }
}

customElements.define('number-with-currency', NumberWithCurrency);

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
solidus_promotions-4.4.2 app/javascript/backend/solidus_promotions/web_components/number_with_currency.js
solidus_promotions-4.4.1 app/javascript/backend/solidus_promotions/web_components/number_with_currency.js
solidus_friendly_promotions-1.9.3 app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js
solidus_promotions-4.4.0 app/javascript/backend/solidus_promotions/web_components/number_with_currency.js
solidus_friendly_promotions-1.9.2 app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js
solidus_friendly_promotions-1.9.1 app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js
solidus_friendly_promotions-1.9.0 app/javascript/solidus_friendly_promotions/web_components/number_with_currency.js