Add API routes and expand v2 frontend

This commit is contained in:
James Cole
2023-09-20 06:18:25 +02:00
parent 0e3ebb9f1a
commit 6b5774a66d
8 changed files with 69 additions and 48 deletions

View File

@@ -201,14 +201,16 @@ export default () => ({
for (let iii = 0; iii < current.attributes.transactions.length; iii++) {
let currentTransaction = current.attributes.transactions[iii];
//console.log(currentTransaction);
const nativeAmountRaw = 'withdrawal' === currentTransaction.type ? parseFloat(currentTransaction.native_amount) * -1 : parseFloat(currentTransaction.native_amount);
const amountRaw = 'withdrawal' === currentTransaction.type ? parseFloat(currentTransaction.amount) * -1 : parseFloat(currentTransaction.amount);
group.transactions.push({
description: currentTransaction.description,
id: current.id,
type: currentTransaction.type,
amount_raw: parseFloat(currentTransaction.amount),
amount: formatMoney(currentTransaction.amount, currentTransaction.currency_code),
native_amount_raw: parseFloat(currentTransaction.native_amount),
native_amount: formatMoney(currentTransaction.native_amount, currentTransaction.native_currency_code),
amount_raw: amountRaw,
amount: formatMoney(amountRaw, currentTransaction.currency_code),
native_amount_raw: nativeAmountRaw,
native_amount: formatMoney(nativeAmountRaw, currentTransaction.native_currency_code),
});
}
groups.push(group);

View File

@@ -30,6 +30,8 @@ let transactions = function () {
return {
count: 0,
totalAmount: 0,
showSuccessMessage: false,
showErrorMessage: false,
entries: [],
// error and success messages:
@@ -37,38 +39,15 @@ let transactions = function () {
showSuccess: false,
init() {
const opts = {
onSelectItem: console.log,
};
let src = [];
for (let i = 0; i < 50; i++) {
src.push({
title: "Option " + i,
id: "opt" + i,
data: {
key: i,
},
});
}
// for each thing, make autocomplete?
console.log('init()');
this.addSplit();
console.log('Ik ben init hoera');
// let element = document.getElementById('source_0');
// new Autocomplete(element, {
// items: src,
// valueField: "id",
// labelField: "title",
// highlightTyped: true,
// onSelectItem: console.log,
// });
},
submitTransaction() {
// todo disable buttons
let transactions = parseFromEntries(this.entries);
let submission = {
// todo process all options
group_title: null,
fire_webhooks: false,
apply_rules: false,
@@ -77,8 +56,15 @@ let transactions = function () {
let poster = new Post();
console.log(submission);
poster.post(submission).then((response) => {
// todo create success banner
this.showSuccessMessage = true;
// todo or redirect to transaction.
// todo release form
console.log(response);
}).catch((error) => {
this.showErrorMessage = true;
// todo create error banner.
// todo release form
console.error(error);
});
},
@@ -90,7 +76,6 @@ let transactions = function () {
// fall back to index 0
const triggerFirstTabEl = document.querySelector('#split-0-tab')
triggerFirstTabEl.click();
//bootstrap.Tab.getInstance(triggerFirstTabEl).show() // Select first tab
},
formattedTotalAmount() {
return formatMoney(this.totalAmount, 'EUR');
@@ -109,7 +94,6 @@ function loadPage() {
Alpine.start();
}
// wait for load until bootstrapped event is received.
document.addEventListener('firefly-iii-bootstrapped', () => {
console.log('Loaded through event listener.');

View File

@@ -27,6 +27,7 @@ function getDefaultChartSettings(type) {
data: {
datasets: [],
},
options: {animations: false}
}
}
if ('pie' === type) {