Clean up views and code

This commit is contained in:
James Cole
2021-07-05 20:01:36 +02:00
parent 8135c034a9
commit c0d3554acb
23 changed files with 169 additions and 419 deletions

View File

@@ -215,9 +215,6 @@ export default {
}
},
watch: {
storeReady: function () {
this.getAccountList();
},
start: function () {
this.getAccountList();
},

View File

@@ -19,18 +19,132 @@
-->
<template>
<div>
Hallo!
</div>
<div>
<div class="row" v-for="group in sortedGroups">
<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">
{{ group[1].title }}
</h3>
</div>
<div class="card-body p-0">
<b-table id="my-table" striped hover responsive="md" primary-key="id" :no-local-sorting="false"
:items="group[1].bills"
sort-icon-left
:busy.sync="loading"
>
</b-table>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import {mapGetters, mapMutations} from "vuex";
import {configureAxios} from "../../shared/forageStore";
export default {
name: "Index"
name: "Index",
data() {
return {
groups: {},
downloaded: false,
loading: false,
locale: 'en-US',
sortedGroups: [],
}
},
computed: {
...mapGetters('root', ['cacheKey']),
},
created() {
this.locale = localStorage.locale ?? 'en-US';
this.downloadBills(1);
},
methods: {
...mapMutations('root', ['refreshCacheKey',]),
resetGroups: function () {
this.groups = {};
this.groups[0] =
{
id: 0,
title: this.$t('firefly.default_group_title_name'),
order: 1,
bills: []
};
},
downloadBills: function (page) {
this.resetGroups();
configureAxios().then(async (api) => {
api.get('./api/v1/bills?page=' + page + 'key=' + this.cacheKey)
.then(response => {
// pages
let currentPage = parseInt(response.data.meta.pagination.current_page);
let totalPage = parseInt(response.data.meta.pagination.total_pages);
this.parseBills(response.data.data);
if (currentPage < totalPage) {
let nextPage = currentPage + 1;
this.downloadBills(nextPage);
}
if (currentPage >= totalPage) {
this.downloaded = true;
}
this.sortGroups();
}
);
});
},
sortGroups: function () {
const sortable = Object.entries(this.groups);
//console.log('sortable');
//console.log(sortable);
sortable.sort(function (a, b) {
return a.order - b.order;
});
this.sortedGroups = sortable;
//console.log(this.sortedGroups);
},
parseBills: function (data) {
for (let key in data) {
if (data.hasOwnProperty(key) && /^0$|^[1-9]\d*$/.test(key) && key <= 4294967294) {
let current = data[key];
let bill = {};
// create group of necessary.
let groupId = null === current.attributes.object_group_id ? 0 : parseInt(current.attributes.object_group_id);
if (0 !== groupId && !(groupId in this.groups)) {
this.groups[groupId] = {
id: groupId,
title: current.attributes.object_group_title,
order: parseInt(current.attributes.object_group_order),
bills: []
}
}
bill.id = parseInt(current.id);
bill.order = parseInt(current.order);
bill.name = current.attributes.name;
bill.repeat_freq = current.attributes.repeat_freq;
bill.skip = current.attributes.skip;
bill.active = current.attributes.active;
bill.amount_max = parseFloat(current.attributes.amount_max);
bill.amount_min = parseFloat(current.attributes.amount_min);
bill.currency_code = parseFloat(current.attributes.currency_code);
bill.currency_id = parseFloat(current.attributes.currency_id);
bill.currency_decimal_places = parseFloat(current.attributes.currency_decimal_places);
bill.currency_symbol = parseFloat(current.attributes.currency_symbol);
bill.next_expected_match = parseFloat(current.attributes.next_expected_match);
bill.notes = parseFloat(current.attributes.notes);
bill.paid_dates = parseFloat(current.attributes.paid_dates);
bill.pay_dates = parseFloat(current.attributes.pay_dates);
this.groups[groupId].bills.push(bill);
}
}
}
}
}
</script>
<style scoped>
</style>
</script>

View File

@@ -1058,7 +1058,7 @@
dependencies:
"@types/node" "*"
"@types/json-schema@*", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.6":
"@types/json-schema@*", "@types/json-schema@^7.0.5", "@types/json-schema@^7.0.7":
version "7.0.7"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.7.tgz#98a993516c859eb0d5c4c8f098317a9ea68db9ad"
integrity sha512-cxWFQVseBm6O9Gbw1IWb8r6OS4OhSt3hPZLkFApLjM8TEXROBuQGLAH2i2gZpcXdLBIrpXuTDhH7Vbm1iXmNGA==
@@ -5019,9 +5019,9 @@ pdfkit@>=0.8.1, pdfkit@^0.12.0:
png-js "^1.0.0"
pdfmake@^0.1.70:
version "0.1.71"
resolved "https://registry.yarnpkg.com/pdfmake/-/pdfmake-0.1.71.tgz#9cb20032cfed534f1bb5aa95026343fd7b4a5953"
integrity sha512-uXUy+NZ8R5pwJ6rYLJRu7VRw/w5ogBScNk440CHpMZ6Z0+E1uc1XvwK4I1U5ry0UZQ3qPD0dpSvbzAkRBKYoJA==
version "0.1.72"
resolved "https://registry.yarnpkg.com/pdfmake/-/pdfmake-0.1.72.tgz#b5ef0057e40e7a22b23a19aaf0be35ada902a3bf"
integrity sha512-xZrPS+Safjf1I8ZYtMoXX83E6C6Pd1zFwa168yNTeeJWHclqf1z9DoYajjlY2uviN7gGyxwVZeou39uSk1oh1g==
dependencies:
iconv-lite "^0.6.2"
linebreak "^1.0.2"
@@ -5743,11 +5743,11 @@ schema-utils@^2.6.5:
ajv-keywords "^3.5.2"
schema-utils@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.0.0.tgz#67502f6aa2b66a2d4032b4279a2944978a0913ef"
integrity sha512-6D82/xSzO094ajanoOSbe4YvXWMfn2A//8Y1+MUqFAJul5Bs+yn36xbK9OtNDcRVSBJ9jjeoXftM6CfztsjOAA==
version "3.1.0"
resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-3.1.0.tgz#95986eb604f66daadeed56e379bfe7a7f963cdb9"
integrity sha512-tTEaeYkyIhEZ9uWgAjDerWov3T9MgX8dhhy2r0IGeeX4W8ngtGl1++dUve/RUqzuaASSh7shwCDJjEzthxki8w==
dependencies:
"@types/json-schema" "^7.0.6"
"@types/json-schema" "^7.0.7"
ajv "^6.12.5"
ajv-keywords "^3.5.2"
@@ -5924,9 +5924,9 @@ sockjs@^0.3.21:
websocket-driver "^0.7.4"
sortablejs@^1.13.0:
version "1.13.0"
resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.13.0.tgz#3ab2473f8c69ca63569e80b1cd1b5669b51269e9"
integrity sha512-RBJirPY0spWCrU5yCmWM1eFs/XgX2J5c6b275/YyxFRgnzPhKl/TDeU2hNR8Dt7ITq66NRPM4UlOt+e5O4CFHg==
version "1.14.0"
resolved "https://registry.yarnpkg.com/sortablejs/-/sortablejs-1.14.0.tgz#6d2e17ccbdb25f464734df621d4f35d4ab35b3d8"
integrity sha512-pBXvQCs5/33fdN1/39pPL0NZF20LeRbLQ5jtnheIPN9JQAaufGjKdWduZn4U7wCtVuzKhmRkI0DFYHYRbB2H1w==
source-list-map@^2.0.0, source-list-map@^2.0.1:
version "2.0.1"
@@ -6670,9 +6670,9 @@ webpack-sources@^2.3.0:
source-map "^0.6.1"
webpack@^5.38.1, webpack@^5.40.0:
version "5.42.0"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.42.0.tgz#39aadbce84ad2cebf86cc5f88a2c53db65cbddfb"
integrity sha512-Ln8HL0F831t1x/yPB/qZEUVmZM4w9BnHZ1EQD/sAUHv8m22hthoPniWTXEzFMh/Sf84mhrahut22TX5KxWGuyQ==
version "5.42.1"
resolved "https://registry.yarnpkg.com/webpack/-/webpack-5.42.1.tgz#3347d0d93e79fe70bf62e51981024c80b9c8c3df"
integrity sha512-msikozzXrG2Hdx+dElq0fyNvxPFsaM2dKLc/l+xkMmhO/1qwVJ9K9gY+fi/49MYWcpSP7alnK5Q78Evrd1LiqQ==
dependencies:
"@types/eslint-scope" "^3.7.0"
"@types/estree" "^0.0.48"