mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-11-01 03:29:33 +00:00
Merge branch 'release/5.5.0' into main
# Conflicts: # config/firefly.php # frontend/src/scss/_variables.scss # frontend/yarn.lock # public/v2/css/app.css # public/v2/css/app.css.map # public/v2/js/transactions/edit.js # public/v2/js/transactions/edit.js.map # public/v2/js/vendor.js # public/v2/js/vendor.js.map
This commit is contained in:
@@ -19,72 +19,110 @@
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Title thing</h3>
|
||||
<div class="card-tools">
|
||||
<div class="input-group input-group-sm" style="width: 150px;">
|
||||
<input class="form-control float-right" name="table_search" placeholder="Search" type="text">
|
||||
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-default" type="submit">
|
||||
<i class="fas fa-search"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<b-pagination
|
||||
v-model="currentPage"
|
||||
:total-rows="total"
|
||||
:per-page="perPage"
|
||||
aria-controls="my-table"
|
||||
></b-pagination>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body p-0">
|
||||
<table class="table table-sm table-striped">
|
||||
<caption style="display:none;">{{ $t('list.name') }}</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"> </th>
|
||||
<th scope="col">{{ $t('list.name') }}</th>
|
||||
<th v-if="'asset' === $props.accountTypes" scope="col">{{ $t('list.role') }}</th>
|
||||
<th scope="col">{{ $t('list.iban') }}</th>
|
||||
<th scope="col" style="text-align: right;">{{ $t('list.currentBalance') }}</th>
|
||||
<th scope="col">{{ $t('list.balanceDiff') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="account in accounts">
|
||||
<td>
|
||||
<div class="btn-group btn-group-xs">
|
||||
<a :href="'./accounts/edit/' + account.id" class="btn btn-xs btn-default"><i class="fa fas fa-pencil-alt"></i></a>
|
||||
<a :href="'./accounts/delete/' + account.id" class="btn btn-xs btn-danger"><i class="fa far fa-trash"></i></a>
|
||||
<div class="card-body p-0">
|
||||
<b-table id="my-table" striped hover primary-key="id"
|
||||
:items="accounts" :fields="fields"
|
||||
:per-page="perPage"
|
||||
sort-icon-left
|
||||
ref="table"
|
||||
:current-page="currentPage"
|
||||
:busy.sync="loading"
|
||||
:sort-by.sync="sortBy"
|
||||
:sort-desc.sync="sortDesc"
|
||||
>
|
||||
<template #cell(title)="data">
|
||||
<a :href="'./accounts/show/' + data.item.id" :title="data.value">{{ data.value }}</a>
|
||||
</template>
|
||||
<template #cell(number)="data">
|
||||
<span v-if="null !== data.item.iban && null === data.item.account_number">{{ data.item.iban }}</span>
|
||||
<span v-if="null === data.item.iban && null !== data.item.account_number">{{ data.item.account_number }}</span>
|
||||
<span v-if="null !== data.item.iban && null !== data.item.account_number">{{ data.item.iban }} ({{ data.item.account_number }})</span>
|
||||
</template>
|
||||
<template #cell(current_balance)="data">
|
||||
<span class="text-success" v-if="parseFloat(data.item.current_balance) > 0">
|
||||
{{
|
||||
Intl.NumberFormat('en-US', {
|
||||
style: 'currency', currency:
|
||||
data.item.currency_code
|
||||
}).format(data.item.current_balance)
|
||||
}}
|
||||
</span>
|
||||
<span class="text-danger" v-if="parseFloat(data.item.current_balance) < 0">
|
||||
{{
|
||||
Intl.NumberFormat('en-US', {
|
||||
style: 'currency', currency:
|
||||
data.item.currency_code
|
||||
}).format(data.item.current_balance)
|
||||
}}
|
||||
</span>
|
||||
|
||||
<span class="text-muted" v-if="0 === parseFloat(data.item.current_balance)">
|
||||
{{
|
||||
Intl.NumberFormat('en-US', {
|
||||
style: 'currency', currency:
|
||||
data.item.currency_code
|
||||
}).format(data.item.current_balance)
|
||||
}}
|
||||
</span>
|
||||
<span v-if="'asset' === type && 'loading' === data.item.balance_diff">
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
</span>
|
||||
<span v-if="'asset' === type && 'loading' !== data.item.balance_diff">
|
||||
(<span class="text-success" v-if="parseFloat(data.item.balance_diff) > 0">{{
|
||||
Intl.NumberFormat('en-US', {
|
||||
style: 'currency', currency:
|
||||
data.item.currency_code
|
||||
}).format(data.item.balance_diff)
|
||||
}}</span><span class="text-muted" v-if="0===parseFloat(data.item.balance_diff)">{{
|
||||
Intl.NumberFormat('en-US', {
|
||||
style: 'currency', currency:
|
||||
data.item.currency_code
|
||||
}).format(data.item.balance_diff)
|
||||
}}</span><span class="text-danger" v-if="parseFloat(data.item.balance_diff) < 0">{{
|
||||
Intl.NumberFormat('en-US', {
|
||||
style: 'currency', currency:
|
||||
data.item.currency_code
|
||||
}).format(data.item.balance_diff)
|
||||
}}</span>)
|
||||
</span>
|
||||
</template>
|
||||
<template #cell(menu)="data">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<div class="dropdown">
|
||||
<button class="btn btn-light btn-sm dropdown-toggle" type="button" :id="'dropdownMenuButton' + data.item.id" data-toggle="dropdown"
|
||||
aria-haspopup="true" aria-expanded="false">
|
||||
{{ $t('firefly.actions') }}
|
||||
</button>
|
||||
<div class="dropdown-menu" :aria-labelledby="'dropdownMenuButton' + data.item.id">
|
||||
<a class="dropdown-item" :href="'./accounts/edit/' + data.item.id"><i class="fa fas fa-pencil-alt"></i> {{ $t('firefly.edit') }}</a>
|
||||
<a class="dropdown-item" :href="'./accounts/delete/' + data.item.id"><i class="fa far fa-trash"></i> {{ $t('firefly.delete') }}</a>
|
||||
<a v-if="'asset' === type" class="dropdown-item" :href="'./accounts/reconcile/' + data.item.id"><i class="fas fa-check"></i>
|
||||
{{ $t('firefly.reconcile_this_account') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>{{ account.attributes.name }}
|
||||
<!--
|
||||
<router-link :to="{ name: 'accounts.show', params: { id: account.id }}"
|
||||
:title="account.attributes.name">{{ account.attributes.name }}
|
||||
</router-link>
|
||||
-->
|
||||
</td>
|
||||
<td v-if="'asset' === $props.accountTypes">
|
||||
{{ account.attributes.account_role }}
|
||||
</td>
|
||||
<td>
|
||||
{{ account.attributes.iban }}
|
||||
</td>
|
||||
<td style="text-align: right;">
|
||||
{{
|
||||
Intl.NumberFormat('en-US', {
|
||||
style: 'currency', currency:
|
||||
account.attributes.currency_code
|
||||
}).format(account.attributes.current_balance)
|
||||
}}
|
||||
</td>
|
||||
<td>diff</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
Footer stuff.
|
||||
</template>
|
||||
</b-table>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a :href="'./accounts/create/' + type" class="btn btn-success" :title="$t('firefly.create_new_' + type)">{{ $t('firefly.create_new_' + type) }}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -92,6 +130,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import {mapGetters} from "vuex";
|
||||
import Sortable from "sortablejs";
|
||||
|
||||
export default {
|
||||
name: "Index",
|
||||
props: {
|
||||
@@ -99,37 +141,246 @@ export default {
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
accounts: []
|
||||
accounts: [],
|
||||
allAccounts: [],
|
||||
type: 'all',
|
||||
downloaded: false,
|
||||
loading: false,
|
||||
ready: false,
|
||||
fields: [],
|
||||
currentPage: 1,
|
||||
perPage: 5,
|
||||
total: 0,
|
||||
sortBy: 'order',
|
||||
sortDesc: false,
|
||||
sortableOptions: {
|
||||
disabled: false,
|
||||
chosenClass: 'is-selected',
|
||||
onEnd: null
|
||||
},
|
||||
sortable: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
storeReady: function () {
|
||||
this.getAccountList();
|
||||
},
|
||||
start: function () {
|
||||
this.getAccountList();
|
||||
},
|
||||
end: function () {
|
||||
this.getAccountList();
|
||||
},
|
||||
orderMode: function (value) {
|
||||
// update the table headers
|
||||
this.updateFieldList();
|
||||
|
||||
// reorder the accounts:
|
||||
this.reorderAccountList(value);
|
||||
|
||||
// make table sortable:
|
||||
this.makeTableSortable(value);
|
||||
},
|
||||
activeFilter: function (value) {
|
||||
this.filterAccountList();
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapGetters('root', ['listPageSize']),
|
||||
...mapGetters('accounts/index', ['orderMode', 'activeFilter']),
|
||||
...mapGetters('dashboard/index', ['start', 'end',]),
|
||||
'indexReady': function () {
|
||||
return null !== this.start && null !== this.end && null !== this.listPageSize && this.ready;
|
||||
},
|
||||
cardTitle: function () {
|
||||
return this.$t('firefly.' + this.type + '_accounts');
|
||||
}
|
||||
},
|
||||
created() {
|
||||
//console.log('mounted account list.');
|
||||
axios.get('./api/v1/accounts?type=' + this.$props.accountTypes)
|
||||
.then(response => {
|
||||
this.loadAccounts(response.data.data);
|
||||
}
|
||||
);
|
||||
},
|
||||
methods: {
|
||||
loadAccounts(data) {
|
||||
for (let key in data) {
|
||||
if (data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||
let acct = data[key];
|
||||
let pathName = window.location.pathname;
|
||||
let parts = pathName.split('/');
|
||||
this.type = parts[parts.length - 1];
|
||||
|
||||
// some conversions here.
|
||||
if ('asset' === acct.attributes.type && null !== acct.attributes.account_role) {
|
||||
acct.attributes.account_role = this.$t('firefly.account_role_' + acct.attributes.account_role);
|
||||
let params = new URLSearchParams(window.location.search);
|
||||
this.currentPage = params.get('page') ? parseInt(params.get('page')) : 1;
|
||||
this.updateFieldList();
|
||||
this.ready = true;
|
||||
},
|
||||
|
||||
methods: {
|
||||
saveAccountSort: function (event) {
|
||||
let oldIndex = parseInt(event.oldIndex);
|
||||
let newIndex = parseInt(event.newIndex);
|
||||
let identifier = parseInt(event.item.attributes.getNamedItem('data-pk').value);
|
||||
for (let i in this.accounts) {
|
||||
if (this.accounts.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
|
||||
let current = this.accounts[i];
|
||||
|
||||
// the actual account
|
||||
if (current.id === identifier) {
|
||||
let newOrder = parseInt(current.order) + (newIndex - oldIndex);
|
||||
this.accounts[i].order = newOrder;
|
||||
let url = './api/v1/accounts/' + current.id;
|
||||
axios.put(url, {order: newOrder}).then(response => {
|
||||
// TODO should update local account list, not refresh the whole thing.
|
||||
this.getAccountList();
|
||||
});
|
||||
}
|
||||
if ('asset' === acct.attributes.type && null === acct.attributes.account_role) {
|
||||
acct.attributes.account_role = this.$t('firefly.Default asset account');
|
||||
}
|
||||
if (null === acct.attributes.iban) {
|
||||
acct.attributes.iban = acct.attributes.account_number;
|
||||
}
|
||||
this.accounts.push(acct);
|
||||
}
|
||||
}
|
||||
},
|
||||
reorderAccountList: function (orderMode) {
|
||||
if (orderMode) {
|
||||
this.sortBy = 'order';
|
||||
this.sortDesc = false;
|
||||
}
|
||||
},
|
||||
makeTableSortable: function (orderMode) {
|
||||
this.sortableOptions.disabled = !orderMode;
|
||||
this.sortableOptions.onEnd = this.saveAccountSort;
|
||||
|
||||
// make sortable of table:
|
||||
if (null === this.sortable) {
|
||||
this.sortable = Sortable.create(this.$refs.table.$el.querySelector('tbody'), this.sortableOptions);
|
||||
}
|
||||
this.sortable.option('disabled', this.sortableOptions.disabled);
|
||||
},
|
||||
|
||||
updateFieldList: function () {
|
||||
this.fields = [];
|
||||
|
||||
this.fields = [{key: 'title', label: this.$t('list.name'), sortable: !this.orderMode}];
|
||||
if ('asset' === this.type) {
|
||||
this.fields.push({key: 'role', label: this.$t('list.role'), sortable: !this.orderMode});
|
||||
}
|
||||
// add the rest
|
||||
this.fields.push({key: 'number', label: this.$t('list.iban'), sortable: !this.orderMode});
|
||||
this.fields.push({key: 'current_balance', label: this.$t('list.currentBalance'), sortable: !this.orderMode});
|
||||
this.fields.push({key: 'menu', label: ' ', sortable: false});
|
||||
},
|
||||
getAccountList: function () {
|
||||
console.log('getAccountList()');
|
||||
if (this.indexReady && !this.loading && !this.downloaded) {
|
||||
console.log('Index ready, not loading and not already downloaded. Reset.');
|
||||
this.loading = true;
|
||||
this.perPage = this.listPageSize ?? 51;
|
||||
this.accounts = [];
|
||||
this.allAccounts = [];
|
||||
this.downloadAccountList(1);
|
||||
}
|
||||
if (this.indexReady && !this.loading && this.downloaded) {
|
||||
console.log('Index ready, not loading and not downloaded.');
|
||||
this.loading = true;
|
||||
this.filterAccountList();
|
||||
// TODO filter accounts.
|
||||
}
|
||||
},
|
||||
downloadAccountList: function (page) {
|
||||
console.log('downloadAccountList(' + page + ')');
|
||||
axios.get('./api/v1/accounts?type=' + this.type + '&page=' + page)
|
||||
.then(response => {
|
||||
let currentPage = parseInt(response.data.meta.pagination.current_page);
|
||||
let totalPage = parseInt(response.data.meta.pagination.total_pages);
|
||||
this.total = parseInt(response.data.meta.pagination.total);
|
||||
this.parseAccounts(response.data.data);
|
||||
if (currentPage < totalPage) {
|
||||
let nextPage = currentPage + 1;
|
||||
this.downloadAccountList(nextPage);
|
||||
}
|
||||
if (currentPage >= totalPage) {
|
||||
console.log('Looks like all downloaded.');
|
||||
this.downloaded = true;
|
||||
this.filterAccountList();
|
||||
}
|
||||
}
|
||||
);
|
||||
},
|
||||
filterAccountList: function () {
|
||||
console.log('filterAccountList()');
|
||||
this.accounts = [];
|
||||
for (let i in this.allAccounts) {
|
||||
if (this.allAccounts.hasOwnProperty(i) && /^0$|^[1-9]\d*$/.test(i) && i <= 4294967294) {
|
||||
// 1 = active only
|
||||
// 2 = inactive only
|
||||
// 3 = both
|
||||
if (1 === this.activeFilter && false === this.allAccounts[i].active) {
|
||||
console.log('Skip account #' + this.allAccounts[i].id + ' because not active.');
|
||||
continue;
|
||||
}
|
||||
if (2 === this.activeFilter && true === this.allAccounts[i].active) {
|
||||
console.log('Skip account #' + this.allAccounts[i].id + ' because active.');
|
||||
continue;
|
||||
}
|
||||
console.log('Include account #' + this.allAccounts[i].id + '.');
|
||||
|
||||
this.accounts.push(this.allAccounts[i]);
|
||||
}
|
||||
}
|
||||
this.total = this.accounts.length;
|
||||
this.loading = false;
|
||||
},
|
||||
roleTranslate: function (role) {
|
||||
if (null === role) {
|
||||
return '';
|
||||
}
|
||||
return this.$t('firefly.account_role_' + role);
|
||||
},
|
||||
parsePages: function (data) {
|
||||
this.total = parseInt(data.pagination.total);
|
||||
//console.log('Total is now ' + this.total);
|
||||
},
|
||||
parseAccounts: function (data) {
|
||||
console.log('In parseAccounts()');
|
||||
for (let key in data) {
|
||||
if (data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
|
||||
let current = data[key];
|
||||
let acct = {};
|
||||
acct.id = parseInt(current.id);
|
||||
acct.order = current.attributes.order;
|
||||
acct.title = current.attributes.name;
|
||||
acct.active = current.attributes.active;
|
||||
acct.role = this.roleTranslate(current.attributes.account_role);
|
||||
acct.account_number = current.attributes.account_number;
|
||||
acct.current_balance = current.attributes.current_balance;
|
||||
acct.currency_code = current.attributes.currency_code;
|
||||
acct.balance_diff = 'loading';
|
||||
|
||||
if (null !== current.attributes.iban) {
|
||||
acct.iban = current.attributes.iban.match(/.{1,4}/g).join(' ');
|
||||
}
|
||||
|
||||
this.allAccounts.push(acct);
|
||||
if ('asset' === this.type) {
|
||||
this.getAccountBalanceDifference(this.allAccounts.length - 1, current);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
getAccountBalanceDifference: function (index, acct) {
|
||||
console.log('getAccountBalanceDifference(' + index + ')');
|
||||
// get account on day 0
|
||||
let promises = [];
|
||||
|
||||
// add meta data to promise context.
|
||||
promises.push(new Promise((resolve) => {
|
||||
resolve(
|
||||
{
|
||||
account: acct,
|
||||
index: index,
|
||||
}
|
||||
);
|
||||
}));
|
||||
|
||||
promises.push(axios.get('./api/v1/accounts/' + acct.id + '?date=' + this.start.toISOString().split('T')[0]));
|
||||
promises.push(axios.get('./api/v1/accounts/' + acct.id + '?date=' + this.end.toISOString().split('T')[0]));
|
||||
|
||||
Promise.all(promises).then(responses => {
|
||||
let index = responses[0].index;
|
||||
let startBalance = parseFloat(responses[1].data.data.attributes.current_balance);
|
||||
let endBalance = parseFloat(responses[2].data.data.attributes.current_balance);
|
||||
this.allAccounts[index].balance_diff = endBalance - startBalance;
|
||||
});
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
93
frontend/src/components/accounts/IndexOptions.vue
Normal file
93
frontend/src/components/accounts/IndexOptions.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<!--
|
||||
- IndexOptions.vue
|
||||
- Copyright (c) 2021 james@firefly-iii.org
|
||||
-
|
||||
- This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
-
|
||||
- This program is free software: you can redistribute it and/or modify
|
||||
- it under the terms of the GNU Affero General Public License as
|
||||
- published by the Free Software Foundation, either version 3 of the
|
||||
- License, or (at your option) any later version.
|
||||
-
|
||||
- This program is distributed in the hope that it will be useful,
|
||||
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
- GNU Affero General Public License for more details.
|
||||
-
|
||||
- You should have received a copy of the GNU Affero General Public License
|
||||
- along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
-->
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="order_mode" id="order_mode" v-model="orderMode">
|
||||
<label class="form-check-label" for="order_mode">
|
||||
Enable order mode
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" :disabled="orderMode" type="radio" value="1" v-model="activeFilter" id="active_filter_1">
|
||||
<label class="form-check-label" for="active_filter_1">
|
||||
Show active accounts
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" :disabled="orderMode" type="radio" value="2" v-model="activeFilter" id="active_filter_2">
|
||||
<label class="form-check-label" for="active_filter_2">
|
||||
Show inactive accounts
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" :disabled="orderMode" type="radio" value="3" v-model="activeFilter" id="active_filter_3">
|
||||
<label class="form-check-label" for="active_filter_3">
|
||||
Show both
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
export default {
|
||||
name: "IndexOptions",
|
||||
data() {
|
||||
return {
|
||||
type: 'invalid'
|
||||
}
|
||||
},
|
||||
// watch orderMode, if its false then go to active in filter.
|
||||
computed: {
|
||||
orderMode: {
|
||||
get() {
|
||||
return this.$store.getters["accounts/index/orderMode"];
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit('accounts/index/setOrderMode', value);
|
||||
if(true===value) {
|
||||
this.$store.commit('accounts/index/setActiveFilter', 1);
|
||||
}
|
||||
}
|
||||
},
|
||||
activeFilter: {
|
||||
get() {
|
||||
return this.$store.getters["accounts/index/activeFilter"];
|
||||
},
|
||||
set(value) {
|
||||
this.$store.commit('accounts/index/setActiveFilter', parseInt(value));
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
let pathName = window.location.pathname;
|
||||
let parts = pathName.split('/');
|
||||
this.type = parts[parts.length - 1];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -29,10 +29,8 @@
|
||||
<div :aria-valuenow="budgetLimit.pctGreen" :style="'width: '+ budgetLimit.pctGreen + '%;'"
|
||||
aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-success progress-bar-striped" role="progressbar">
|
||||
<span v-if="budgetLimit.pctGreen > 35">
|
||||
Spent
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent) }}
|
||||
of
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount) }}
|
||||
{{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }}
|
||||
<!-- -->
|
||||
</span>
|
||||
|
||||
|
||||
@@ -41,30 +39,20 @@
|
||||
<div :aria-valuenow="budgetLimit.pctOrange" :style="'width: '+ budgetLimit.pctOrange + '%;'"
|
||||
aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-warning progress-bar-striped" role="progressbar">
|
||||
<span v-if="budgetLimit.pctRed <= 50 && budgetLimit.pctOrange > 35">
|
||||
Spent
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent) }}
|
||||
of
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount) }}
|
||||
{{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div :aria-valuenow="budgetLimit.pctRed" :style="'width: '+ budgetLimit.pctRed + '%;'"
|
||||
aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-danger progress-bar-striped" role="progressbar">
|
||||
<span v-if="budgetLimit.pctOrange <= 50 && budgetLimit.pctRed > 35" class="text-muted">
|
||||
Spent
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent) }}
|
||||
of
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount) }}
|
||||
{{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- amount if bar is very small -->
|
||||
<span v-if="budgetLimit.pctGreen <= 35 && 0 === budgetLimit.pctOrange && 0 === budgetLimit.pctRed && 0 !== budgetLimit.pctGreen">
|
||||
|
||||
Spent
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent) }}
|
||||
of
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount) }}
|
||||
<span v-if="budgetLimit.pctGreen <= 35 && 0 === budgetLimit.pctOrange && 0 === budgetLimit.pctRed && 0 !== budgetLimit.pctGreen" style="line-height: 16px;">
|
||||
{{ $t('firefly.spent_x_of_y', {amount: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.spent), total: Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(budgetLimit.amount)}) }}
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -76,9 +76,13 @@
|
||||
<script>
|
||||
|
||||
import {createNamespacedHelpers} from "vuex";
|
||||
|
||||
import Vue from "vue";
|
||||
import DatePicker from "v-calendar/lib/components/date-picker.umd";
|
||||
const {mapState, mapGetters, mapActions, mapMutations} = createNamespacedHelpers('dashboard/index')
|
||||
|
||||
|
||||
Vue.component('date-picker', DatePicker)
|
||||
|
||||
export default {
|
||||
name: "Calendar",
|
||||
created() {
|
||||
|
||||
@@ -78,7 +78,6 @@ export default {
|
||||
watch: {
|
||||
datesReady: function (value) {
|
||||
if (true === value) {
|
||||
// console.log(this.chartOptions);
|
||||
this.initialiseChart();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -53,14 +53,15 @@
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: category.currency_code}).format(category.spent) }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-if="category.spentPct <= 20">
|
||||
<span v-if="category.spentPct <= 20" class="progress-label" style="line-height: 16px;">
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: category.currency_code}).format(category.spent) }}
|
||||
</span>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- EARNED -->
|
||||
<div v-if="category.earnedPct > 0" class="progress justify-content-end" title="hello2">
|
||||
<span v-if="category.earnedPct <= 20">
|
||||
<span v-if="category.earnedPct <= 20" style="line-height: 16px;">
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: category.currency_code}).format(category.earned) }}
|
||||
</span>
|
||||
<div :aria-valuenow="category.earnedPct" :style="{ width: category.earnedPct + '%'}" aria-valuemax="100"
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: entry.currency_code}).format(entry.difference_float) }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-if="entry.pct <= 20">
|
||||
<span v-if="entry.pct <= 20" style="line-height: 16px;">
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: entry.currency_code}).format(entry.difference_float) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: entry.currency_code}).format(entry.difference_float) }}
|
||||
</span>
|
||||
</div>
|
||||
<span v-if="entry.pct <= 20">
|
||||
<span v-if="entry.pct <= 20" style="line-height: 16px;">
|
||||
{{ Intl.NumberFormat(locale, {style: 'currency', currency: entry.currency_code}).format(entry.difference_float) }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
21
frontend/src/components/store/index.js
vendored
21
frontend/src/components/store/index.js
vendored
@@ -23,13 +23,17 @@ import Vuex, {createLogger} from 'vuex'
|
||||
import transactions_create from './modules/transactions/create';
|
||||
import transactions_edit from './modules/transactions/edit';
|
||||
import dashboard_index from './modules/dashboard/index';
|
||||
import root_store from './modules/root';
|
||||
import accounts_index from './modules/accounts/index';
|
||||
|
||||
Vue.use(Vuex)
|
||||
const debug = process.env.NODE_ENV !== 'production'
|
||||
|
||||
export default new Vuex.Store(
|
||||
{
|
||||
namespaced: true,
|
||||
modules: {
|
||||
root: root_store,
|
||||
transactions: {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
@@ -37,6 +41,12 @@ export default new Vuex.Store(
|
||||
edit: transactions_edit
|
||||
}
|
||||
},
|
||||
accounts: {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
index: accounts_index
|
||||
},
|
||||
},
|
||||
dashboard: {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
@@ -48,11 +58,11 @@ export default new Vuex.Store(
|
||||
plugins: debug ? [createLogger()] : [],
|
||||
state: {
|
||||
currencyPreference: {},
|
||||
locale: 'en-US'
|
||||
locale: 'en-US',
|
||||
listPageSize: 50
|
||||
},
|
||||
mutations: {
|
||||
setCurrencyPreference(state, payload) {
|
||||
//console.log('setCurrencyPreference', payload);
|
||||
state.currencyPreference = payload.payload;
|
||||
},
|
||||
initialiseStore(state) {
|
||||
@@ -61,6 +71,7 @@ export default new Vuex.Store(
|
||||
state.locale = localStorage.locale;
|
||||
return;
|
||||
}
|
||||
|
||||
// set locale from HTML:
|
||||
let localeToken = document.head.querySelector('meta[name="locale"]');
|
||||
if (localeToken) {
|
||||
@@ -82,13 +93,11 @@ export default new Vuex.Store(
|
||||
locale: state => {
|
||||
return state.locale;
|
||||
}
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
|
||||
updateCurrencyPreference(context) {
|
||||
if (localStorage.currencyPreference) {
|
||||
//console.log('set from local storage.');
|
||||
//console.log(localStorage.currencyPreference);
|
||||
//console.log({payload: JSON.parse(localStorage.currencyPreference)});
|
||||
context.commit('setCurrencyPreference', {payload: JSON.parse(localStorage.currencyPreference)});
|
||||
return;
|
||||
}
|
||||
|
||||
59
frontend/src/components/store/modules/accounts/index.js
vendored
Normal file
59
frontend/src/components/store/modules/accounts/index.js
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* index.js
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// initial state
|
||||
const state = () => (
|
||||
{
|
||||
orderMode: false,
|
||||
activeFilter: 1
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
// getters
|
||||
const getters = {
|
||||
orderMode: state => {
|
||||
return state.orderMode;
|
||||
},
|
||||
activeFilter: state => {
|
||||
return state.activeFilter;
|
||||
}
|
||||
}
|
||||
|
||||
// actions
|
||||
const actions = {}
|
||||
|
||||
// mutations
|
||||
const mutations = {
|
||||
setOrderMode(state, payload) {
|
||||
state.orderMode = payload;
|
||||
},
|
||||
setActiveFilter(state, payload) {
|
||||
state.activeFilter = payload;
|
||||
}
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
79
frontend/src/components/store/modules/root.js
vendored
Normal file
79
frontend/src/components/store/modules/root.js
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
* root.js
|
||||
* Copyright (c) 2021 james@firefly-iii.org
|
||||
*
|
||||
* This file is part of Firefly III (https://github.com/firefly-iii).
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// initial state
|
||||
const state = () => (
|
||||
{
|
||||
listPageSize: 33,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
// getters
|
||||
const getters = {
|
||||
listPageSize: state => {
|
||||
// console.log('Wil return ' + state.listPageSize);
|
||||
return state.listPageSize;
|
||||
},
|
||||
}
|
||||
|
||||
// actions
|
||||
const actions = {
|
||||
initialiseStore(context) {
|
||||
// console.log('Now in root initialiseStore');
|
||||
// if list length in local storage:
|
||||
if (localStorage.listPageSize) {
|
||||
// console.log('listPageSize is in localStorage')
|
||||
// console.log('Init list page size with value ');
|
||||
// console.log(localStorage.listPageSize);
|
||||
state.listPageSize = localStorage.listPageSize;
|
||||
context.commit('setListPageSize', {length: localStorage.listPageSize});
|
||||
}
|
||||
if (!localStorage.listPageSize) {
|
||||
axios.get('./api/v1/preferences/listPageSize')
|
||||
.then(response => {
|
||||
// console.log('from API: listPageSize is ' + parseInt(response.data.data.attributes.data));
|
||||
context.commit('setListPageSize', {length: parseInt(response.data.data.attributes.data)});
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// mutations
|
||||
const mutations = {
|
||||
setListPageSize(state, payload) {
|
||||
// console.log('Got a payload in setListPageSize');
|
||||
// console.log(payload);
|
||||
let number = parseInt(payload.length);
|
||||
if (0 !== number) {
|
||||
state.listPageSize = number;
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
getters,
|
||||
actions,
|
||||
mutations
|
||||
}
|
||||
@@ -529,6 +529,7 @@ export default {
|
||||
this.date.toISOString() !== this.originalDate.toISOString() ||
|
||||
this.time.toISOString() !== this.originalTime.toISOString()
|
||||
) {
|
||||
console.log('Date and/or time is changed');
|
||||
// set date and time!
|
||||
shouldSubmit = true;
|
||||
let theDate = this.date;
|
||||
@@ -537,7 +538,7 @@ export default {
|
||||
theDate.setMinutes(this.time.getMinutes());
|
||||
theDate.setSeconds(this.time.getSeconds());
|
||||
dateStr = toW3CString(theDate);
|
||||
submission.date = dateStr;
|
||||
diff.date = dateStr;
|
||||
}
|
||||
if (Object.keys(diff).length === 0 && transactionCount > 1) {
|
||||
diff.transaction_journal_id = originalTransaction.transaction_journal_id;
|
||||
@@ -623,8 +624,6 @@ export default {
|
||||
// // meanwhile, store the ID and the title in some easy to access variables.
|
||||
this.returnedGroupId = parseInt(response.data.data.id);
|
||||
this.returnedGroupTitle = null === response.data.data.attributes.group_title ? response.data.data.attributes.transactions[0].description : response.data.data.attributes.group_title;
|
||||
|
||||
|
||||
}
|
||||
)
|
||||
.catch(error => {
|
||||
|
||||
Reference in New Issue
Block a user