Frontend remembers state.

This commit is contained in:
James Cole
2021-01-17 19:52:53 +01:00
parent c86791950d
commit 79c00548df
22 changed files with 239 additions and 258 deletions

View File

@@ -18,13 +18,12 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
let date = new Date;
const lodashClonedeep = require('lodash.clonedeep');
// initial state
const state = () => ({
transactionType: 'any',
date: new Date,
transactions: [],
allowedOpposingTypes: {},
accountToTransaction: {},
@@ -41,8 +40,6 @@ const state = () => ({
defaultTransaction: {
// basic
description: '',
date: date.toISOString().split('T')[0],
time: ('0' + date.getHours()).slice(-2) + ':' + ('0' + date.getMinutes()).slice(-2) + ':' + ('0' + date.getSeconds()).slice(-2),
// accounts:
source_account: {
@@ -99,6 +96,9 @@ const getters = {
transactions: state => {
return state.transactions;
},
date: state => {
return state.date;
},
transactionType: state => {
return state.transactionType;
},
@@ -176,6 +176,9 @@ const mutations = {
let newTransaction = lodashClonedeep(state.defaultTransaction);
state.transactions.push(newTransaction);
},
setDate(state, payload) {
state.date = payload.date;
},
setCustomDateFields(state, payload) {
state.customDateFields = payload;
},