mirror of
https://github.com/jcreek/bank-statement-analyser.git
synced 2026-07-13 02:43:47 +00:00
Added ability to select a tag but only works with one new transaction when there are duplicates too.
This commit is contained in:
@@ -5,9 +5,22 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
<modal v-show="isModalVisible" @close="closeModal">
|
<modal v-show="isModalVisible" @close="closeModal">
|
||||||
<slot name="body">
|
<template v-slot:body>
|
||||||
Successfully used slot body.
|
Successfully used slot body.
|
||||||
</slot>
|
<br>
|
||||||
|
{{ transaction.date }} - {{ transaction.transactionTypeDescription }} - {{ transaction.isExpenditure ? "Expenditure" : "Income" }} -> {{ transaction.amount }}
|
||||||
|
<br>
|
||||||
|
{{ transaction.description }}
|
||||||
|
|
||||||
|
<select v-model="selectedTag">
|
||||||
|
<option v-for="tag in tagsExpenditure" v-bind:key="tag">{{ tag }}</option>
|
||||||
|
</select>
|
||||||
|
</template>
|
||||||
|
<template v-slot:footer>
|
||||||
|
<button type="button" class="btn-green" @click="saveTransaction" aria-label="Close modal">
|
||||||
|
Save transaction and tags
|
||||||
|
</button>
|
||||||
|
</template>
|
||||||
</modal>
|
</modal>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -19,6 +32,7 @@
|
|||||||
name: 'app',
|
name: 'app',
|
||||||
props: [
|
props: [
|
||||||
"transaction",
|
"transaction",
|
||||||
|
"tagsExpenditure",
|
||||||
"isModalVisible"
|
"isModalVisible"
|
||||||
],
|
],
|
||||||
components: {
|
components: {
|
||||||
@@ -26,14 +40,24 @@
|
|||||||
},
|
},
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
|
selectedTag: ""
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
closeModal() {
|
||||||
|
this.$emit('close');
|
||||||
|
},
|
||||||
showModal() {
|
showModal() {
|
||||||
this.$emit('show');
|
this.$emit('show');
|
||||||
},
|
},
|
||||||
closeModal() {
|
saveTransaction() {
|
||||||
|
const newTransaction = this.transaction;
|
||||||
|
var newTags = [];
|
||||||
|
newTags.push(this.selectedTag);
|
||||||
|
newTransaction.tags = newTags;
|
||||||
|
|
||||||
this.$emit('close');
|
this.$emit('close');
|
||||||
|
this.$emit('add', newTransaction);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
+4
-3
@@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<ApplyTag :transaction="newTransaction" :isModalVisible="isModalVisible" @show="showModal" @close="closeModal"/>
|
<ApplyTag :transaction="newTransaction" :isModalVisible="isModalVisible" :tagsExpenditure="tagsExpenditure" @show="showModal" @close="closeModal" @add="addTransaction"/>
|
||||||
<AddTransaction v-on:add-transaction="checkTransactionExists" />
|
<AddTransaction v-on:add-transaction="checkTransactionExists" />
|
||||||
<Transactions v-bind:transactions="transactions" v-on:del-transaction="deleteTransaction" />
|
<Transactions v-bind:transactions="transactions" v-on:del-transaction="deleteTransaction" />
|
||||||
</div>
|
</div>
|
||||||
@@ -67,12 +67,12 @@ export default {
|
|||||||
this.transactions = this.transactions.filter(transaction => transaction.id !== id);
|
this.transactions = this.transactions.filter(transaction => transaction.id !== id);
|
||||||
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
||||||
},
|
},
|
||||||
addTransaction() {
|
addTransaction(newTransaction) {
|
||||||
// When the confirmation button is clicked, return the value of the dropdown
|
// When the confirmation button is clicked, return the value of the dropdown
|
||||||
|
|
||||||
|
|
||||||
// Add the transaction
|
// Add the transaction
|
||||||
this.transactions.push(this.newTransaction);
|
this.transactions.push(newTransaction);
|
||||||
this.saveTransactions();
|
this.saveTransactions();
|
||||||
},
|
},
|
||||||
checkTransactionExists(newTransaction) {
|
checkTransactionExists(newTransaction) {
|
||||||
@@ -89,6 +89,7 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveTransactions() {
|
saveTransactions() {
|
||||||
|
// Save the transactions to localstorage so they persist after closing the session
|
||||||
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
||||||
},
|
},
|
||||||
closeModal() {
|
closeModal() {
|
||||||
|
|||||||
Reference in New Issue
Block a user