Skip to content

Commit

Permalink
[gui] Client side pagination
Browse files Browse the repository at this point in the history
Rendering too many components in the product list page in a single row
can really slow down the rendering. For this reason with this patch
we will introduce a client side pagination, so we will not show all the
product in one round.
  • Loading branch information
csordasmarton committed Aug 17, 2021
1 parent bd6c9d1 commit 3f1d0a6
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions web/server/vue-cli/src/views/Products.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
:headers="headers"
:items="products"
:options.sync="pagination"
:server-items-length.sync="products.length"
:hide-default-footer="true"
:footer-props="footerProps"
:page.sync="page"
:must-sort="true"
:loading="loading"
:mobile-breakpoint="1000"
Expand Down Expand Up @@ -154,8 +154,10 @@ export default {
},
data() {
const itemsPerPageOptions = [ 25 ];
const sortBy = this.$router.currentRoute.query["sort-by"];
const sortDesc = this.$router.currentRoute.query["sort-desc"];
const page = parseInt(this.$router.currentRoute.query["page"]) || 1;
return {
DBStatus,
Expand All @@ -165,6 +167,10 @@ export default {
sortBy: sortBy ? [ sortBy ] : [],
sortDesc: sortDesc !== undefined ? [ !!sortDesc ] : []
},
footerProps: {
itemsPerPageOptions: itemsPerPageOptions
},
page,
headers: [
{
text: "Name",
Expand Down Expand Up @@ -220,6 +226,16 @@ export default {
deep: true
},
page() {
const page = this.page === 1 ? undefined : this.page;
this.$router.replace({
query: {
...this.$route.query,
"page": page
}
}).catch(() => {});
},
productNameSearch: _.debounce(function () {
this.$router.replace({
query: {
Expand Down Expand Up @@ -282,6 +298,8 @@ export default {
};
}).sort(this.sortProducts);
this.pagination.page = this.page;
this.loading = false;
}));
},
Expand Down

0 comments on commit 3f1d0a6

Please sign in to comment.