Build frontend again, using Yarn.

This commit is contained in:
James Cole
2020-11-12 07:11:15 +01:00
parent 60339c9d1b
commit ce51bb8be6
8 changed files with 282 additions and 271 deletions

View File

@@ -43,9 +43,9 @@ if (token) {
let localeToken = document.head.querySelector('meta[name="locale"]'); let localeToken = document.head.querySelector('meta[name="locale"]');
if (localeToken) { if (localeToken) {
window.localeValue = localeToken.content; localStorage.locale = localeToken.content;
} else { } else {
window.localeValue = 'en_US'; localStorage.locale = 'en_US';
} }
// admin stuff // admin stuff

View File

@@ -19,12 +19,13 @@
--> -->
<script> <script>
export default { export default {
name: "DataConverter", name: "DataConverter",
data() { data() {
return { return {
dataSet: null, dataSet: null,
newDataSet: null, newDataSet: null,
locale: localStorage.local,
} }
}, },
methods: { methods: {
@@ -142,7 +143,7 @@
for (let labelKey in dataSet.labels) { for (let labelKey in dataSet.labels) {
if (dataSet.labels.hasOwnProperty(labelKey)) { if (dataSet.labels.hasOwnProperty(labelKey)) {
const unixTimeZero = Date.parse(dataSet.labels[labelKey]); const unixTimeZero = Date.parse(dataSet.labels[labelKey]);
dataSet.labels[labelKey] = new Intl.DateTimeFormat(window.localeValue).format(unixTimeZero); dataSet.labels[labelKey] = new Intl.DateTimeFormat(this.locale).format(unixTimeZero);
} }
} }
return dataSet; return dataSet;
@@ -180,5 +181,5 @@
} }
} }
} }
} }
</script> </script>

View File

@@ -83,7 +83,7 @@
callback: function (tickValue) { callback: function (tickValue) {
"use strict"; "use strict";
let currencyCode = this.chart.data.datasets[0] ? this.chart.data.datasets[0].currency_code : 'EUR'; let currencyCode = this.chart.data.datasets[0] ? this.chart.data.datasets[0].currency_code : 'EUR';
return new Intl.NumberFormat(window.localeValue, {style: 'currency', currency: currencyCode}).format(tickValue); return new Intl.NumberFormat(localStorage.locale, {style: 'currency', currency: currencyCode}).format(tickValue);
}, },
} }
@@ -95,7 +95,7 @@
label: function (tooltipItem, data) { label: function (tooltipItem, data) {
"use strict"; "use strict";
let currencyCode = data.datasets[tooltipItem.datasetIndex] ? data.datasets[tooltipItem.datasetIndex].currency_code : 'EUR'; let currencyCode = data.datasets[tooltipItem.datasetIndex] ? data.datasets[tooltipItem.datasetIndex].currency_code : 'EUR';
let nrString = new Intl.NumberFormat(window.localeValue, { let nrString = new Intl.NumberFormat(localStorage.locale, {
style: 'currency', style: 'currency',
currency: currencyCode currency: currencyCode
}).format(tooltipItem.yLabel); }).format(tooltipItem.yLabel);

View File

@@ -106,7 +106,7 @@ export default {
// date format // date format
let dateObj = new Date(value); let dateObj = new Date(value);
let options = { year: 'numeric', month: 'long', day: 'numeric' }; let options = { year: 'numeric', month: 'long', day: 'numeric' };
let str = new Intl.DateTimeFormat(window.localeValue, options).format(dateObj); let str = new Intl.DateTimeFormat(localStorage.locale, options).format(dateObj);
//console.log(); //console.log();
//return self.formatLabel(value, 20); //return self.formatLabel(value, 20);
return self.formatLabel(str, 20); return self.formatLabel(str, 20);
@@ -120,7 +120,7 @@ export default {
callback: function (tickValue) { callback: function (tickValue) {
"use strict"; "use strict";
let currencyCode = this.chart.data.datasets[0].currency_code ? this.chart.data.datasets[0].currency_code : 'EUR'; let currencyCode = this.chart.data.datasets[0].currency_code ? this.chart.data.datasets[0].currency_code : 'EUR';
return new Intl.NumberFormat(window.localeValue, {style: 'currency', currency: currencyCode}).format(tickValue); return new Intl.NumberFormat(localStorage.locale, {style: 'currency', currency: currencyCode}).format(tickValue);
}, },
beginAtZero: true beginAtZero: true
} }
@@ -134,7 +134,7 @@ export default {
"use strict"; "use strict";
let currencyCode = data.datasets[tooltipItem.datasetIndex].currency_code ? data.datasets[tooltipItem.datasetIndex].currency_code : 'EUR'; let currencyCode = data.datasets[tooltipItem.datasetIndex].currency_code ? data.datasets[tooltipItem.datasetIndex].currency_code : 'EUR';
let nrString = let nrString =
new Intl.NumberFormat(window.localeValue, {style: 'currency', currency: currencyCode}).format(tooltipItem.yLabel) new Intl.NumberFormat(localStorage.locale, {style: 'currency', currency: currencyCode}).format(tooltipItem.yLabel)
return data.datasets[tooltipItem.datasetIndex].label + ': ' + nrString; return data.datasets[tooltipItem.datasetIndex].label + ': ' + nrString;
} }

View File

@@ -27,9 +27,9 @@
<h3 class="card-title"><a :href="account.uri">{{ account.title }}</a></h3> <h3 class="card-title"><a :href="account.uri">{{ account.title }}</a></h3>
</div> </div>
<div class="card-body table-responsive p-0"> <div class="card-body table-responsive p-0">
<transaction-list-large :transactions="account.transactions" v-if="1===accounts.length" :account_id="account.id" /> <transaction-list-large :transactions="account.transactions" v-if="1===accounts.length" :account_id="account.id"/>
<transaction-list-medium :transactions="account.transactions" v-if="2===accounts.length" :account_id="account.id" /> <transaction-list-medium :transactions="account.transactions" v-if="2===accounts.length" :account_id="account.id"/>
<transaction-list-small :transactions="account.transactions" v-if="accounts.length > 2" :account_id="account.id" /> <transaction-list-small :transactions="account.transactions" v-if="accounts.length > 2" :account_id="account.id"/>
</div> </div>
</div> </div>
</div> </div>
@@ -37,7 +37,7 @@
</template> </template>
<script> <script>
export default { export default {
name: "MainAccountList", name: "MainAccountList",
data() { data() {
return { return {
@@ -84,7 +84,7 @@
); );
}, },
} }
} }
</script> </script>
<style scoped> <style scoped>

