Build v2 with some fixes for #4735

This commit is contained in:
James Cole
2021-05-08 18:23:50 +02:00
parent 9eaacf30ad
commit d0edae76f2
6 changed files with 37 additions and 17 deletions

View File

@@ -223,6 +223,9 @@ export default {
enableSubmit: true, enableSubmit: true,
stayHere: false, stayHere: false,
// force the submission (in case of deletes)
forceTransactionSubmission: false
} }
}, },
components: { components: {
@@ -275,7 +278,7 @@ export default {
for (let i in transactions) { for (let i in transactions) {
if (transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) { if (transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
console.log('Parsing transaction nr ' + i); // console.log('Parsing transaction nr ' + i);
let result = this.parseTransaction(parseInt(i), transactions[i]); let result = this.parseTransaction(parseInt(i), transactions[i]);
this.transactions.push(result); this.transactions.push(result);
this.originalTransactions.push(lodashClonedeep(result)); this.originalTransactions.push(lodashClonedeep(result));
@@ -489,9 +492,10 @@ export default {
let index = 0; let index = 0;
for (let i in this.transactions) { for (let i in this.transactions) {
if (this.transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) { if (this.transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
console.log('Now at index: ' + i); // console.log('Now at index: ' + i);
if (index === payload.index) { if (index === payload.index) {
console.log('Delete!'); this.forceTransactionSubmission = true;
//console.log('Delete!');
this.transactions.splice(index, 1); this.transactions.splice(index, 1);
//console.log(delete this.transactions[i]); //console.log(delete this.transactions[i]);
} }
@@ -499,7 +503,7 @@ export default {
} }
} }
$('#transactionTabs li:first-child a').tab('show'); $('#transactionTabs li:first-child a').tab('show');
// console.log(this.transactions);
// this.transactions.splice(payload.index, 1); // this.transactions.splice(payload.index, 1);
// console.log('length: ' + this.transactions.length); // console.log('length: ' + this.transactions.length);
@@ -530,6 +534,7 @@ export default {
this.transactions.push(newTransaction); this.transactions.push(newTransaction);
}, },
submitTransaction: function (event) { submitTransaction: function (event) {
// console.log('submitTransaction()');
event.preventDefault(); event.preventDefault();
this.enableSubmit = false; this.enableSubmit = false;
let submission = {transactions: []}; let submission = {transactions: []};
@@ -553,9 +558,11 @@ export default {
} }
// loop each transaction (edited by the user): // loop each transaction (edited by the user):
// console.log('Start of loop submitTransaction');
for (let i in this.transactions) { for (let i in this.transactions) {
// console.log('Index ' + i);
if (this.transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) { if (this.transactions.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
// console.log('Has index ' + i);
// original transaction present: // original transaction present:
let currentTransaction = this.transactions[i]; let currentTransaction = this.transactions[i];
let originalTransaction = this.originalTransactions.hasOwnProperty(i) ? this.originalTransactions[i] : {}; let originalTransaction = this.originalTransactions.hasOwnProperty(i) ? this.originalTransactions[i] : {};
@@ -585,19 +592,28 @@ export default {
for (let ii in basicFields) { for (let ii in basicFields) {
if (basicFields.hasOwnProperty(ii) && /^0$|^[1-9]\d*$/.test(ii) && ii <= 4294967294) { if (basicFields.hasOwnProperty(ii) && /^0$|^[1-9]\d*$/.test(ii) && ii <= 4294967294) {
let fieldName = basicFields[ii]; let fieldName = basicFields[ii];
// console.log('Now at field ' + fieldName);
let submissionFieldName = fieldName; let submissionFieldName = fieldName;
// if the original is undefined and the new one is null, just skip it. // if the original is undefined and the new one is null, just skip it.
if (currentTransaction[fieldName] === null && 'undefined' === typeof originalTransaction[fieldName]) { if (currentTransaction[fieldName] === null && 'undefined' === typeof originalTransaction[fieldName]) {
// console.log('Will continue and skip');
continue; continue;
} }
if (currentTransaction[fieldName] !== originalTransaction[fieldName]) { if (currentTransaction[fieldName] !== originalTransaction[fieldName] || true === this.forceTransactionSubmission) {
// console.log('we continue');
// some fields are ignored: // some fields are ignored:
if ('foreign_amount' === submissionFieldName && '' === currentTransaction[fieldName]) { if ('foreign_amount' === submissionFieldName && '' === currentTransaction[fieldName]) {
// console.log('we skip!');
continue; continue;
} }
if ('foreign_currency_id' === submissionFieldName && 0 === currentTransaction[fieldName]) { if ('foreign_currency_id' === submissionFieldName && 0 === currentTransaction[fieldName] ) {
// console.log('we skip!');
continue;
}
if ('foreign_currency_id' === submissionFieldName && '0' === currentTransaction[fieldName] ) {
// console.log('we skip!');
continue; continue;
} }
@@ -618,6 +634,7 @@ export default {
// otherwise save them and remember them for submission: // otherwise save them and remember them for submission:
diff[submissionFieldName] = currentTransaction[fieldName]; diff[submissionFieldName] = currentTransaction[fieldName];
shouldSubmit = true; shouldSubmit = true;
//console.log('Should submit is now TRUE');
} }
} }
} }
@@ -671,15 +688,18 @@ export default {
submission.transactions.push(lodashClonedeep(diff)); submission.transactions.push(lodashClonedeep(diff));
shouldSubmit = true; shouldSubmit = true;
} }
// console.log('Should submit index ' + i + '?');
// console.log(shouldSubmit);
} }
} }
this.submitUpdate(submission, shouldSubmit, shouldLinks, shouldUpload); this.submitUpdate(submission, shouldSubmit, shouldLinks, shouldUpload);
}, },
submitData: function (shouldSubmit, submission) { submitData: function (shouldSubmit, submission) {
//console.log('submitData'); // console.log('submitData');
// console.log(submission);
if (!shouldSubmit) { if (!shouldSubmit) {
//console.log('No need!'); // console.log('No need to submit transaction.');
return new Promise((resolve) => { return new Promise((resolve) => {
resolve({}); resolve({});
}); });
@@ -732,9 +752,9 @@ export default {
return this.deleteAllOriginalLinks().then(() => this.submitNewLinks()); return this.deleteAllOriginalLinks().then(() => this.submitNewLinks());
}, },
submitAttachments: function (shouldSubmit, response) { submitAttachments: function (shouldSubmit, response) {
console.log('submitAttachments'); // console.log('submitAttachments');
if (!shouldSubmit) { if (!shouldSubmit) {
console.log('no need!'); // console.log('no need!');
this.submittedAttachments = 1; this.submittedAttachments = 1;
return new Promise((resolve) => { return new Promise((resolve) => {
resolve({}); resolve({});
@@ -802,7 +822,7 @@ export default {
} }
}, },
submitUpdate: function (submission, shouldSubmit, shouldLinks, shouldUpload) { submitUpdate: function (submission, shouldSubmit, shouldLinks, shouldUpload) {
//console.log('submitUpdate()'); // console.log('submitUpdate()');
this.inError = false; this.inError = false;
this.submitData(shouldSubmit, submission) this.submitData(shouldSubmit, submission)

View File

@@ -372,7 +372,7 @@ export default {
}, },
created() { created() {
console.log('SplitForm(' + this.index + ')'); // console.log('SplitForm(' + this.index + ')');
}, },
methods: { methods: {
removeTransaction: function () { removeTransaction: function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long