Fix various issues and remove debug comments.

This commit is contained in:
James Cole 2021-12-10 16:42:02 +01:00
parent 219c3c11f9
commit f32bdd6c76
No known key found for this signature in database
GPG Key ID: BDE6667570EADBD5
22 changed files with 240 additions and 145 deletions

View File

@ -275,8 +275,8 @@ export default {
this.hasAttachments = false;
},
uploadedAttachments: function (e) {
console.log('Response to event uploaded-attachments');
console.log(e);
// console.log('Response to event uploaded-attachments');
// console.log(e);
this.finishSubmission();
},
submitForm: function (e) {

View File

@ -177,13 +177,9 @@
import {mapGetters, mapMutations} from "vuex";
import Sortable from "sortablejs";
import format from "date-fns/format";
// import {setup} from 'axios-cache-adapter';
// import {cacheAdapterEnhancer} from 'axios-extensions';
import {configureAxios} from "../../shared/forageStore";
// get all and cache, dont keep the table busy.
export default {
name: "Index",
props: {

View File

@ -80,8 +80,8 @@
<script>
import TransactionListLarge from "../transactions/TransactionListLarge";
import format from "date-fns/format";
import {mapGetters} from "vuex";
import format from "date-fns/format";
import {configureAxios} from "../../shared/forageStore";
export default {
@ -147,32 +147,36 @@ export default {
this.updatePageTitle();
},
getTransactions: function () {
// console.log('getTransactions()');
if (this.showReady && !this.loading) {
// console.log('Show ready, not loading, go for download');
this.loading = true;
this.rawTransactions = [];
configureAxios().then(async (api) => {
// console.log('Now getTransactions() x Start');
let startStr = format(this.start, 'y-MM-dd');
let endStr = format(this.end, 'y-MM-dd');
this.rawTransactions = [];
let url = './api/v1/accounts/' + this.accountId + '/transactions?page=1&limit=' + this.perPage + '&start=' + startStr + '&end=' + endStr + '&cache=' + this.cacheKey;
let url = './api/v1/accounts/' + this.accountId + '/transactions?page=' + this.currentPage + '&limit=' + this.perPage + '&start=' + startStr + '&end=' + endStr + '&cache=' + this.cacheKey;
api.get(url)
.then(response => {
// console.log('Now getTransactions() DONE!');
this.total = parseInt(response.data.meta.pagination.total);
let transactions = response.data.data;
// console.log('Have downloaded ' + transactions.length + ' transactions');
// console.log(response.data);
this.rawTransactions = response.data.data;
this.loading = false;
}
);
});
}
},
jumpToPage: function (event) {
// console.log('noticed a change!');
// console.log('noticed a change in account/show!');
this.currentPage = event.page;
this.downloadTransactionList(event.page);
this.getTransactions();
},
},
watch: {

View File

@ -23,6 +23,23 @@
<Alert :message="errorMessage" type="danger"/>
<Alert :message="successMessage" type="success"/>
<form @submit="submitForm" autocomplete="off">
<div class="col">
<!-- tabs -->
<ul class="nav nav-tabs ml-auto p-2" id="subscriptionTabs">
<li>
<li class="nav-item"><a class="nav-link active" href="#subscription" data-toggle="pill">
Subscription
</a>
</li>
<li>
<li class="nav-item"><a class="nav-link" href="#rule" data-toggle="pill">
Rule
</a>
</li>
</ul>
</div>
<div class="tab-content" id="subscriptionTabContent">
<div class="tab-pane show active" id="subscription" role="tabpanel" aria-labelledby="subscription-tab">
<div class="row">
<div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-xs-12">
<div class="card card-primary">
@ -77,7 +94,8 @@
<GenericTextInput :disabled="submitting" v-model="skip" field-name="skip" :errors="errors.skip" :title="$t('form.skip')"
v-on:set-field="storeField($event)"/>
<GenericGroup :disabled="submitting" v-model="group_title" field-name="group_title" :errors="errors.group_title" :title="$t('form.object_group')"
<GenericGroup :disabled="submitting" v-model="group_title" field-name="group_title" :errors="errors.group_title"
:title="$t('form.object_group')"
v-on:set-field="storeField($event)"/>
</div>
</div>
@ -111,6 +129,26 @@
</div>
</div>
</div>
</div>
<div class="tab-pane show" id="rule" role="tabpanel" aria-labelledby="rule-tab">
<div class="row">
<div class="col-xl-6 col-lg-6 col-md-12 col-sm-12 col-xs-12">
<div class="card card-primary">
<div class="card-header">
<h3 class="card-title">
Title
</h3>
</div>
<div class="card-body">
<p>
In the future here you can set rule info for the new subscription.
</p>
</div>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</template>

View File

@ -269,10 +269,10 @@ export default {
};
},
downloadBills: function (page) {
console.log('downloadBills');
console.log(this.indexReady);
console.log(this.loading);
console.log(this.downloaded);
// console.log('downloadBills');
// console.log(this.indexReady);
// console.log(this.loading);
// console.log(this.downloaded);
this.resetGroups();
// console.log('getAccountList()');
if (this.indexReady && !this.loading && !this.downloaded) {

View File

@ -215,16 +215,16 @@ export default {
let pctOrange = 0;
let pctRed = 0;
//console.log('Collected "' + period + '" budget limit #' + currentId + ' (part of budget #' + budgetId + ')');
console.log('Spent ' + spentFloatPos + ' of ' + amount);
// console.log('Spent ' + spentFloatPos + ' of ' + amount);
// remove budget info from rawBudgets if it's there:
this.filterBudgets(budgetId, currencyId);
let name = this.budgets[current.attributes.budget_id].name;
// spent within budget:
if (0.0 !== spentFloat && spentFloatPos < amount) {
console.log('Spent ' + name + ' in budget');
// console.log('Spent ' + name + ' in budget');
pctGreen = (spentFloatPos / amount) * 100;
console.log('pctGreen is ' + pctGreen);
// console.log('pctGreen is ' + pctGreen);
}
// spent over budget

View File

@ -97,22 +97,22 @@ export default {
// });
// new code
console.log('start of new');
// console.log('start of new');
let files = this.$refs.att.files;
this.uploads = files.length;
// loop all files and create attachments.
for (let i in files) {
if (files.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
console.log('Now at file ' + (parseInt(i) + 1) + ' / ' + files.length);
// console.log('Now at file ' + (parseInt(i) + 1) + ' / ' + files.length);
// read file into file reader:
let current = files[i];
let fileReader = new FileReader();
let theParent = this; // dont ask me why i need to do this.
fileReader.onloadend = evt => {
if (evt.target.readyState === FileReader.DONE) {
console.log('I am done reading file ' + (parseInt(i) + 1));
// console.log('I am done reading file ' + (parseInt(i) + 1));
this.createAttachment(current.name).then(response => {
console.log('Created attachment. Now upload (1)');
// console.log('Created attachment. Now upload (1)');
return theParent.uploadAttachment(response.data.data.id, new Blob([evt.target.result]));
}).then(theParent.countAttachment);
}
@ -121,7 +121,7 @@ export default {
}
}
if (0 === files.length) {
console.log('No files to upload. Emit event!');
// console.log('No files to upload. Emit event!');
this.$emit('uploaded-attachments', this.transaction_journal_id);
}
// Promise.all(promises).then(response => {
@ -138,15 +138,15 @@ export default {
methods: {
countAttachment: function () {
this.uploaded++;
console.log('Uploaded ' + this.uploaded + ' / ' + this.uploads);
// console.log('Uploaded ' + this.uploaded + ' / ' + this.uploads);
if (this.uploaded >= this.uploads) {
console.log('All files uploaded. Emit event for ' + this.uploadObjectId);
// console.log('All files uploaded. Emit event for ' + this.uploadObjectId);
this.$emit('uploaded-attachments', this.uploadObjectId);
}
},
uploadAttachment: function (attachmentId, data) {
this.created++;
console.log('Now in uploadAttachment()');
// console.log('Now in uploadAttachment()');
const uploadUri = './api/v1/attachments/' + attachmentId + '/upload';
return axios.post(uploadUri, data)
},

View File

@ -20,7 +20,7 @@
const lodashClonedeep = require('lodash.clonedeep');
import {getDefaultTransaction, getDefaultErrors} from '../../../../shared/transactions';
import {getDefaultErrors, getDefaultTransaction} from '../../../../shared/transactions';
// initial state
const state = () => ({
@ -100,6 +100,7 @@ const mutations = {
state.transactions[payload.index].errors = lodashClonedeep(state.defaultErrors);
},
resetTransactions(state) {
// console.log('Store: Record call to resetTransactions :(');
state.transactions = [];
},
setGroupTitle(state, payload) {
@ -109,12 +110,13 @@ const mutations = {
state.customDateFields = payload;
},
deleteTransaction(state, payload) {
// console.log('Record call to deleteTransaction!');
state.transactions.splice(payload.index, 1);
// console.log('Deleted transaction ' + payload.index);
// console.log(state.transactions);
if (0 === state.transactions.length) {
// if (0 === state.transactions.length) {
// console.log('array is empty!');
}
// }
},
setTransactionType(state, transactionType) {
state.transactionType = transactionType;

View File

@ -221,7 +221,7 @@ export default {
]
),
addTransactionArray: function (event) {
console.log('Record call to addTransactionArray');
// console.log('Record call to addTransactionArray');
event.preventDefault();
this.addTransaction();
},
@ -229,8 +229,8 @@ export default {
* Removes a split from the array.
*/
removeTransaction: function (payload) {
console.log('Record call to removeTransaction');
console.log('Triggered to remove transaction ' + payload.index);
// console.log('Record call to removeTransaction');
// console.log('Triggered to remove transaction ' + payload.index);
window.$('#tab_split_' + (payload.index - 1)).click();
this.$store.commit('transactions/create/deleteTransaction', payload);
},

View File

@ -153,7 +153,7 @@ export default {
this.getTransactionList();
},
jumpToPage: function (event) {
console.log('noticed a change in transactions/index.vue!');
// console.log('noticed a change in transactions/index.vue!');
this.currentPage = event.page;
this.downloadTransactionList(event.page);
},

View File

@ -209,6 +209,7 @@
<TransactionTags
v-model="transaction.tags"
v-on="$listeners"
ref="tags"
:errors="transaction.errors.tags"
:index="index"
/>
@ -381,12 +382,13 @@ export default {
methods: {
removeTransaction: function () {
// console.log('Will remove transaction ' + this.index);
this.$emit('remove-transaction', {index: this.index});
},
triggerNextAccount: function(e) {
//alert(e);
if('source' === e) {
console.log('Jump to destination!');
// console.log('Jump to destination!');
this.$refs.destinationAccount.giveFocus();
}
}

View File

@ -19,12 +19,16 @@
-->
<template>
<div>
<span>Length: {{ this.transactions.length }}</span>
<div v-if="transactions.length > 1" class="row">
<div class="col">
<!-- tabs -->
<ul class="nav nav-pills ml-auto p-2" id="transactionTabs">
<li v-for="(transaction, index) in this.transactions" class="nav-item"><a :class="'nav-link' + (0 === index ? ' active' : '')"
:href="'#split_' + index"
:id="'tab_split_' + index"
data-toggle="pill">
<span v-if="'' !== transaction.description">{{ transaction.description }}</span>
<span v-if="'' === transaction.description">Split {{ index + 1 }}</span>
@ -32,6 +36,7 @@
</ul>
</div>
</div>
</div>
</template>
<script>

View File

@ -116,15 +116,22 @@ export default {
// console.log('TransactionAccount::created() direction=' + this.direction + ', type=' + this.transactionType + ' , name="' + this.accountName + '"');
this.selectedAccountTrigger = true;
},
mounted: function () {
this.$nextTick(function () {
if (0 === this.index) {
this.$refs.inputThing.$refs.input.tabIndex = 2;
}
})
},
methods: {
getACURL: function (types, query) {
return './api/v1/autocomplete/accounts?types=' + types.join(',') + '&query=' + query;
},
giveFocus: function () {
console.log('I want focus! now OK: ' + this.direction + ' l: ' + this.accounts.length);
//console.log('I want focus! now OK: ' + this.direction + ' l: ' + this.accounts.length);
//console.log(this.$refs.inputThing.$refs.input.value);
this.$refs.inputThing.$refs.input.focus();
console.log(this.$refs.inputThing.isFocused);
//console.log(this.$refs.inputThing.isFocused);
},
userSelectedAccount: function (event) {
// console.log('userSelectedAccount!');

View File

@ -69,6 +69,13 @@ export default {
this.transactionAmount = this.formatNumber(this.amount);
}
},
mounted: function () {
this.$nextTick(function () {
if (0 === this.index) {
this.$refs.input.tabIndex = 3;
}
})
},
methods: {
formatNumber(str) {
return parseFloat(str).toFixed(this.fractionDigits);

View File

@ -52,6 +52,11 @@ export default {
bill: this.value,
}
},
mounted: function () {
this.$nextTick(function () {
this.$refs.bill.tabIndex = 9;
})
},
created() {
this.collectData();
},

View File

@ -52,6 +52,11 @@ export default {
emitEvent: true
}
},
mounted: function () {
this.$nextTick(function () {
this.$refs.budget.tabIndex = 8;
})
},
created() {
this.collectData();
},

View File

@ -35,6 +35,7 @@
inputName="category[]"
@hit="selectedCategory = $event"
@input="lookupCategory"
ref="input"
>
<template slot="append">
<div class="input-group-append">
@ -64,7 +65,11 @@ export default {
category: this.value
}
},
mounted: function () {
this.$nextTick(function () {
this.$refs.input.$refs.input.tabIndex = 10;
})
},
created() {
//console.log('Created category(' + this.index + ') "' + this.value + '"');
// initial list of accounts:

View File

@ -67,7 +67,14 @@ export default {
let parts = this.date.split('T');
this.dateStr = parts[0];
this.timeStr = parts[1];
},
mounted: function () {
if (0 === this.index) {
this.$nextTick(function () {
this.$refs.date.tabIndex = 6;
this.$refs.time.tabIndex = 7;
});
}
},
data() {
return {

View File

@ -31,6 +31,7 @@
autocomplete="off"
name="foreign_amount[]"
type="number"
ref="input"
>
</div>
<span v-if="errors.length > 0">
@ -66,6 +67,11 @@ export default {
this.amount = this.formatNumber(this.amount);
}
},
mounted: function () {
this.$nextTick(function () {
this.$refs.input.tabIndex = 5;
})
},
methods: {
formatNumber(str) {
return parseFloat(str).toFixed(this.fractionDigits);

View File

@ -23,7 +23,7 @@
<div v-if="isVisible" class="form-group">
<div class="text-xs">&nbsp;</div>
<div class="input-group">
<select v-model="selectedCurrency" class="form-control" name="foreign_currency_id[]">
<select v-model="selectedCurrency" class="form-control" ref="input" name="foreign_currency_id[]">
<option v-for="currency in selectableCurrencies" :label="currency.name" :value="currency.id">{{ currency.name }}</option>
</select>
</div>
@ -77,6 +77,11 @@ export default {
// console.log('Created TransactionForeignCurrency');
this.getAllCurrencies();
},
mounted: function () {
this.$nextTick(function () {
this.$refs.input.tabIndex = 4;
})
},
methods: {
lockCurrency: function () {
// console.log('Lock currency (' + this.transactionType + ')');

View File

@ -225,12 +225,12 @@ export default {
this.$emit('jump-page', {page: value});
},
entries: function (value) {
console.log('detected new transactions! (' + value.length + ')');
// console.log('detected new transactions! (' + value.length + ')');
this.parseTransactions();
},
value: function (value) {
console.log('Watch value!');
}
// value: function (value) {
// // console.log('Watch value!');
// }
},
methods: {
...mapMutations('root', ['refreshCacheKey',]),
@ -239,10 +239,10 @@ export default {
// console.log('Start of parseTransactions. Count of entries is ' + this.entries.length + ' and page is ' + this.page);
// console.log('Reported total is ' + this.total);
if (0 === this.entries.length) {
console.log('Will not render now because length is 0.');
// console.log('Will not render now because length is 0.');
return;
}
console.log('Now have ' + this.transactions.length + ' transactions');
// console.log('Now have ' + this.transactions.length + ' transactions');
for (let i = 0; i < this.total; i++) {
this.transactions.push({dummy: true, type: 'x'});
// console.log('Push dummy to index ' + i);
@ -270,7 +270,7 @@ export default {
},
newCacheKey: function () {
this.refreshCacheKey();
console.log('Cache key is now ' + this.cacheKey);
// console.log('Cache key is now ' + this.cacheKey);
this.$emit('refreshed-cache-key');
},
updateFieldList: function () {

View File

@ -29,6 +29,7 @@
:add-only-from-autocomplete="false"
:autocomplete-items="autocompleteItems"
:tags="tags"
ref="input"
:title="$t('firefly.tags')"
v-bind:placeholder="$t('firefly.tags')"
@tags-changed="newTags => this.tags = newTags"