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