mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Add API routes and expand v2 frontend
This commit is contained in:
parent
0e3ebb9f1a
commit
6b5774a66d
@ -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);
|
||||
|
@ -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.');
|
||||
|
@ -27,6 +27,7 @@ function getDefaultChartSettings(type) {
|
||||
data: {
|
||||
datasets: [],
|
||||
},
|
||||
options: {animations: false}
|
||||
}
|
||||
}
|
||||
if ('pie' === type) {
|
||||
|
@ -1681,6 +1681,7 @@ return [
|
||||
'remove_budgeted_amount' => 'Remove budgeted amount in :currency',
|
||||
|
||||
// bills:
|
||||
'subscription' => 'Subscription',
|
||||
'not_expected_period' => 'Not expected this period',
|
||||
'subscriptions_in_group' => 'Subscriptions in group "%{title}"',
|
||||
'subscr_expected_x_times' => 'Expect to pay %{amount} %{times} times this period',
|
||||
@ -1720,6 +1721,7 @@ return [
|
||||
'bill_edit_rules' => 'Firefly III will attempt to edit the rule related to this bill as well. If you\'ve edited this rule yourself however, Firefly III won\'t change anything.|Firefly III will attempt to edit the :count rules related to this bill as well. If you\'ve edited these rules yourself however, Firefly III won\'t change anything.',
|
||||
'bill_expected_date' => 'Expected :date',
|
||||
'bill_expected_date_js' => 'Expected {date}',
|
||||
'expected_amount' => '(Expected) amount',
|
||||
'bill_paid_on' => 'Paid on {date}',
|
||||
'bill_repeats_weekly' => 'Repeats weekly',
|
||||
'bill_repeats_monthly' => 'Repeats monthly',
|
||||
|
@ -13,7 +13,7 @@
|
||||
x-text="account.name"></a>
|
||||
|
||||
<span class="small">
|
||||
@include('partials.elements.amount', ['autoConversion' => true,'amount' => 'account.balance','native' => 'account.native_balance'])
|
||||
@include('partials.elements.amount', ['autoConversion' => true,'type' => 'null','amount' => 'account.balance','native' => 'account.native_balance'])
|
||||
</span>
|
||||
</h3>
|
||||
</div>
|
||||
@ -71,7 +71,7 @@
|
||||
</template>
|
||||
<template x-for="transaction in group.transactions">
|
||||
<span>
|
||||
@include('partials.elements.amount', ['autoConversion' => true,'amount' => 'transaction.amount','native' => 'transaction.native_amount'])
|
||||
@include('partials.elements.amount', ['autoConversion' => true,'type' => 'transaction.type','amount' => 'transaction.amount','native' => 'transaction.native_amount'])
|
||||
</span>
|
||||
</template>
|
||||
</td>
|
||||
|
@ -8,7 +8,7 @@
|
||||
</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<div class="card-body">
|
||||
<div class="row mb-2">
|
||||
<template x-for="pie in group.payment_info">
|
||||
<div :class='group.col_size'>
|
||||
@ -22,15 +22,15 @@
|
||||
<table class="table table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>TODO Subscription</th>
|
||||
<th>(Expected) amount</th>
|
||||
<th>{{ __('firefly.subscription') }}</th>
|
||||
<th>{{ __('firefly.expected_amount') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<template x-for="bill in group.bills">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#" :title="bill.name">
|
||||
<a :href="'{{ route('subscriptions.show',['']) }}/' + bill.id" :title="bill.name">
|
||||
<span x-text="bill.name"></span>
|
||||
</a>
|
||||
<template x-if="bill.paid">
|
||||
|
@ -7,9 +7,16 @@
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="{{ $native }}_raw >= 0">
|
||||
<span class="text-success">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
</span>
|
||||
<template x-if="'transfer' === {{ $type }}">
|
||||
<span class="text-primary">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="'transfer' !== {{ $type }}">
|
||||
<span class="text-success">
|
||||
<span x-text="{{ $native }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
</template>
|
||||
</span>
|
||||
</template>
|
||||
@ -29,13 +36,20 @@
|
||||
</template>
|
||||
@else
|
||||
<template x-if="{{ $amount }}_raw < 0">
|
||||
<span class="text-danger">
|
||||
<span x-text="{{ $amount }}"></span>
|
||||
</span>
|
||||
<span class="text-danger">
|
||||
<span x-text="{{ $amount }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="{{ $amount }}_raw >= 0">
|
||||
<span class="text-success">
|
||||
<span x-text="{{ $amount }}"></span>
|
||||
</span>
|
||||
<template x-if="'transfer' === {{ $type }}">
|
||||
<span class="text-primary">
|
||||
<span x-text="{{ $amount }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
<template x-if="'transfer' !== {{ $type }}">
|
||||
<span class="text-success">
|
||||
<span x-text="{{ $amount }}"></span>
|
||||
</span>
|
||||
</template>
|
||||
</template>
|
||||
@endif
|
||||
|
@ -202,6 +202,24 @@ Route::group(
|
||||
}
|
||||
);
|
||||
|
||||
/**
|
||||
* V2 API route for user groups (administrations).
|
||||
*/
|
||||
Route::group(
|
||||
[
|
||||
'namespace' => 'FireflyIII\Api\V2\Controllers\UserGroup',
|
||||
'prefix' => 'v2/user-groups',
|
||||
'as' => 'api.v2.user-groups.',
|
||||
],
|
||||
static function () {
|
||||
Route::get('', ['uses' => 'ShowController@index', 'as' => 'index']);
|
||||
Route::post('', ['uses' => 'StoreController@store', 'as' => 'store']);
|
||||
Route::get('{userGroup}', ['uses' => 'ShowController@show', 'as' => 'show']);
|
||||
}
|
||||
);
|
||||
|
||||
// down here is v1
|
||||
|
||||
/**
|
||||
* Autocomplete controllers
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user