This commit is contained in:
James Cole
2025-08-20 09:09:38 +02:00
parent a1595d0647
commit 46219c4678

View File

@@ -83,15 +83,15 @@ export default {
}, },
watch: { watch: {
source: function () { source: function () {
// console.log('ForeignAmountSelect watch source'); console.log('ForeignAmountSelect watch source');
this.changeData(); this.changeData();
}, },
destination: function () { destination: function () {
// console.log('ForeignAmountSelect watch destination'); console.log('ForeignAmountSelect watch destination');
this.changeData(); this.changeData();
}, },
transactionType: function () { transactionType: function () {
// console.log('ForeignAmountSelect watch transaction type (is now ' + this.transactionType + ')'); console.log('ForeignAmountSelect watch transaction type (is now ' + this.transactionType + ')');
this.changeData(); this.changeData();
} }
}, },
@@ -112,12 +112,10 @@ export default {
amount: this.$refs.amount.value, amount: this.$refs.amount.value,
currency_id: this.$refs.currency_select.value, currency_id: this.$refs.currency_select.value,
}; };
// console.log(obj); this.$emit('input', obj);
this.$emit('input', obj
);
}, },
changeData: function () { changeData: function () {
// console.log('ForeignAmountSelect changeData'); console.log('ForeignAmountSelect changeData');
this.enabledCurrencies = []; this.enabledCurrencies = [];
let destType = this.destination.type ? this.destination.type.toLowerCase() : 'invalid'; let destType = this.destination.type ? this.destination.type.toLowerCase() : 'invalid';
let srcType = this.source.type ? this.source.type.toLowerCase() : 'invalid'; let srcType = this.source.type ? this.source.type.toLowerCase() : 'invalid';
@@ -160,6 +158,7 @@ export default {
} }
} }
} }
this.checkSelection();
return; return;
} }
@@ -172,6 +171,7 @@ export default {
} }
} }
} }
this.checkSelection();
return; return;
} }
for (const key in this.currencies) { for (const key in this.currencies) {
@@ -180,6 +180,23 @@ export default {
} }
} }
}, },
checkSelection: function () {
let selectedCurrency = this.$refs.currency_select.value;
let hasSelected = false;
for(const key in this.enabledCurrencies) {
if(parseInt(this.enabledCurrencies[key].id) === parseInt(selectedCurrency)) {
hasSelected = true;
}
}
if(false === hasSelected) {
let obj = {
amount: '',
currency_id: null,
};
this.$emit('input', obj);
console.warn('Reset foreign amount.');
}
},
loadCurrencies: function () { loadCurrencies: function () {
// console.log('loadCurrencies'); // console.log('loadCurrencies');
// reset list of currencies: // reset list of currencies: