diff --git a/bin/controls/fields/types/Price.js b/bin/controls/fields/types/Price.js index dbb86709f620675b4c15f1110d2464245aabcce5..77d51ca2f9c6fc0921e150e54239f0eb3a5a0e2b 100644 --- a/bin/controls/fields/types/Price.js +++ b/bin/controls/fields/types/Price.js @@ -108,10 +108,12 @@ define('package/quiqqer/products/bin/controls/fields/types/Price', [ require(['package/quiqqer/currency/bin/Currency'], (Currencies) => { Promise.all([ Currencies.getCurrencies(), + Currencies.getDefaultCurrency(), this.getFormatter() ]).then((r) => { const currencies = r[0]; - const Formatter = r[1]; + const defaultCurrency = r[1]; + const Formatter = r[2]; if (currencies.length <= 1) { return; @@ -164,6 +166,21 @@ define('package/quiqqer/products/bin/controls/fields/types/Price', [ const displayNode = container.querySelector('.displayNode'); const input = container.querySelector('input'); + if (defaultCurrency === currency.code) { + input.disabled = true; + input.value = this.$Input.value; + + this.$Input.addEvent('change', () => { + input.value = this.$Input.value; + + this.$calcBruttoPriceForCurrency( + input.value, + currency.code, + displayNode + ); + }); + } + container.querySelector('button') .addEventListener('click', this.openBruttoInputForCurrencies); @@ -277,6 +294,7 @@ define('package/quiqqer/products/bin/controls/fields/types/Price', [ ) { this.getElm().value = ''; this.$Input.value = ''; + this.$Input.fireEvent('change'); this.$calcBruttoPrice(); return; } @@ -290,12 +308,14 @@ define('package/quiqqer/products/bin/controls/fields/types/Price', [ if ((foundGroupSeparator || foundDecimalSeparator) && !(foundGroupSeparator && !foundDecimalSeparator)) { this.getElm().value = value; this.$Input.value = value; + this.$Input.fireEvent('change'); return; } this.getFormatter().then((Formatter) => { this.getElm().value = Formatter.format(parseFloat(value)); this.$Input.value = Formatter.format(parseFloat(value)); + this.$Input.fireEvent('change'); }); this.$calcBruttoPrice(); @@ -408,7 +428,10 @@ define('package/quiqqer/products/bin/controls/fields/types/Price', [ productId: this.$productId, events: { onSubmit: (Win, value) => { - e.target.getParent('label').querySelector('input').value = value; + const input = e.target.getParent('label').querySelector('input'); + + input.value = value; + input.dispatchEvent(new Event('blur', {bubbles: false})); } } }).open(); diff --git a/composer.json b/composer.json index b8047731994b6fe834452607b338445cb8b780aa..7044308636bb923a692625ebe5fb8d27e7d077de 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "quiqqer/erp": "^3.2", "quiqqer/areas": "^2", "quiqqer/bricks": "^2", - "quiqqer/currency": "^2", + "quiqqer/currency": "^2.1", "quiqqer/discount": "^2", "quiqqer/pace": "^2", "quiqqer/product-bricks": "^2",