From 1cf2f6083de212db57756f327237a9cec562d925 Mon Sep 17 00:00:00 2001 From: phlexplexico Date: Tue, 26 Apr 2022 14:54:01 -0600 Subject: [PATCH] Fix my matches. Server paginate/sort team tables. --- src/components/MatchesTable.vue | 44 ++++++++++++----- src/components/TeamsTable.vue | 85 +++++++++++++++++++++++---------- 2 files changed, 92 insertions(+), 37 deletions(-) diff --git a/src/components/MatchesTable.vue b/src/components/MatchesTable.vue index e499452..09baee4 100644 --- a/src/components/MatchesTable.vue +++ b/src/components/MatchesTable.vue @@ -48,6 +48,18 @@ {{ item.team2_string }} + @@ -62,7 +74,8 @@ export default { isLoading: true, isThereCancelledMatches: false, totalMatches: -1, - options: {} + options: {}, + deletePending: false }; }, computed: { @@ -84,7 +97,8 @@ export default { }, { text: this.$t("Matches.Status"), - value: "match_status" + value: "match_status", + sortable: false }, { text: this.$t("Matches.Owner"), @@ -92,12 +106,15 @@ export default { sortable: false } ]; + }, + isMyMatches() { + return this.$route.path == "/mymatches"; } }, watch: { options: { - handler() { - this.pageUpdate(); + async handler() { + await this.pageUpdate(); }, deep: true } @@ -118,14 +135,16 @@ export default { this.isLoading = false; }, async pageUpdate() { - let count = await this.GetAllMatches(); + let count = + this.$route.path == "/mymatches" + ? await this.GetMyMatches() + : await this.GetAllMatches(); const { sortBy, sortDesc, page, itemsPerPage } = this.options; if (typeof count == "string") count = []; if (sortBy.length === 1 && sortDesc.length === 1) { count = count.sort((a, b) => { const sortA = a[sortBy[0]]; const sortB = b[sortBy[0]]; - if (sortDesc[0]) { if (sortA < sortB) return 1; if (sortA > sortB) return -1; @@ -144,11 +163,14 @@ export default { await this.pushMatchData(count); return; }, - async checkRoute(offset, amount) { - let res; - if (offset < 0) res = await this.GetAllMatches(); - else res = await this.GetPagedMatches(offset, amount); - return res; + async deleteCancelled() { + this.deletePending = true; + await this.DeleteMyCancelledMatches(); + this.deletePending = false; + this.matches = []; + this.isLoading = true; + this.isThereCancelledMatches = false; + await this.pageUpdate(); } } }; diff --git a/src/components/TeamsTable.vue b/src/components/TeamsTable.vue index cfe97d9..86fdc0a 100644 --- a/src/components/TeamsTable.vue +++ b/src/components/TeamsTable.vue @@ -7,7 +7,8 @@ :loading-text="$t('misc.LoadText')" :headers="headers" :items="teams" - :sort-by="['id']" + :options.sync="options" + :server-items-length="totalTeams" ref="TeamsTable" >