Better event.

This commit is contained in:
James Cole 2021-02-23 06:42:04 +01:00
parent fb821ea63e
commit 419c1a75dd
No known key found for this signature in database
GPG Key ID: B5669F9493CDE38D
4 changed files with 23 additions and 68 deletions

View File

@ -33,15 +33,14 @@
:custom-fields="customFields" :custom-fields="customFields"
:submitted-transaction="submittedTransaction" :submitted-transaction="submittedTransaction"
v-on:uploaded-attachments="uploadedAttachment($event)" v-on:uploaded-attachments="uploadedAttachment($event)"
v-on:set-description="storeField($event)"
v-on:set-marker-location="storeLocation($event)" v-on:set-marker-location="storeLocation($event)"
v-on:set-account="storeAccountValue($event)" v-on:set-account="storeAccountValue($event)"
v-on:switch-accounts="switchAccounts($event)" v-on:switch-accounts="switchAccounts($event)"
v-on:set-amount="storeAmount(index, $event)"
v-on:set-foreign-currency-id="storeField($event)"
v-on:set-foreign-amount="storeField($event)"
v-on:set-date="storeDate($event)" v-on:set-date="storeDate($event)"
v-on:set-time="storeTime($event)" v-on:set-time="storeTime($event)"
v-on:set-amount="storeField($event)"
v-on:set-foreign-currency-id="storeField($event)"
v-on:set-foreign-amount="storeField($event)"
v-on:set-custom-date="storeField($event)" v-on:set-custom-date="storeField($event)"
v-on:set-budget="storeField($event)" v-on:set-budget="storeField($event)"
v-on:set-category="storeField($event)" v-on:set-category="storeField($event)"
@ -50,8 +49,9 @@
v-on:set-piggy-bank="storeField($event)" v-on:set-piggy-bank="storeField($event)"
v-on:set-internal-reference="storeField($event)" v-on:set-internal-reference="storeField($event)"
v-on:set-external-url="storeField($event)" v-on:set-external-url="storeField($event)"
v-on:set-notes="storeNotes(index, $event)" v-on:set-notes="storeField($event)"
v-on:set-links="storeLinks(index, $event)" v-on:set-links="storeField($event)"
v-on:set-description="storeField($event)"
/> />
</div> </div>
@ -402,55 +402,12 @@ export default {
storeField: function (payload) { storeField: function (payload) {
this.updateField(payload); this.updateField(payload);
}, },
storeDescription: function (index, value) {
this.updateField({field: 'description', index: index, value: value});
},
storeForeignCurrencyId: function (index, value) {
console.log('storeForeignCurrencyId(' + index + ',' + value + ')');
this.updateField({field: 'foreign_currency_id', index: index, value: value});
},
storeAmount: function (index, value) {
this.updateField({field: 'amount', index: index, value: value});
},
storeForeignAmount: function (index, value) {
this.updateField({field: 'foreign_amount', index: index, value: value});
},
storeDate: function (value) { storeDate: function (value) {
this.setDate(value.date) this.setDate(value.date)
}, },
storeTime: function (value) { storeTime: function (value) {
this.setTime(value.time) this.setTime(value.time)
}, },
storeCustomDate: function (index, payload) {
this.updateField({field: payload.field, index: index, value: payload.date});
},
storeBudget: function (index, value) {
this.updateField({field: 'budget_id', index: index, value: value});
},
storeCategory: function (index, value) {
this.updateField({field: 'category', index: index, value: value});
},
storeBill: function (index, value) {
this.updateField({field: 'bill_id', index: index, value: value});
},
storeTags: function (index, value) {
this.updateField({field: 'tags', index: index, value: value});
},
storePiggyBank: function (index, value) {
this.updateField({field: 'piggy_bank_id', index: index, value: value});
},
storeInternalReference: function (index, value) {
this.updateField({field: 'internal_reference', index: index, value: value});
},
storeExternalUrl: function (index, value) {
this.updateField({field: 'external_url', index: index, value: value});
},
storeNotes: function (index, value) {
this.updateField({field: 'notes', index: index, value: value});
},
storeLinks: function (index, value) {
this.updateField({field: 'links', index: index, value: value});
},
/** /**
* Calculate the transaction type based on what's currently in the store. * Calculate the transaction type based on what's currently in the store.

View File

@ -38,7 +38,7 @@
<span v-if="errors.length > 0"> <span v-if="errors.length > 0">
<span v-for="error in errors" class="text-danger small">{{ error }}<br/></span> <span v-for="error in errors" class="text-danger small">{{ error }}<br/></span>
</span> </span>
</div> </div>
</template> </template>
<script> <script>
@ -46,9 +46,9 @@
export default { export default {
name: "TransactionAmount", name: "TransactionAmount",
props: [ props: [
'index', 'errors', 'amount', 'transactionType', 'index', 'errors', 'amount', 'transactionType',
'sourceCurrencySymbol', 'sourceCurrencySymbol',
'destinationCurrencySymbol', 'destinationCurrencySymbol',
], ],
data() { data() {
return { return {
@ -60,9 +60,9 @@ export default {
}, },
watch: { watch: {
transactionAmount: function (value) { transactionAmount: function (value) {
this.$emit('set-amount', value); this.$emit('set-amount', {field: 'amount', index: this.index, value: value});
}, },
amount: function(value) { amount: function (value) {
this.transactionAmount = value; this.transactionAmount = value;
}, },
sourceCurrencySymbol: function (value) { sourceCurrencySymbol: function (value) {
@ -72,15 +72,15 @@ export default {
this.dstCurrencySymbol = value; this.dstCurrencySymbol = value;
}, },
transactionType: function(value) { transactionType: function (value) {
switch (value) { switch (value) {
case 'Transfer': case 'Transfer':
case 'Withdrawal': case 'Withdrawal':
this.currencySymbol =this.srcCurrencySymbol; this.currencySymbol = this.srcCurrencySymbol;
break; break;
case 'Deposit': case 'Deposit':
this.currencySymbol =this.dstCurrencySymbol; this.currencySymbol = this.dstCurrencySymbol;
} }
}, },
}, },
} }

View File

@ -216,9 +216,7 @@ export default {
}, },
watch: { watch: {
links: function (value) { links: function (value) {
// TODO this.$emit('set-links', {index: this.index, field: 'links', value: lodashClonedeep(value)});
this.$emit('set-links', lodashClonedeep(value));
//this.updateField({index: this.index, field: 'links', value: lodashClonedeep(value)});
}, },
customFields: function (value) { customFields: function (value) {
this.availableFields = value; this.availableFields = value;

View File

@ -58,7 +58,7 @@ export default {
this.availableFields = value; this.availableFields = value;
}, },
notes: function (value) { notes: function (value) {
this.$emit('set-notes', value); this.$emit('set-notes', {field: 'notes', index: this.index, value: value});
} }
} }
} }