2020-11-21 12:06:43 +01:00
|
|
|
<!--
|
|
|
|
|
- BudgetRow.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/>.
|
|
|
|
|
-->
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="width:25%;">
|
|
|
|
|
<a :href="'./budgets/show/' + budgetLimit.budget_id">{{ budgetLimit.budget_name }}</a>
|
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
|
<td style="vertical-align: middle">
|
|
|
|
|
<div class="progress progress active">
|
2021-02-26 06:39:20 +01:00
|
|
|
<div :aria-valuenow="budgetLimit.pctGreen" :style="'width: '+ budgetLimit.pctGreen + '%;'"
|
2021-05-08 21:26:50 +02:00
|
|
|
aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-success" role="progressbar">
|
2020-11-21 12:06:43 +01:00
|
|
|
<span v-if="budgetLimit.pctGreen > 35">
|
2021-03-24 19:28:07 +01:00
|
|
|
{{ $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)}) }}
|
2021-03-24 06:28:32 +01:00
|
|
|
<!-- -->
|
2020-11-21 12:06:43 +01:00
|
|
|
</span>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-02-26 06:39:20 +01:00
|
|
|
<div :aria-valuenow="budgetLimit.pctOrange" :style="'width: '+ budgetLimit.pctOrange + '%;'"
|
2021-05-08 21:26:50 +02:00
|
|
|
aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-warning" role="progressbar">
|
2020-11-21 12:06:43 +01:00
|
|
|
<span v-if="budgetLimit.pctRed <= 50 && budgetLimit.pctOrange > 35">
|
2021-03-24 19:28:07 +01:00
|
|
|
{{ $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)}) }}
|
2020-11-21 12:06:43 +01:00
|
|
|
</span>
|
|
|
|
|
</div>
|
|
|
|
|
|
2021-02-26 06:39:20 +01:00
|
|
|
<div :aria-valuenow="budgetLimit.pctRed" :style="'width: '+ budgetLimit.pctRed + '%;'"
|
2021-05-08 21:26:50 +02:00
|
|
|
aria-valuemax="100" aria-valuemin="0" class="progress-bar bg-danger" role="progressbar">
|
2021-02-14 07:53:20 +01:00
|
|
|
<span v-if="budgetLimit.pctOrange <= 50 && budgetLimit.pctRed > 35" class="text-muted">
|
2021-03-24 19:28:07 +01:00
|
|
|
{{ $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)}) }}
|
2020-11-21 12:06:43 +01:00
|
|
|
</span>
|
|
|
|
|
</div>
|
2021-02-13 20:04:18 +01:00
|
|
|
|
|
|
|
|
<!-- amount if bar is very small -->
|
2021-03-24 19:28:07 +01:00
|
|
|
<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)}) }}
|
2021-02-13 20:04:18 +01:00
|
|
|
</span>
|
|
|
|
|
|
2020-11-21 12:06:43 +01:00
|
|
|
</div>
|
|
|
|
|
<small class="d-none d-lg-block">
|
|
|
|
|
{{ new Intl.DateTimeFormat(locale, {year: 'numeric', month: 'long', day: 'numeric'}).format(budgetLimit.start) }}
|
|
|
|
|
→
|
|
|
|
|
{{ new Intl.DateTimeFormat(locale, {year: 'numeric', month: 'long', day: 'numeric'}).format(budgetLimit.end) }}
|
|
|
|
|
</small>
|
|
|
|
|
</td>
|
|
|
|
|
|
2021-02-26 06:39:20 +01:00
|
|
|
<td class="align-middle d-none d-lg-table-cell" style="width:10%;">
|
|
|
|
|
<span v-if="parseFloat(budgetLimit.amount) + parseFloat(budgetLimit.spent) > 0" class="text-success">
|
2020-11-21 12:06:43 +01:00
|
|
|
{{
|
|
|
|
|
Intl.NumberFormat(locale, {
|
|
|
|
|
style: 'currency',
|
|
|
|
|
currency: budgetLimit.currency_code
|
|
|
|
|
}).format(parseFloat(budgetLimit.amount) + parseFloat(budgetLimit.spent))
|
|
|
|
|
}}
|
|
|
|
|
</span>
|
2021-02-26 06:39:20 +01:00
|
|
|
<span v-if="0.0 === parseFloat(budgetLimit.amount) + parseFloat(budgetLimit.spent)" class="text-muted">
|
2020-11-21 12:06:43 +01:00
|
|
|
{{ Intl.NumberFormat(locale, {style: 'currency', currency: budgetLimit.currency_code}).format(0) }}
|
|
|
|
|
</span>
|
2021-02-26 06:39:20 +01:00
|
|
|
<span v-if="parseFloat(budgetLimit.amount) + parseFloat(budgetLimit.spent) < 0" class="text-danger">
|
2020-11-21 12:06:43 +01:00
|
|
|
{{
|
|
|
|
|
Intl.NumberFormat(locale, {
|
|
|
|
|
style: 'currency',
|
|
|
|
|
currency: budgetLimit.currency_code
|
|
|
|
|
}).format(parseFloat(budgetLimit.amount) + parseFloat(budgetLimit.spent))
|
|
|
|
|
}}
|
|
|
|
|
</span>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
export default {
|
|
|
|
|
name: "BudgetLimitRow",
|
2021-02-03 19:52:47 +01:00
|
|
|
created() {
|
2020-11-22 07:50:55 +01:00
|
|
|
this.locale = localStorage.locale ?? 'en-US';
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
locale: 'en-US',
|
|
|
|
|
}
|
|
|
|
|
},
|
2020-11-21 12:06:43 +01:00
|
|
|
props: {
|
|
|
|
|
budgetLimit: {
|
|
|
|
|
type: Object,
|
2020-12-22 17:22:50 +01:00
|
|
|
default: function () {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
2020-11-21 12:06:43 +01:00
|
|
|
},
|
|
|
|
|
budget: {
|
|
|
|
|
type: Object,
|
2020-12-22 17:22:50 +01:00
|
|
|
default: function () {
|
|
|
|
|
return {};
|
|
|
|
|
}
|
2020-11-21 12:06:43 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</script>
|
|
|
|
|
|