mirror of
https://github.com/jcreek/bank-statement-analyser.git
synced 2026-07-12 18:33:46 +00:00
Fixed persistent localstorage for transactions, incl adding and removing
This commit is contained in:
+6
-10
@@ -48,31 +48,27 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (localStorage.getItem('transactions')) {
|
if (localStorage.getItem('transactionStorage')) {
|
||||||
try {
|
try {
|
||||||
this.transactions = JSON.parse(localStorage.getItem('transactions'));
|
this.transactions = JSON.parse(localStorage.getItem('transactionStorage'));
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
alert(e);
|
alert(e);
|
||||||
localStorage.removeItem('transactions');
|
localStorage.removeItem('transactionStorage');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
transactions(newTransaction) {
|
|
||||||
localStorage.transactions = [...localStorage.transactions, newTransaction];
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
deleteTransaction(id) {
|
deleteTransaction(id) {
|
||||||
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));
|
||||||
},
|
},
|
||||||
addTransaction(newTransaction) {
|
addTransaction(newTransaction) {
|
||||||
this.transactions.push(newTransaction);
|
this.transactions.push(newTransaction);
|
||||||
this.saveTransactions();
|
this.saveTransactions();
|
||||||
},
|
},
|
||||||
saveTransactions() {
|
saveTransactions() {
|
||||||
alert(JSON.stringify(this.transactions));
|
localStorage.setItem("lastname", "Smith");
|
||||||
localStorage.setItem('transactions', JSON.stringify(this.transactions));
|
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
configureWebpack: {
|
||||||
|
devtool: 'source-map'
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user