Skip to content

Commit 5985913

Browse files
authored
fix(network): fix detailed AC display and sorting of boards on listing (#2212)
1 parent 13cf27b commit 5985913

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

src/views/network/AntennaCriteriaCheck.vue

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,8 @@ export default {
279279
for (const organizer of event.organizing_bodies) {
280280
const body = this.bodies.find(x => x.id === organizer.body_id)
281281
if (body) {
282-
const latestEvent = !body.latestEvent || moment(event.latestEvent).isAfter(moment(body.latestEvent))
283-
? event.latestEvent
282+
const latestEvent = !body.latestEvent || moment(event.latest_event).isAfter(moment(body.latestEvent))
283+
? event.latest_event
284284
: body.latestEvent
285285
this.$set(body, 'latestEvent', latestEvent)
286286
}
@@ -290,8 +290,8 @@ export default {
290290
for (const event of this.statutoryEvents) {
291291
const body = this.bodies.find(x => x.id === event.body_id)
292292
if (body) {
293-
const latestEvent = !body.latestEvent || moment(event.latestEvent).isAfter(moment(body.latestEvent))
294-
? event.latestEvent
293+
const latestEvent = !body.latestEvent || moment(event.latest_event).isAfter(moment(body.latestEvent))
294+
? event.latest_event
295295
: body.latestEvent
296296
this.$set(body, 'latestEvent', latestEvent)
297297
}
@@ -301,8 +301,8 @@ export default {
301301
for (const organizer of event.organizing_bodies) {
302302
const body = this.bodies.find(x => x.id === organizer.body_id)
303303
if (body) {
304-
const latestEvent = !body.latestEvent || moment(event.latestEvent).isAfter(moment(body.latestEvent))
305-
? event.latestEvent
304+
const latestEvent = !body.latestEvent || moment(event.latest_event).isAfter(moment(body.latestEvent))
305+
? event.latest_event
306306
: body.latestEvent
307307
this.$set(body, 'latestEvent', latestEvent)
308308
}
@@ -323,7 +323,7 @@ export default {
323323
await this.axios.get(this.services['network'] + '/boards/recents', { params: { ends: this.selectedAgora.ends } }).then((boardsResponse) => {
324324
for (const board of boardsResponse.data.data) {
325325
const body = this.bodies.find(x => x.id === board.body_id)
326-
this.$set(body, 'latestElection', board.latestElection)
326+
this.$set(body, 'latestElection', board.latest_election)
327327
}
328328
329329
// Check if the current board was elected within the past year

src/views/network/BoardListing.vue

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@
3636

3737
<div class="field">
3838
<label class="label">Other filters</label>
39-
<input class="checkbox" type="checkbox" v-model="filters.noCurrentBoard" @change="refetch()" />
39+
<input class="checkbox" type="checkbox" v-model="filters.noCurrentBoard" />
4040
Only display bodies without a current board
4141
</div>
4242

43-
<b-table :data="bodies" :loading="isLoading" narrowed>
43+
<b-table :data="filteredBodies" :loading="isLoading" narrowed>
4444
<template slot-scope="props">
4545
<b-table-column field="code" label="Body code">
4646
{{ props.row.code }}
@@ -132,6 +132,12 @@ export default {
132132
133133
return queryObj
134134
},
135+
filteredBodies () {
136+
if (!this.filters.noCurrentBoard) return this.bodies
137+
138+
const today = moment().format('YYYY-MM-DD')
139+
return this.bodies.filter(x => !x.board || moment(x.board.end_date).isBefore(today, 'date'))
140+
},
135141
...mapGetters({
136142
services: 'services',
137143
loginUser: 'user'
@@ -161,19 +167,11 @@ export default {
161167
162168
this.axios.get(this.services['network'] + '/boards?sort=start_date&direction=desc').then((boardsResponse) => {
163169
const boards = boardsResponse.data.data
164-
const today = moment().format('YYYY-MM-DD')
165170
166171
// Add most recent board to their corresponding body
167-
for (const board of boards) {
168-
const body = this.bodies.find(x => board.body_id === x.id)
169-
if (body && moment(board.start_date).isSameOrBefore(today, 'date')) {
170-
body.board = board
171-
}
172-
}
173-
174-
// Apply filters on the final data
175-
if (this.filters.noCurrentBoard) {
176-
this.bodies = this.bodies.filter(x => !x.board || moment(x.board.end_date).isBefore(today, 'date'))
172+
for (const body of this.bodies) {
173+
const recentBoard = boards.find(board => board.body_id === body.id)
174+
if (recentBoard) this.$set(body, 'board', recentBoard)
177175
}
178176
179177
if (this.loginUser) {

0 commit comments

Comments
 (0)