Skip to content
Code-Schnipsel Gruppen Projekte
Commit 5fc962f9 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

fix: consider default currency and change event to price field

This commit adds the `getDefaultCurrency` function call and incorporates the default currency in
the price calculation. It further enhances the price input field to be disabled and auto-filled
when the default currency is in use. Changes to the primary input field are now also propagated to
the relevant currency input field.

In addition, the composer.json has been updated to require a minimum version of 2.1 for
`quiqqer/currency`.

Note: Besides, several function calls have been added to trigger `change` event on main input
element for accurate price calculation whenever the value changes. Moreover, the `blur` event has
been added to the input element in `onSubmit` event handler to reflect the changes immediately.
Übergeordneter 367d4ebc
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
Pipeline-Nr. 16544 mit Warnungen bestanden
......@@ -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();
......
......@@ -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",
......
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren