Files
firefly-iii/frontend/src/components/transactions/TransactionListSmall.vue

92 lines
3.3 KiB
Vue
Raw Normal View History

2020-07-03 05:59:36 +02:00
<!--
- TransactionListSmall.vue
- Copyright (c) 2020 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/>.
-->
2020-06-22 18:03:57 +02:00
<template>
2020-11-12 07:11:15 +01:00
<table class="table table-striped table-sm">
<caption style="display:none;">{{ $t('firefly.transaction_table_description') }}</caption>
<thead>
<tr>
2021-02-26 06:39:20 +01:00
<th class="text-left" scope="col">{{ $t('firefly.description') }}</th>
<th class="text-right" scope="col">{{ $t('firefly.amount') }}</th>
2020-11-12 07:11:15 +01:00
</tr>
</thead>
<tbody>
<tr v-for="transaction in this.transactions">
<td>
2021-02-26 06:39:20 +01:00
<a :href="'transactions/show/' + transaction.id "
:title="new Intl.DateTimeFormat(locale, { year: 'numeric', month: 'long', day: 'numeric' }).format(new Date(transaction.attributes.transactions[0].date))">
2020-11-12 07:11:15 +01:00
<span v-if="transaction.attributes.transactions.length > 1">{{ transaction.attributes.group_title }}</span>
<span v-if="1===transaction.attributes.transactions.length">{{ transaction.attributes.transactions[0].description }}</span>
</a>
</td>
<td style="text-align:right;">
2020-06-22 18:03:57 +02:00
<span v-for="tr in transaction.attributes.transactions">
<span v-if="'withdrawal' === tr.type" class="text-danger">
2020-11-12 07:11:15 +01:00
{{ Intl.NumberFormat(locale, {style: 'currency', currency: tr.currency_code}).format(tr.amount * -1) }}<br>
2020-06-22 18:03:57 +02:00
</span>
<span v-if="'deposit' === tr.type" class="text-success">
2020-11-12 07:11:15 +01:00
{{ Intl.NumberFormat(locale, {style: 'currency', currency: tr.currency_code}).format(tr.amount) }}<br>
2020-06-22 18:03:57 +02:00
</span>
2020-06-29 08:04:38 +02:00
<span v-if="'transfer' === tr.type && tr.source_id === account_id" class="text-info">
2020-11-12 07:11:15 +01:00
{{ Intl.NumberFormat(locale, {style: 'currency', currency: tr.currency_code}).format(tr.amount * -1) }}<br>
2020-06-29 08:04:38 +02:00
</span>
<span v-if="'transfer' === tr.type && tr.destination_id === account_id" class="text-info">
2020-11-12 07:11:15 +01:00
{{ Intl.NumberFormat(locale, {style: 'currency', currency: tr.currency_code}).format(tr.amount) }}<br>
2020-06-29 08:04:38 +02:00
</span>
2020-06-22 18:03:57 +02:00
</span>
2020-11-12 07:11:15 +01:00
</td>
</tr>
</tbody>
</table>
2020-06-22 18:03:57 +02:00
</template>
<script>
2020-11-12 07:11:15 +01:00
export default {
name: "TransactionListSmall",
data() {
return {
locale: 'en-US'
2020-06-22 18:03:57 +02:00
}
2020-11-12 07:11:15 +01:00
},
2021-01-26 19:57:20 +01:00
created() {
2020-11-12 07:11:15 +01:00
this.locale = localStorage.locale ?? 'en-US';
},
2021-02-26 06:39:20 +01:00
methods: {},
2020-11-12 07:11:15 +01:00
props: {
transactions: {
type: Array,
default: function () {
return [];
}
},
account_id: {
type: Number,
default: function () {
return 0;
}
},
}
}
2020-06-22 18:03:57 +02:00
</script>
<style scoped>
</style>