-
{{ $t('Exchange Rates Data') }}
-
-
- {{ $t('Refresh') }}
-
-
+
+
+
+
+
{{ $t('Data source') }}
+
+ {{ exchangeRatesData.dataSource }}
+ {{ exchangeRatesData.dataSource }}
+ {{ $t('None') }}
+
+
+
+
+
{{ $t('Last Updated') }}
+
+ {{ exchangeRatesDataUpdateTime }}
+
+
+
+
+
+
+
+
{{ $t('Base Amount') }}
+
+
+
+ {{ $t('Base Currency') }}
+
+
+
+ {{ exchangeRate.currencyDisplayName }}
+ {{ exchangeRate.currencyCode }}
+
+
+
+ {{ $t('None') }}
+
+
-
-
-
- {{ $t('Data source') }}
- {{ exchangeRatesData.dataSource }}
- {{ exchangeRatesData.dataSource }}
- , {{ $t('Last Updated') }} {{ exchangeRatesDataUpdateTime }}
-
-
-
- {{ $t('No exchange rates data') }}
-
-
-
-
- {{ $t('Base Currency') }}
-
-
-
-
-
-
-
- {{ $t('Base Amount') }}
-
-
-
-
-
-
-
-
-
- | {{ $t('Currency') }} |
- {{ $t('Amount') }} |
-
-
+
+
+
+
+
+ {{ $t('Exchange Rates Data') }}
+
+
+ {{ $t('Refresh') }}
+
+
+
+
-
-
- |
- {{ exchangeRate.currencyDisplayName }}
- {{ exchangeRate.currencyCode }}
- |
- {{ getDisplayConvertedAmount(exchangeRate) }} |
-
-
-
+
+
+
+ | {{ $t('Currency') }} |
+ {{ $t('Amount') }} |
+
+
+
+
+
+ |
+
+ |
+
+
+
+ | {{ $t('No exchange rates data') }} |
+
+
+
+ |
+ {{ exchangeRate.currencyDisplayName }}
+ {{ exchangeRate.currencyCode }}
+ |
+ {{ getDisplayConvertedAmount(exchangeRate) }} |
+
+
+
+
+
+
+
@@ -95,9 +121,10 @@ export default {
const userStore = useUserStore();
return {
+ activeTab: 'exchangeRatesPage',
baseCurrency: userStore.currentUserDefaultCurrency,
baseAmount: '1',
- loading: false,
+ loading: true,
icons: {
refresh: mdiRefresh
}
@@ -120,34 +147,37 @@ export default {
}
},
created() {
- if (!this.exchangeRatesData || !this.exchangeRatesData.exchangeRates) {
- return;
- }
-
- for (let i = 0; i < this.exchangeRatesData.exchangeRates.length; i++) {
- const exchangeRate = this.exchangeRatesData.exchangeRates[i];
- if (exchangeRate.currency === this.baseCurrency) {
- return;
- }
- }
-
- this.$refs.snackbar.showMessage('There is no exchange rates data for your default currency');
+ this.reload(false);
},
methods: {
- update() {
+ reload(force) {
const self = this;
- if (self.loading) {
- return;
- }
-
self.loading = true;
+
self.exchangeRatesStore.getLatestExchangeRates({
silent: false,
- force: true
+ force: force
}).then(() => {
self.loading = false;
- self.$refs.snackbar.showMessage('Exchange rates data has been updated');
+
+ if (this.exchangeRatesData && this.exchangeRatesData.exchangeRates) {
+ let foundDefaultCurrency = false;
+
+ for (let i = 0; i < this.exchangeRatesData.exchangeRates.length; i++) {
+ const exchangeRate = this.exchangeRatesData.exchangeRates[i];
+ if (exchangeRate.currency === this.baseCurrency) {
+ foundDefaultCurrency = true;
+ break;
+ }
+ }
+
+ if (force) {
+ self.$refs.snackbar.showMessage('Exchange rates data has been updated');
+ } else if (!foundDefaultCurrency) {
+ this.$refs.snackbar.showMessage('There is no exchange rates data for your default currency');
+ }
+ }
}).catch(error => {
self.loading = false;
@@ -170,9 +200,23 @@ export default {
}
},
getDisplayConvertedAmount(toExchangeRate) {
+ if (this.baseAmount === '') {
+ return '';
+ }
+
const rateStr = this.getConvertedAmount(toExchangeRate).toString();
return getDisplayExchangeRateAmount(rateStr, this.isEnableThousandsSeparator);
}
}
}
+
+