Rebuild frontend, do not use store in components.

This commit is contained in:
James Cole
2021-02-22 18:43:26 +01:00
parent 6d9acd1dc2
commit 5b5c988aa3
87 changed files with 2887 additions and 2835 deletions

View File

@@ -20,15 +20,13 @@
<template>
<!-- FOREIGN AMOUNT -->
<div class="form-group">
<input type="hidden" name="foreign_currency_id[]" :value="currencyId"/>
<div class="form-group" v-if="isVisible">
<div class="text-xs">{{ $t('form.foreign_amount') }}</div>
<div class="input-group">
<input
:title="$t('form.foreign_amount')"
autocomplete="off"
:class="errors.length > 0 ? 'form-control is-invalid' : 'form-control'"
:disabled="0===currencyId"
name="foreign_amount[]"
type="number"
v-model="amount"
@@ -42,117 +40,34 @@
</template>
<script>
import {createNamespacedHelpers} from "vuex";
const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('transactions/create')
//const {mapRootState, mapRootGetters, mapRootActions, mapRootMutations} = createHelpers('');
export default {
name: "TransactionForeignAmount",
props: ['index','errors'],
props: [
'index',
'errors',
'transactionType',
'sourceCurrencyId',
'destinationCurrencyId'
],
data() {
return {
currencySymbol: '',
allCurrencies: [],
selectableCurrencies: [],
amount: ''
// currencySymbol: '',
// allCurrencies: [],
// selectableCurrencies: [],
}
},
watch: {
transactionType: function (value) {
// switch (value) {
// case 'Transfer':
// case 'Withdrawal':
// // take currency from source:
// //this.currencyId = this.transactions[this.index].source_account.currency_id;
// this.currencySymbol = this.transactions[this.index].source_account.currency_symbol;
// return;
// case 'Deposit':
// // take currency from destination:
// this.currencyId = this.transactions[this.index].destination_account.currency_id;
// this.currencySymbol = this.transactions[this.index].destination_account.currency_symbol;
// return;
// }
},
destinationAllowedTypes: function (value) {
// // aka source was updated. if source is asset/loan/debt/mortgage use it to set the currency:
// if ('undefined' !== typeof this.transactions[this.index].source_account.type) {
// if (['Asset account', 'Loan', 'Debt', 'Mortgage'].indexOf(this.transactions[this.index].source_account.type) !== -1) {
// // get currency pref from source account
// this.currencyId = this.transactions[this.index].source_account.currency_id;
// this.currencySymbol = this.transactions[this.index].source_account.currency_symbol;
// }
// }
},
sourceAllowedTypes: function (value) {
// // aka destination was updated. if destination is asset/loan/debt/mortgage use it to set the currency:
// // unless its already known to be a transfer
// if ('undefined' !== typeof this.transactions[this.index].destination_account.type && 'Transfer' !== this.transactionType) {
// if (['Asset account', 'Loan', 'Debt', 'Mortgage'].indexOf(this.transactions[this.index].destination_account.type) !== -1) {
// // get currency pref from destination account
// this.currencyId = this.transactions[this.index].destination_account.currency_id;
// this.currencySymbol = this.transactions[this.index].destination_account.currency_symbol;
// }
// }
},
},
created: function () {
},
methods: {
...mapMutations(
[
'updateField',
],
),
// updateCurrency: function () {
// if (0 === this.currencyId) {
// // use default currency from store.
// this.currencySymbol = this.currencyPreference.symbol;
// this.currencyId = this.currencyPreference.id;
// }
// }
amount: function(value) {
this.$emit('set-foreign-amount', value);
}
},
computed: {
currencyPreference: {
isVisible: {
get() {
return this.$store.state.currencyPreference;
return !('Transfer' === this.transactionType && this.sourceCurrencyId === this.destinationCurrencyId);
}
},
...mapGetters([
'transactionType',
'transactions',
'destinationAllowedTypes',
'sourceAllowedTypes',
]),
amount: {
get() {
return this.transactions[this.index].foreign_amount;
},
set(value) {
this.updateField({field: 'foreign_amount', index: this.index, value: value});
}
},
currencyId: {
get() {
return this.transactions[this.index].foreign_currency_id;
},
set(value) {
this.updateField({field: 'foreign_currency_id', index: this.index, value: value});
}
},
selectedTransactionType: {
get() {
return this.transactionType;
},
set(value) {
// console.log('set selectedAccount for ' + this.direction);
// console.log(value);
// this.updateField({field: this.accountKey, index: this.index, value: value});
}
}
}
}
</script>