View File

@@ -30,7 +30,7 @@
<tbody> <tbody>
<tr v-for="transaction in this.transactions"> <tr v-for="transaction in this.transactions">
<td> <td>
<a :href="'transactions/show/' + transaction.id " :title="transaction.date"> <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))">
<span v-if="transaction.attributes.transactions.length > 1">{{ transaction.attributes.group_title }}</span> <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> <span v-if="1===transaction.attributes.transactions.length">{{ transaction.attributes.transactions[0].description }}</span>
</a> </a>
@@ -38,16 +38,16 @@
<td style="text-align:right;"> <td style="text-align:right;">
<span v-for="tr in transaction.attributes.transactions"> <span v-for="tr in transaction.attributes.transactions">
<span v-if="'withdrawal' === tr.type" class="text-danger"> <span v-if="'withdrawal' === tr.type" class="text-danger">
{{ Intl.NumberFormat('en-US', {style: 'currency', currency: tr.currency_code}).format(tr.amount * -1)}}<br> {{ Intl.NumberFormat(locale, {style: 'currency', currency: tr.currency_code}).format(tr.amount * -1) }}<br>
</span> </span>
<span v-if="'deposit' === tr.type" class="text-success"> <span v-if="'deposit' === tr.type" class="text-success">
{{ Intl.NumberFormat('en-US', {style: 'currency', currency: tr.currency_code}).format(tr.amount)}}<br> {{ Intl.NumberFormat(locale, {style: 'currency', currency: tr.currency_code}).format(tr.amount) }}<br>
</span> </span>
<span v-if="'transfer' === tr.type && tr.source_id === account_id" class="text-info"> <span v-if="'transfer' === tr.type && tr.source_id === account_id" class="text-info">
{{ Intl.NumberFormat('en-US', {style: 'currency', currency: tr.currency_code}).format(tr.amount * -1)}}<br> {{ Intl.NumberFormat(locale, {style: 'currency', currency: tr.currency_code}).format(tr.amount * -1) }}<br>
</span> </span>
<span v-if="'transfer' === tr.type && tr.destination_id === account_id" class="text-info"> <span v-if="'transfer' === tr.type && tr.destination_id === account_id" class="text-info">
{{ Intl.NumberFormat('en-US', {style: 'currency', currency: tr.currency_code}).format(tr.amount)}}<br> {{ Intl.NumberFormat(locale, {style: 'currency', currency: tr.currency_code}).format(tr.amount) }}<br>
</span> </span>
</span> </span>
</td> </td>
@@ -57,8 +57,18 @@
</template> </template>
<script> <script>
export default { export default {
name: "TransactionListSmall", name: "TransactionListSmall",
data() {
return {
locale: 'en-US'
}
},
mounted() {
this.locale = localStorage.locale ?? 'en-US';
},
methods: {
},
props: { props: {
transactions: { transactions: {
type: Array, type: Array,
@@ -68,12 +78,12 @@
}, },
account_id: { account_id: {
type: Number, type: Number,
default: function() { default: function () {
return 0; return 0;
} }
}, },
} }
} }
</script> </script>
<style scoped> <style scoped>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long