Skip to content

Commit

Permalink
fix(frontend): avoid mutating options prop in table component
Browse files Browse the repository at this point in the history
  • Loading branch information
pablolmedorado committed Oct 4, 2020
1 parent c819bec commit 2f4a56e
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions frontend/src/components/common/ItemTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -167,17 +167,18 @@ export default {
};
},
async fetchItems(resetPagination = false) {
this.tableLoading = true;
try {
this.$emit("input", []);
if (resetPagination) {
this.options.page = 1;
if (resetPagination && this.options.page !== 1) {
this.$emit("update:options", { ...this.options, page: 1 });
} else {
this.tableLoading = true;
try {
this.$emit("input", []);
const response = await this.service.list(this.buildFetchRequestParams());
this.items = this.options.itemsPerPage <= 0 ? response.data : response.data.results;
this.itemCount = this.options.itemsPerPage <= 0 ? response.data.length : response.data.count;
} finally {
this.tableLoading = false;
}
const response = await this.service.list(this.buildFetchRequestParams());
this.items = this.options.itemsPerPage <= 0 ? response.data : response.data.results;
this.itemCount = this.options.itemsPerPage <= 0 ? response.data.length : response.data.count;
} finally {
this.tableLoading = false;
}
}
}
Expand Down

0 comments on commit 2f4a56e

Please sign in to comment.