Skip to content

Commit

Permalink
fix(network): fix detailed AC display and sorting of boards on listing (
Browse files Browse the repository at this point in the history
  • Loading branch information
LeonVreling authored Oct 9, 2024
1 parent 13cf27b commit 5985913
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 20 deletions.
14 changes: 7 additions & 7 deletions src/views/network/AntennaCriteriaCheck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ export default {
for (const organizer of event.organizing_bodies) {
const body = this.bodies.find(x => x.id === organizer.body_id)
if (body) {
const latestEvent = !body.latestEvent || moment(event.latestEvent).isAfter(moment(body.latestEvent))
? event.latestEvent
const latestEvent = !body.latestEvent || moment(event.latest_event).isAfter(moment(body.latestEvent))
? event.latest_event
: body.latestEvent
this.$set(body, 'latestEvent', latestEvent)
}
Expand All @@ -290,8 +290,8 @@ export default {
for (const event of this.statutoryEvents) {
const body = this.bodies.find(x => x.id === event.body_id)
if (body) {
const latestEvent = !body.latestEvent || moment(event.latestEvent).isAfter(moment(body.latestEvent))
? event.latestEvent
const latestEvent = !body.latestEvent || moment(event.latest_event).isAfter(moment(body.latestEvent))
? event.latest_event
: body.latestEvent
this.$set(body, 'latestEvent', latestEvent)
}
Expand All @@ -301,8 +301,8 @@ export default {
for (const organizer of event.organizing_bodies) {
const body = this.bodies.find(x => x.id === organizer.body_id)
if (body) {
const latestEvent = !body.latestEvent || moment(event.latestEvent).isAfter(moment(body.latestEvent))
? event.latestEvent
const latestEvent = !body.latestEvent || moment(event.latest_event).isAfter(moment(body.latestEvent))
? event.latest_event
: body.latestEvent
this.$set(body, 'latestEvent', latestEvent)
}
Expand All @@ -323,7 +323,7 @@ export default {
await this.axios.get(this.services['network'] + '/boards/recents', { params: { ends: this.selectedAgora.ends } }).then((boardsResponse) => {
for (const board of boardsResponse.data.data) {
const body = this.bodies.find(x => x.id === board.body_id)
this.$set(body, 'latestElection', board.latestElection)
this.$set(body, 'latestElection', board.latest_election)
}
// Check if the current board was elected within the past year
Expand Down
24 changes: 11 additions & 13 deletions src/views/network/BoardListing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

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

<b-table :data="bodies" :loading="isLoading" narrowed>
<b-table :data="filteredBodies" :loading="isLoading" narrowed>
<template slot-scope="props">
<b-table-column field="code" label="Body code">
{{ props.row.code }}
Expand Down Expand Up @@ -132,6 +132,12 @@ export default {
return queryObj
},
filteredBodies () {
if (!this.filters.noCurrentBoard) return this.bodies
const today = moment().format('YYYY-MM-DD')
return this.bodies.filter(x => !x.board || moment(x.board.end_date).isBefore(today, 'date'))
},
...mapGetters({
services: 'services',
loginUser: 'user'
Expand Down Expand Up @@ -161,19 +167,11 @@ export default {
this.axios.get(this.services['network'] + '/boards?sort=start_date&direction=desc').then((boardsResponse) => {
const boards = boardsResponse.data.data
const today = moment().format('YYYY-MM-DD')
// Add most recent board to their corresponding body
for (const board of boards) {
const body = this.bodies.find(x => board.body_id === x.id)
if (body && moment(board.start_date).isSameOrBefore(today, 'date')) {
body.board = board
}
}
// Apply filters on the final data
if (this.filters.noCurrentBoard) {
this.bodies = this.bodies.filter(x => !x.board || moment(x.board.end_date).isBefore(today, 'date'))
for (const body of this.bodies) {
const recentBoard = boards.find(board => board.body_id === body.id)
if (recentBoard) this.$set(body, 'board', recentBoard)
}
if (this.loginUser) {
Expand Down

0 comments on commit 5985913

Please sign in to comment.