mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix #2651
This commit is contained in:
parent
9332808d7f
commit
34e7455d67
2
public/v1/js/app.js
vendored
2
public/v1/js/app.js
vendored
File diff suppressed because one or more lines are too long
@ -95,11 +95,13 @@
|
||||
}
|
||||
},
|
||||
ready() {
|
||||
// console.log('ready(): this.name = this.accountName (' + this.accountName + ')');
|
||||
this.name = this.accountName;
|
||||
},
|
||||
mounted() {
|
||||
this.target = this.$refs.input;
|
||||
let types = this.allowedTypes.join(',');
|
||||
// console.log('mounted(): this.name = this.accountName (' + this.accountName + ')');
|
||||
this.name = this.accountName;
|
||||
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search=";
|
||||
this.triggerTransactionType();
|
||||
@ -115,6 +117,10 @@
|
||||
types = this.defaultAccountTypeFilters.join(',');
|
||||
}
|
||||
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search=";
|
||||
},
|
||||
name() {
|
||||
// console.log('Watch: name()');
|
||||
// console.log(this.name);
|
||||
}
|
||||
},
|
||||
methods:
|
||||
@ -123,7 +129,16 @@
|
||||
return this.error.length > 0;
|
||||
},
|
||||
triggerTransactionType: function () {
|
||||
// console.log('On triggerTransactionType(' + this.inputName + ')');
|
||||
if(null === this.name) {
|
||||
// console.log('this.name is NULL.');
|
||||
}
|
||||
if (null === this.transactionType) {
|
||||
// console.log('Transaction type is NULL.');
|
||||
return;
|
||||
}
|
||||
if ('' === this.transactionType) {
|
||||
// console.log('Transaction type is "".');
|
||||
return;
|
||||
}
|
||||
this.inputDisabled = false;
|
||||
@ -148,21 +163,24 @@
|
||||
}
|
||||
},
|
||||
selectedItem: function (e) {
|
||||
//console.log('In SelectedItem()');
|
||||
// console.log('In SelectedItem()');
|
||||
if (typeof this.name === 'undefined') {
|
||||
//console.log('Is undefined');
|
||||
// console.log('Is undefined');
|
||||
return;
|
||||
}
|
||||
if(typeof this.name === 'string') {
|
||||
//console.log('Is a string.');
|
||||
// console.log('Is a string.');
|
||||
//this.trType = null;
|
||||
this.$emit('clear:value');
|
||||
}
|
||||
// emit the fact that the user selected a type of account
|
||||
// (influencing the destination)
|
||||
// console.log('Is some object maybe:');
|
||||
// console.log(this.name);
|
||||
this.$emit('select:account', this.name);
|
||||
},
|
||||
clearSource: function (e) {
|
||||
// console.log('clearSource()');
|
||||
//props.value = '';
|
||||
this.name = '';
|
||||
// some event?
|
||||
|
@ -219,6 +219,7 @@
|
||||
},
|
||||
methods: {
|
||||
convertData: function () {
|
||||
// console.log('Now in convertData()');
|
||||
let data = {
|
||||
'transactions': [],
|
||||
};
|
||||
@ -254,6 +255,7 @@
|
||||
return data;
|
||||
},
|
||||
convertDataRow(row, index, transactionType) {
|
||||
// console.log('Now in convertDataRow()');
|
||||
let tagList = [];
|
||||
let foreignAmount = null;
|
||||
let foreignCurrency = null;
|
||||
@ -371,6 +373,7 @@
|
||||
},
|
||||
// submit transaction
|
||||
submit(e) {
|
||||
// console.log('Now in submit()');
|
||||
const uri = './api/v1/transactions?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
|
||||
const data = this.convertData();
|
||||
|
||||
@ -378,9 +381,10 @@
|
||||
button.prop("disabled", true);
|
||||
|
||||
axios.post(uri, data).then(response => {
|
||||
|
||||
// console.log('Did a succesfull POST');
|
||||
// this method will ultimately send the user on (or not).
|
||||
if (0 === this.collectAttachmentData(response)) {
|
||||
// console.log('Will now go to redirectUser()');
|
||||
this.redirectUser(response.data.data.id, button);
|
||||
}
|
||||
}).catch(error => {
|
||||
@ -398,10 +402,10 @@
|
||||
}
|
||||
},
|
||||
redirectUser(groupId, button) {
|
||||
//console.log('In redirectUser()');
|
||||
// console.log('In redirectUser()');
|
||||
// if count is 0, send user onwards.
|
||||
if (this.createAnother) {
|
||||
//console.log('Will create another.');
|
||||
// console.log('Will create another.');
|
||||
|
||||
// do message:
|
||||
this.success_message = '<a href="transactions/show/' + groupId + '">Transaction #' + groupId + '</a> has been stored.';
|
||||
@ -409,7 +413,9 @@
|
||||
if (this.resetFormAfter) {
|
||||
// also clear form.
|
||||
this.resetTransactions();
|
||||
this.addTransactionToArray();
|
||||
// do a short time out?
|
||||
setTimeout(() => this.addTransactionToArray(), 50);
|
||||
//this.addTransactionToArray();
|
||||
}
|
||||
|
||||
// clear errors:
|
||||
@ -619,9 +625,11 @@
|
||||
}
|
||||
},
|
||||
resetTransactions: function () {
|
||||
// console.log('Now in resetTransactions()');
|
||||
this.transactions = [];
|
||||
},
|
||||
addTransactionToArray: function (e) {
|
||||
// console.log('Now in addTransactionToArray()');
|
||||
this.transactions.push({
|
||||
description: "",
|
||||
date: "",
|
||||
@ -693,9 +701,13 @@
|
||||
}
|
||||
});
|
||||
if (this.transactions.length === 1) {
|
||||
// console.log('Length == 1, set date to today.');
|
||||
// set first date.
|
||||
let today = new Date();
|
||||
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) {
|
||||
e.preventDefault();
|
||||
@ -735,6 +747,7 @@
|
||||
},
|
||||
|
||||
selectedSourceAccount: function (index, model) {
|
||||
// console.log('Now in selectedSourceAccount()');
|
||||
if (typeof model === 'string') {
|
||||
// cant change types, only name.
|
||||
this.transactions[index].source_account.name = model;
|
||||
@ -756,6 +769,7 @@
|
||||
}
|
||||
},
|
||||
selectedDestinationAccount: function (index, model) {
|
||||
// console.log('Now in selectedDestinationAccount()');
|
||||
if (typeof model === 'string') {
|
||||
// cant change types, only name.
|
||||
this.transactions[index].destination_account.name = model;
|
||||
|
@ -56,7 +56,7 @@
|
||||
|
||||
props: ['source', 'destination', 'transactionType', 'value', 'error', 'no_currency', 'title',],
|
||||
mounted() {
|
||||
console.log('loadCurrencies()');
|
||||
//console.log('loadCurrencies()');
|
||||
this.liability = false;
|
||||
this.loadCurrencies();
|
||||
},
|
||||
@ -71,35 +71,35 @@
|
||||
},
|
||||
watch: {
|
||||
source: function () {
|
||||
console.log('watch source in foreign currency');
|
||||
// console.log('watch source in foreign currency');
|
||||
this.changeData();
|
||||
},
|
||||
destination: function () {
|
||||
console.log('watch destination in foreign currency');
|
||||
// console.log('watch destination in foreign currency');
|
||||
this.changeData();
|
||||
},
|
||||
transactionType: function () {
|
||||
console.log('watch transaction type in foreign currency');
|
||||
// console.log('watch transaction type in foreign currency');
|
||||
this.changeData();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
hasError: function () {
|
||||
console.log('Has error');
|
||||
// console.log('Has error');
|
||||
return this.error.length > 0;
|
||||
},
|
||||
handleInput(e) {
|
||||
console.log('handleInput');
|
||||
// console.log('handleInput');
|
||||
let obj = {
|
||||
amount: this.$refs.amount.value,
|
||||
currency_id: this.$refs.currency_select.value,
|
||||
};
|
||||
console.log(obj);
|
||||
// console.log(obj);
|
||||
this.$emit('input', obj
|
||||
);
|
||||
},
|
||||
changeData: function () {
|
||||
console.log('Now in changeData()');
|
||||
//console.log('Now in changeData()');
|
||||
this.enabledCurrencies = [];
|
||||
let destType = this.destination.type ? this.destination.type.toLowerCase() : 'invalid';
|
||||
let srcType = this.source.type ? this.source.type.toLowerCase() : 'invalid';
|
||||
@ -108,11 +108,11 @@
|
||||
let sourceIsLiability = liabilities.indexOf(srcType) !== -1;
|
||||
let destIsLiability = liabilities.indexOf(destType) !== -1;
|
||||
|
||||
console.log(srcType + ' (source) is a liability: ' + sourceIsLiability);
|
||||
console.log(destType + ' (dest) is a liability: ' + destIsLiability);
|
||||
// console.log(srcType + ' (source) is a liability: ' + sourceIsLiability);
|
||||
// console.log(destType + ' (dest) is a liability: ' + destIsLiability);
|
||||
|
||||
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;
|
||||
// lock dropdown list on on currencyID of destination.
|
||||
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;
|
||||
}
|
||||
|
||||
@ -156,7 +156,7 @@
|
||||
}
|
||||
},
|
||||
loadCurrencies: function () {
|
||||
console.log('loadCurrencies');
|
||||
// console.log('loadCurrencies');
|
||||
let URI = document.getElementsByTagName('base')[0].href + "json/currencies";
|
||||
axios.get(URI, {}).then((res) => {
|
||||
this.currencies = [
|
||||
|
@ -20,6 +20,7 @@
|
||||
{{ ExpandedForm.text('name') }}
|
||||
{% if account.accountType.type == 'Default account' or account.accountType.type == 'Asset account' or objectType == 'liabilities' %}
|
||||
{{ CurrencyForm.currencyList('currency_id', null, {helpText:'account_default_currency'|_}) }}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{% if objectType == 'liabilities' %}
|
||||
|
Loading…
Reference in New Issue
Block a user