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() {
|
||||
if (localStorage.getItem('transactions')) {
|
||||
if (localStorage.getItem('transactionStorage')) {
|
||||
try {
|
||||
this.transactions = JSON.parse(localStorage.getItem('transactions'));
|
||||
this.transactions = JSON.parse(localStorage.getItem('transactionStorage'));
|
||||
} catch(e) {
|
||||
alert(e);
|
||||
localStorage.removeItem('transactions');
|
||||
localStorage.removeItem('transactionStorage');
|
||||
}
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
transactions(newTransaction) {
|
||||
localStorage.transactions = [...localStorage.transactions, newTransaction];
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
deleteTransaction(id) {
|
||||
this.transactions = this.transactions.filter(transaction => transaction.id !== id);
|
||||
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
||||
},
|
||||
addTransaction(newTransaction) {
|
||||
this.transactions.push(newTransaction);
|
||||
this.saveTransactions();
|
||||
},
|
||||
saveTransactions() {
|
||||
alert(JSON.stringify(this.transactions));
|
||||
localStorage.setItem('transactions', JSON.stringify(this.transactions));
|
||||
localStorage.setItem("lastname", "Smith");
|
||||
localStorage.setItem("transactionStorage", JSON.stringify(this.transactions));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
module.exports = {
|
||||
configureWebpack: {
|
||||
devtool: 'source-map'
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user