mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-10-14 00:04:24 +00:00
Code for #2534
This commit is contained in:
@@ -74,6 +74,12 @@
|
||||
default: function () {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
defaultAccountTypeFilters: {
|
||||
type: Array,
|
||||
default: function () {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -84,7 +90,8 @@
|
||||
trType: this.transactionType,
|
||||
target: null,
|
||||
inputDisabled: false,
|
||||
allowedTypes: this.accountTypeFilters
|
||||
allowedTypes: this.accountTypeFilters,
|
||||
defaultAllowedTypes: this.defaultAccountTypeFilters
|
||||
}
|
||||
},
|
||||
ready() {
|
||||
@@ -94,6 +101,8 @@
|
||||
this.target = this.$refs.input;
|
||||
let types = this.allowedTypes.join(',');
|
||||
this.name = this.accountName;
|
||||
// console.log('Mounted Types:');
|
||||
// console.log(this.allowedTypes);
|
||||
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search=";
|
||||
this.triggerTransactionType();
|
||||
},
|
||||
@@ -104,6 +113,10 @@
|
||||
},
|
||||
accountTypeFilters() {
|
||||
let types = this.accountTypeFilters.join(',');
|
||||
if (0 === this.accountTypeFilters.length) {
|
||||
types = this.defaultAccountTypeFilters.join(',');
|
||||
// console.log('types was empty: ' + types);
|
||||
}
|
||||
this.accountAutoCompleteURI = document.getElementsByTagName('base')[0].href + "json/accounts?types=" + types + "&search=";
|
||||
}
|
||||
},
|
||||
|
@@ -43,8 +43,8 @@
|
||||
props: ['transactionType', 'value', 'error'],
|
||||
mounted() {
|
||||
this.loadBudgets();
|
||||
console.log('budget value');
|
||||
console.log(this.value);
|
||||
// console.log('budget value');
|
||||
// console.log(this.value);
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
@@ -86,6 +86,7 @@
|
||||
title="Source account"
|
||||
:accountName="transaction.source_account.name"
|
||||
:accountTypeFilters="transaction.source_account.allowed_types"
|
||||
:defaultAccountTypeFilters="transaction.source_account.default_allowed_types"
|
||||
:transactionType="transactionType"
|
||||
:index="index"
|
||||
v-on:clear:value="clearSource(index)"
|
||||
@@ -97,6 +98,7 @@
|
||||
title="Destination account"
|
||||
:accountName="transaction.destination_account.name"
|
||||
:accountTypeFilters="transaction.destination_account.allowed_types"
|
||||
:defaultAccountTypeFilters="transaction.destination_account.default_allowed_types"
|
||||
:transactionType="transactionType"
|
||||
:index="index"
|
||||
v-on:clear:value="clearDestination(index)"
|
||||
@@ -393,10 +395,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.';
|
||||
@@ -414,13 +416,13 @@
|
||||
button.prop("disabled", false);
|
||||
}
|
||||
} else {
|
||||
console.log('Will redirect to previous URL. (' + previousUri + ')');
|
||||
// console.log('Will redirect to previous URL. (' + previousUri + ')');
|
||||
window.location.href = window.previousUri + '?transaction_group_id=' + groupId + '&message=created';
|
||||
}
|
||||
},
|
||||
|
||||
collectAttachmentData(response) {
|
||||
console.log('Now incollectAttachmentData()');
|
||||
// console.log('Now incollectAttachmentData()');
|
||||
let groupId = response.data.data.id;
|
||||
|
||||
// array of all files to be uploaded:
|
||||
@@ -449,7 +451,7 @@
|
||||
}
|
||||
}
|
||||
let count = toBeUploaded.length;
|
||||
console.log('Found ' + toBeUploaded.length + ' attachments.');
|
||||
// console.log('Found ' + toBeUploaded.length + ' attachments.');
|
||||
|
||||
// loop all uploads.
|
||||
for (const key in toBeUploaded) {
|
||||
@@ -483,7 +485,7 @@
|
||||
let uploads = 0;
|
||||
for (const key in fileData) {
|
||||
if (fileData.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||
console.log('Creating attachment #' + key);
|
||||
// console.log('Creating attachment #' + key);
|
||||
// axios thing, + then.
|
||||
const uri = './api/v1/attachments';
|
||||
const data = {
|
||||
@@ -493,19 +495,19 @@
|
||||
};
|
||||
axios.post(uri, data)
|
||||
.then(response => {
|
||||
console.log('Created attachment #' + key);
|
||||
console.log('Uploading attachment #' + key);
|
||||
// console.log('Created attachment #' + key);
|
||||
// console.log('Uploading attachment #' + key);
|
||||
const uploadUri = './api/v1/attachments/' + response.data.data.id + '/upload';
|
||||
axios.post(uploadUri, fileData[key].content)
|
||||
.then(response => {
|
||||
console.log('Uploaded attachment #' + key);
|
||||
// console.log('Uploaded attachment #' + key);
|
||||
uploads++;
|
||||
if (uploads === count) {
|
||||
// finally we can redirect the user onwards.
|
||||
console.log('FINAL UPLOAD');
|
||||
// console.log('FINAL UPLOAD');
|
||||
this.redirectUser(groupId);
|
||||
}
|
||||
console.log('Upload complete!');
|
||||
// console.log('Upload complete!');
|
||||
return true;
|
||||
}).catch(error => {
|
||||
console.error('Could not upload');
|
||||
@@ -522,7 +524,7 @@
|
||||
setDefaultErrors: function () {
|
||||
for (const key in this.transactions) {
|
||||
if (this.transactions.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||
console.log('Set default errors for key ' + key);
|
||||
// console.log('Set default errors for key ' + key);
|
||||
//this.transactions[key].description
|
||||
this.transactions[key].errors = {
|
||||
source_account: [],
|
||||
@@ -664,7 +666,8 @@
|
||||
currency_name: '',
|
||||
currency_code: '',
|
||||
currency_decimal_places: 2,
|
||||
allowed_types: ['Asset account','Revenue account','Loan','Debt','Mortgage']
|
||||
allowed_types: ['Asset account','Revenue account','Loan','Debt','Mortgage'],
|
||||
default_allowed_types: ['Asset account','Revenue account','Loan','Debt','Mortgage']
|
||||
},
|
||||
destination_account: {
|
||||
id: 0,
|
||||
@@ -674,7 +677,8 @@
|
||||
currency_name: '',
|
||||
currency_code: '',
|
||||
currency_decimal_places: 2,
|
||||
allowed_types: ['Asset account','Expense account','Loan','Debt','Mortgage']
|
||||
allowed_types: ['Asset account','Expense account','Loan','Debt','Mortgage'],
|
||||
default_allowed_types: ['Asset account','Expense account','Loan','Debt','Mortgage']
|
||||
}
|
||||
});
|
||||
if (this.transactions.length === 1) {
|
||||
@@ -732,7 +736,8 @@
|
||||
currency_name: model.currency_name,
|
||||
currency_code: model.currency_code,
|
||||
currency_decimal_places: model.currency_decimal_places,
|
||||
allowed_types: this.transactions[index].source_account.allowed_types
|
||||
allowed_types: this.transactions[index].source_account.allowed_types,
|
||||
default_allowed_types: ['Asset account','Revenue account','Loan','Debt','Mortgage']
|
||||
};
|
||||
|
||||
// force types on destination selector.
|
||||
@@ -752,7 +757,8 @@
|
||||
currency_name: model.currency_name,
|
||||
currency_code: model.currency_code,
|
||||
currency_decimal_places: model.currency_decimal_places,
|
||||
allowed_types: this.transactions[index].destination_account.allowed_types
|
||||
allowed_types: this.transactions[index].destination_account.allowed_types,
|
||||
default_allowed_types: ['Asset account','Expense account','Loan','Debt','Mortgage']
|
||||
};
|
||||
|
||||
// force types on destination selector.
|
||||
@@ -760,7 +766,7 @@
|
||||
}
|
||||
},
|
||||
clearSource: function (index) {
|
||||
console.log('clearSource(' + index + ')');
|
||||
// console.log('clearSource(' + index + ')');
|
||||
// reset source account:
|
||||
this.transactions[index].source_account = {
|
||||
id: 0,
|
||||
@@ -770,7 +776,8 @@
|
||||
currency_name: '',
|
||||
currency_code: '',
|
||||
currency_decimal_places: 2,
|
||||
allowed_types: this.transactions[index].source_account.allowed_types
|
||||
allowed_types: this.transactions[index].source_account.allowed_types,
|
||||
default_allowed_types: ['Asset account','Revenue account','Loan','Debt','Mortgage']
|
||||
};
|
||||
// reset destination allowed account types.
|
||||
this.transactions[index].destination_account.allowed_types = [];
|
||||
@@ -782,7 +789,7 @@
|
||||
}
|
||||
},
|
||||
clearDestination: function (index) {
|
||||
console.log('clearDestination(' + index + ')');
|
||||
// console.log('clearDestination(' + index + ')');
|
||||
// reset destination account:
|
||||
this.transactions[index].destination_account = {
|
||||
id: 0,
|
||||
@@ -792,7 +799,8 @@
|
||||
currency_name: '',
|
||||
currency_code: '',
|
||||
currency_decimal_places: 2,
|
||||
allowed_types: this.transactions[index].destination_account.allowed_types
|
||||
allowed_types: this.transactions[index].destination_account.allowed_types,
|
||||
default_allowed_types: ['Asset account','Expense account','Loan','Debt','Mortgage']
|
||||
};
|
||||
// reset destination allowed account types.
|
||||
this.transactions[index].source_account.allowed_types = [];
|
||||
|
@@ -203,7 +203,7 @@
|
||||
this.getGroup();
|
||||
},
|
||||
ready() {
|
||||
console.log('Ready Group ID: ' + this.groupId);
|
||||
// console.log('Ready Group ID: ' + this.groupId);
|
||||
},
|
||||
methods: {
|
||||
positiveAmount(amount) {
|
||||
@@ -290,10 +290,10 @@
|
||||
}
|
||||
},
|
||||
clearDestination(index) {
|
||||
console.log('clearDestination(' + index + ')');
|
||||
// console.log('clearDestination(' + index + ')');
|
||||
// reset destination account:
|
||||
console.log('Destination allowed types first:');
|
||||
console.log(this.transactions[index].destination_account.allowed_types);
|
||||
// console.log('Destination allowed types first:');
|
||||
// console.log(this.transactions[index].destination_account.allowed_types);
|
||||
this.transactions[index].destination_account = {
|
||||
id: 0,
|
||||
name: '',
|
||||
@@ -313,8 +313,8 @@
|
||||
this.selectedSourceAccount(index, this.transactions[index].source_account);
|
||||
}
|
||||
|
||||
console.log('Destination allowed types after:');
|
||||
console.log(this.transactions[index].destination_account.allowed_types);
|
||||
// console.log('Destination allowed types after:');
|
||||
// console.log(this.transactions[index].destination_account.allowed_types);
|
||||
},
|
||||
getGroup() {
|
||||
|
||||
@@ -323,7 +323,7 @@
|
||||
|
||||
|
||||
const uri = './api/v1/transactions/' + groupId + '?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
|
||||
console.log(uri);
|
||||
// console.log(uri);
|
||||
|
||||
// fill in transactions array.
|
||||
axios.get(uri)
|
||||
@@ -331,11 +331,11 @@
|
||||
this.processIncomingGroup(response.data.data);
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Some error.');
|
||||
//console.error('Some error.');
|
||||
});
|
||||
},
|
||||
processIncomingGroup(data) {
|
||||
console.log(data);
|
||||
// console.log(data);
|
||||
this.group_title = data.attributes.group_title;
|
||||
let transactions = data.attributes.transactions.reverse();
|
||||
for (let key in transactions) {
|
||||
@@ -347,7 +347,7 @@
|
||||
}
|
||||
},
|
||||
processIncomingGroupRow(transaction) {
|
||||
console.log(transaction);
|
||||
// console.log(transaction);
|
||||
this.setTransactionType(transaction.type);
|
||||
|
||||
let newTags = [];
|
||||
@@ -579,7 +579,7 @@
|
||||
return currentArray;
|
||||
},
|
||||
submit: function (e) {
|
||||
console.log('I am submit');
|
||||
// console.log('I am submit');
|
||||
const page = window.location.href.split('/');
|
||||
const groupId = page[page.length - 1];
|
||||
const uri = './api/v1/transactions/' + groupId + '?_token=' + document.head.querySelector('meta[name="csrf-token"]').content;
|
||||
@@ -617,7 +617,7 @@
|
||||
},
|
||||
|
||||
redirectUser(groupId, button) {
|
||||
console.log('In redirectUser()');
|
||||
// console.log('In redirectUser()');
|
||||
// if count is 0, send user onwards.
|
||||
|
||||
if (this.returnAfter) {
|
||||
@@ -632,7 +632,7 @@
|
||||
},
|
||||
|
||||
collectAttachmentData(response) {
|
||||
console.log('Now incollectAttachmentData()');
|
||||
// console.log('Now incollectAttachmentData()');
|
||||
let groupId = response.data.data.id;
|
||||
|
||||
// array of all files to be uploaded:
|
||||
@@ -661,7 +661,7 @@
|
||||
}
|
||||
}
|
||||
let count = toBeUploaded.length;
|
||||
console.log('Found ' + toBeUploaded.length + ' attachments.');
|
||||
// console.log('Found ' + toBeUploaded.length + ' attachments.');
|
||||
|
||||
// loop all uploads.
|
||||
for (const key in toBeUploaded) {
|
||||
@@ -695,7 +695,7 @@
|
||||
let uploads = 0;
|
||||
for (const key in fileData) {
|
||||
if (fileData.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||
console.log('Creating attachment #' + key);
|
||||
// console.log('Creating attachment #' + key);
|
||||
// axios thing, + then.
|
||||
const uri = './api/v1/attachments';
|
||||
const data = {
|
||||
@@ -705,23 +705,23 @@
|
||||
};
|
||||
axios.post(uri, data)
|
||||
.then(response => {
|
||||
console.log('Created attachment #' + key);
|
||||
console.log('Uploading attachment #' + key);
|
||||
// console.log('Created attachment #' + key);
|
||||
// console.log('Uploading attachment #' + key);
|
||||
const uploadUri = './api/v1/attachments/' + response.data.data.id + '/upload';
|
||||
axios.post(uploadUri, fileData[key].content)
|
||||
.then(response => {
|
||||
console.log('Uploaded attachment #' + key);
|
||||
// console.log('Uploaded attachment #' + key);
|
||||
uploads++;
|
||||
if (uploads === count) {
|
||||
// finally we can redirect the user onwards.
|
||||
console.log('FINAL UPLOAD');
|
||||
// console.log('FINAL UPLOAD');
|
||||
this.redirectUser(groupId);
|
||||
}
|
||||
console.log('Upload complete!');
|
||||
// console.log('Upload complete!');
|
||||
return true;
|
||||
}).catch(error => {
|
||||
console.error('Could not upload');
|
||||
console.error(error);
|
||||
// console.error('Could not upload');
|
||||
// console.error(error);
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
@@ -70,7 +70,7 @@
|
||||
return this.error.length > 0;
|
||||
},
|
||||
initItems() {
|
||||
console.log('Now in initItems');
|
||||
// console.log('Now in initItems');
|
||||
if (this.tag.length < 2) {
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user