diff --git a/.eslintrc.js b/.eslintrc.js index 636a1ef..6f3adff 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -46,5 +46,11 @@ module.exports = { files: ['tests/**/*-test.{js,ts}'], extends: ['plugin:qunit/recommended'], }, + { + files: ['**/*.gjs'], + parser: 'ember-eslint-parser', + plugins: ['ember'], + extends: ['eslint:recommended', 'plugin:ember/recommended', 'plugin:ember/recommended-gjs'], + }, ], }; diff --git a/.prettierrc.js b/.prettierrc.js index 12f341f..c8fcf65 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,9 +1,10 @@ 'use strict'; module.exports = { + plugins: ['prettier-plugin-ember-template-tag'], overrides: [ { - files: '*.{js,ts}', + files: '*.{js,ts,gjs,gts}', options: { singleQuote: true, printWidth: 100, diff --git a/app/components/fmt/unit-code.js b/app/components/fmt/unit-code.js index 7b54778..34d6b65 100644 --- a/app/components/fmt/unit-code.js +++ b/app/components/fmt/unit-code.js @@ -1,15 +1,23 @@ import Component from '@glimmer/component'; export default class FmtUnitCodeComponent extends Component { + get label() { + if (typeof this.args.value === 'string') { + return this.args.value; + } else { + // ED unitPrice object + return this.args.value?.get('label'); + } + } get htmlLabel() { - if (this.args.value == 'm1') { + if (this.label == 'm1') { return 'm'; - } else if (this.args.value == 'm2') { + } else if (this.label == 'm2') { return 'm2'; - } else if (this.args.value == 'st') { + } else if (this.alabel == 'st') { return 'stuk'; } else { - return this.args.value; + return this.label; } } } diff --git a/app/components/fmt/unit-price.hbs b/app/components/fmt/unit-price.hbs index 12fc2af..4f9b49b 100644 --- a/app/components/fmt/unit-price.hbs +++ b/app/components/fmt/unit-price.hbs @@ -1,6 +1,4 @@ -{{#if this.currencyValueLoader.isResolved}} - - {{#if @showUnit}}/ {{/if}} -{{/if}} \ No newline at end of file + +{{#if @showUnit}}/ {{/if}} \ No newline at end of file diff --git a/app/components/fmt/unit-price.js b/app/components/fmt/unit-price.js index d7ec592..eeef3e9 100644 --- a/app/components/fmt/unit-price.js +++ b/app/components/fmt/unit-price.js @@ -1,36 +1,27 @@ import Component from '@glimmer/component'; -import { cached } from '@glimmer/tracking'; -import { TrackedAsyncData } from 'ember-async-data'; import { VAT_RATE } from '../../config'; import { calculatePriceTaxIncluded, calculatePriceTaxExcluded } from '../../utils/calculate-price'; - +import { get } from '@ember/object'; export default class FmtUnitPriceComponent extends Component { // Note: - // this.args.model maybe a Proxy object coming from ember-data + // this.args.model may be a unit-price-specification Proxy object coming from ember-data // or a plain javascript object coming as nested object from mu-search. - @cached - get currencyValueLoader() { + get currencyValue() { + // eslint-disable-next-line ember/no-get + return get(this.args.model, 'currencyValue'); + } + + get isTaxIncluded() { + // eslint-disable-next-line ember/no-get + return `${get(this.args.model, 'valueAddedTaxIncluded')}` === 'true'; // cover for mu-search where 'true' is a string + } + + get calculatedCurrencyValue() { if (this.args.showTaxIncluded) { - const loadData = async () => { - const model = await this.args.model; - return calculatePriceTaxIncluded( - model.currencyValue, - VAT_RATE, - `${model.valueAddedTaxIncluded}` === 'true', // cover for mu-search where 'true' is a string - ); - }; - return new TrackedAsyncData(loadData()); + return calculatePriceTaxIncluded(this.currencyValue, VAT_RATE, this.isTaxIncluded); } else { - const loadData = async () => { - const model = await this.args.model; - return calculatePriceTaxExcluded( - model.currencyValue, - VAT_RATE, - `${model.valueAddedTaxIncluded}` === 'true', // cover for mu-search where 'true' is a string - ); - }; - return new TrackedAsyncData(loadData()); + return calculatePriceTaxExcluded(this.currencyValue, VAT_RATE, this.isTaxIncluded); } } } diff --git a/app/components/main-menu.hbs b/app/components/main-menu.hbs index 40d5887..88fd595 100644 --- a/app/components/main-menu.hbs +++ b/app/components/main-menu.hbs @@ -12,11 +12,18 @@