This commit is contained in:
James Cole 2019-11-09 16:50:13 +01:00
parent 9332808d7f
commit 34e7455d67
No known key found for this signature in database
GPG Key ID: C16961E655E74B5E
5 changed files with 54 additions and 21 deletions

2
public/v1/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@ -95,11 +95,13 @@
} }
}, },
ready() { ready() {
// console.log('ready(): this.name = this.accountName (' + this.accountName + ')');
this.name = this.accountName; this.name = this.accountName;
}, },
mounted() { mounted() {
this.target = this.$refs.input; this.target = this.$refs.input;
let types = this.allowedTypes.join(','); let types = this.allowedTypes.join(',');
// console.log('mounted(): this.name = this.accountName (' + this.accountName + ')');
this.name = this.accountName; this.name = this.accountName;
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search="; this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search=";
this.triggerTransactionType(); this.triggerTransactionType();
@ -115,6 +117,10 @@
types = this.defaultAccountTypeFilters.join(','); types = this.defaultAccountTypeFilters.join(',');
} }
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search="; this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search=";
},
name() {
// console.log('Watch: name()');
// console.log(this.name);
} }
}, },
methods: methods:
@ -123,7 +129,16 @@
return this.error.length > 0; return this.error.length > 0;
}, },
triggerTransactionType: function () { triggerTransactionType: function () {
// console.log('On triggerTransactionType(' + this.inputName + ')');
if(null === this.name) {
// console.log('this.name is NULL.');
}
if (null === this.transactionType) { if (null === this.transactionType) {
// console.log('Transaction type is NULL.');
return;
}
if ('' === this.transactionType) {
// console.log('Transaction type is "".');
return; return;
} }
this.inputDisabled = false; this.inputDisabled = false;
@ -148,21 +163,24 @@
} }
}, },
selectedItem: function (e) { selectedItem: function (e) {
//console.log('In SelectedItem()'); // console.log('In SelectedItem()');
if (typeof this.name === 'undefined') { if (typeof this.name === 'undefined') {
//console.log('Is undefined'); // console.log('Is undefined');
return; return;
} }
if(typeof this.name === 'string') { if(typeof this.name === 'string') {
//console.log('Is a string.'); // console.log('Is a string.');
//this.trType = null; //this.trType = null;
this.$emit('clear:value'); this.$emit('clear:value');
} }
// emit the fact that the user selected a type of account // emit the fact that the user selected a type of account
// (influencing the destination) // (influencing the destination)
// console.log('Is some object maybe:');
// console.log(this.name);
this.$emit('select:account', this.name); this.$emit('select:account', this.name);
}, },
clearSource: function (e) { clearSource: function (e) {
// console.log('clearSource()');
//props.value = ''; //props.value = '';
this.name = ''; this.name = '';
// some event? // some event?

View File

@ -219,6 +219,7 @@
}, },
methods: { methods: {
convertData: function () { convertData: function () {
// console.log('Now in convertData()');
let data = { let data = {
'transactions': [], 'transactions': [],
}; };
@ -254,6 +255,7 @@
return data; return data;
}, },
convertDataRow(row, index, transactionType) { convertDataRow(row, index, transactionType) {
// console.log('Now in convertDataRow()');
let tagList = []; let tagList = [];
let foreignAmount = null; let foreignAmount = null;
let foreignCurrency = null; let foreignCurrency = null;
@ -371,6 +373,7 @@
}, },
// submit transaction // submit transaction
submit(e) { submit(e) {
// console.log('Now in submit()');
const uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content; const uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
const data = this.convertData(); const data = this.convertData();
@ -378,9 +381,10 @@
button.prop("disabled", true); button.prop("disabled", true);
axios.post(uri, data).then(response => { axios.post(uri, data).then(response => {
// console.log('Did a succesfull POST');
// this method will ultimately send the user on (or not). // this method will ultimately send the user on (or not).
if (0 === this.collectAttachmentData(response)) { if (0 === this.collectAttachmentData(response)) {
// console.log('Will now go to redirectUser()');
this.redirectUser(response.data.data.id, button); this.redirectUser(response.data.data.id, button);
} }
}).catch(error => { }).catch(error => {
@ -398,10 +402,10 @@
} }
}, },
redirectUser(groupId, button) { redirectUser(groupId, button) {
//console.log('In redirectUser()'); // console.log('In redirectUser()');
// if count is 0, send user onwards. // if count is 0, send user onwards.
if (this.createAnother) { if (this.createAnother) {
//console.log('Will create another.'); // console.log('Will create another.');
// do message: // do message:
this.success_message = '<a href="transactions/show/' + groupId + '">Transaction #' + groupId + '</a> has been stored.'; this.success_message = '<a href="transactions/show/' + groupId + '">Transaction #' + groupId + '</a> has been stored.';
@ -409,7 +413,9 @@
if (this.resetFormAfter) { if (this.resetFormAfter) {
// also clear form. // also clear form.
this.resetTransactions(); this.resetTransactions();
this.addTransactionToArray(); // do a short time out?
setTimeout(() => this.addTransactionToArray(), 50);
//this.addTransactionToArray();
} }
// clear errors: // clear errors:
@ -619,9 +625,11 @@
} }
}, },
resetTransactions: function () { resetTransactions: function () {
// console.log('Now in resetTransactions()');
this.transactions = []; this.transactions = [];
}, },
addTransactionToArray: function (e) { addTransactionToArray: function (e) {
// console.log('Now in addTransactionToArray()');
this.transactions.push({ this.transactions.push({
description: "", description: "",
date: "", date: "",
@ -693,9 +701,13 @@
} }
}); });
if (this.transactions.length === 1) { if (this.transactions.length === 1) {
// console.log('Length == 1, set date to today.');
// set first date. // set first date.
let today = new Date(); let today = new Date();
this.transactions[0].date = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2); this.transactions[0].date = today.getFullYear() + '-' + ("0" + (today.getMonth() + 1)).slice(-2) + '-' + ("0" + today.getDate()).slice(-2);
// call for extra clear thing:
// this.clearSource(0);
//this.clearDestination(0);
} }
if (e) { if (e) {
e.preventDefault(); e.preventDefault();
@ -735,6 +747,7 @@
}, },
selectedSourceAccount: function (index, model) { selectedSourceAccount: function (index, model) {
// console.log('Now in selectedSourceAccount()');
if (typeof model === 'string') { if (typeof model === 'string') {
// cant change types, only name. // cant change types, only name.
this.transactions[index].source_account.name = model; this.transactions[index].source_account.name = model;
@ -756,6 +769,7 @@
} }
}, },
selectedDestinationAccount: function (index, model) { selectedDestinationAccount: function (index, model) {
// console.log('Now in selectedDestinationAccount()');
if (typeof model === 'string') { if (typeof model === 'string') {
// cant change types, only name. // cant change types, only name.
this.transactions[index].destination_account.name = model; this.transactions[index].destination_account.name = model;

View File

@ -56,7 +56,7 @@
props: ['source', 'destination', 'transactionType', 'value', 'error', 'no_currency', 'title',], props: ['source', 'destination', 'transactionType', 'value', 'error', 'no_currency', 'title',],
mounted() { mounted() {
console.log('loadCurrencies()'); //console.log('loadCurrencies()');
this.liability = false; this.liability = false;
this.loadCurrencies(); this.loadCurrencies();
}, },
@ -71,35 +71,35 @@
}, },
watch: { watch: {
source: function () { source: function () {
console.log('watch source in foreign currency'); // console.log('watch source in foreign currency');
this.changeData(); this.changeData();
}, },
destination: function () { destination: function () {
console.log('watch destination in foreign currency'); // console.log('watch destination in foreign currency');
this.changeData(); this.changeData();
}, },
transactionType: function () { transactionType: function () {
console.log('watch transaction type in foreign currency'); // console.log('watch transaction type in foreign currency');
this.changeData(); this.changeData();
} }
}, },
methods: { methods: {
hasError: function () { hasError: function () {
console.log('Has error'); // console.log('Has error');
return this.error.length > 0; return this.error.length > 0;
}, },
handleInput(e) { handleInput(e) {
console.log('handleInput'); // console.log('handleInput');
let obj = { let obj = {
amount: this.$refs.amount.value, amount: this.$refs.amount.value,
currency_id: this.$refs.currency_select.value, currency_id: this.$refs.currency_select.value,
}; };
console.log(obj); // console.log(obj);
this.$emit('input', obj this.$emit('input', obj
); );
}, },
changeData: function () { changeData: function () {
console.log('Now in changeData()'); //console.log('Now in changeData()');
this.enabledCurrencies = []; this.enabledCurrencies = [];
let destType = this.destination.type ? this.destination.type.toLowerCase() : 'invalid'; let destType = this.destination.type ? this.destination.type.toLowerCase() : 'invalid';
let srcType = this.source.type ? this.source.type.toLowerCase() : 'invalid'; let srcType = this.source.type ? this.source.type.toLowerCase() : 'invalid';
@ -108,11 +108,11 @@
let sourceIsLiability = liabilities.indexOf(srcType) !== -1; let sourceIsLiability = liabilities.indexOf(srcType) !== -1;
let destIsLiability = liabilities.indexOf(destType) !== -1; let destIsLiability = liabilities.indexOf(destType) !== -1;
console.log(srcType + ' (source) is a liability: ' + sourceIsLiability); // console.log(srcType + ' (source) is a liability: ' + sourceIsLiability);
console.log(destType + ' (dest) is a liability: ' + destIsLiability); // console.log(destType + ' (dest) is a liability: ' + destIsLiability);
if (tType === 'transfer' || destIsLiability || sourceIsLiability) { if (tType === 'transfer' || destIsLiability || sourceIsLiability) {
console.log('Source is liability OR dest is liability, OR transfer. Lock list on currency of destination.'); //console.log('Source is liability OR dest is liability, OR transfer. Lock list on currency of destination.');
this.liability = true; this.liability = true;
// lock dropdown list on on currencyID of destination. // lock dropdown list on on currencyID of destination.
for (const key in this.currencies) { for (const key in this.currencies) {
@ -122,7 +122,7 @@
} }
} }
} }
console.log('Enabled currencies length is now ' + this.enabledCurrencies.length); //console.log('Enabled currencies length is now ' + this.enabledCurrencies.length);
return; return;
} }
@ -156,7 +156,7 @@
} }
}, },
loadCurrencies: function () { loadCurrencies: function () {
console.log('loadCurrencies'); // console.log('loadCurrencies');
let URI = document.getElementsByTagName('base')[0].href + "json/currencies"; let URI = document.getElementsByTagName('base')[0].href + "json/currencies";
axios.get(URI, {}).then((res) => { axios.get(URI, {}).then((res) => {
this.currencies = [ this.currencies = [

View File

@ -20,6 +20,7 @@
{{ ExpandedForm.text('name') }} {{ ExpandedForm.text('name') }}
{% if account.accountType.type == 'Default account' or account.accountType.type == 'Asset account' or objectType == 'liabilities' %} {% if account.accountType.type == 'Default account' or account.accountType.type == 'Asset account' or objectType == 'liabilities' %}
{{ CurrencyForm.currencyList('currency_id', null, {helpText:'account_default_currency'|_}) }} {{ CurrencyForm.currencyList('currency_id', null, {helpText:'account_default_currency'|_}) }}
{% endif %} {% endif %}
{% if objectType == 'liabilities' %} {% if objectType == 'liabilities' %}