Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(network): Fix various small problems for the Antenna Criteria check #2204

Merged
merged 6 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 30 additions & 31 deletions src/views/network/AntennaCriteriaCheck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@
</b-table-column>

<b-table-column field="boardElection" label="Board election (BE)">
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.boardElection && !showDetails">Yes</b-tag>
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.boardElection && showDetails">
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.boardElection === 'true' && !showDetails">Yes</b-tag>
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.boardElection === 'true' && showDetails">
{{ props.row.latest_election }}
</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="!props.row.antennaCriteria.boardElection && !showDetails && props.row.type === 'antenna'">No</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="!props.row.antennaCriteria.boardElection && showDetails && props.row.latest_election && props.row.type === 'antenna'">
<b-tag type="is-danger" size="is-medium" v-if="props.row.antennaCriteria.boardElection !== 'true' && !showDetails && props.row.type === 'antenna'">No</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="props.row.antennaCriteria.boardElection !== 'true' && showDetails && props.row.latest_election && props.row.type === 'antenna'">
{{ props.row.latest_election }}
</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="!props.row.antennaCriteria.boardElection && showDetails && !props.row.latest_election && props.row.type === 'antenna'">No</b-tag>
<b-tag type="is-info" size="is-medium" v-if="!props.row.antennaCriteria.boardElection && props.row.type !== 'antenna'">Else</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="props.row.antennaCriteria.boardElection !== 'true' && showDetails && !props.row.latest_election && props.row.type === 'antenna'">No</b-tag>
<b-tag type="is-info" size="is-medium" v-if="props.row.antennaCriteria.boardElection !== 'true' && props.row.type !== 'antenna'">Else</b-tag>
</b-table-column>

<b-table-column field="membersList" label="Members list (ML)">
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.membersList">Yes</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="!props.row.antennaCriteria.membersList && props.row.type !== 'contact'">No</b-tag>
<b-tag type="is-info" size="is-medium" v-if="!props.row.antennaCriteria.membersList && props.row.type === 'contact'">Else</b-tag>
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.membersList === 'true'">Yes</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="props.row.antennaCriteria.membersList !== 'true' && props.row.type !== 'contact'">No</b-tag>
<b-tag type="is-info" size="is-medium" v-if="props.row.antennaCriteria.membersList !== 'true' && props.row.type === 'contact'">Else</b-tag>
</b-table-column>

<b-table-column field="membershipFee" label="Membership fee (F)">
Expand All @@ -75,16 +75,16 @@
</b-table-column>

<b-table-column field="mostRecentEvent" label="Events (E)">
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.events && !showDetails">Yes</b-tag>
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.events && showDetails">
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.events === 'true' && !showDetails">Yes</b-tag>
<b-tag type="is-success" size="is-medium" v-if="props.row.antennaCriteria.events === 'true' && showDetails">
{{ props.row.latest_event }}
</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="!props.row.antennaCriteria.events && !showDetails && props.row.type === 'antenna'">No</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="!props.row.antennaCriteria.events && showDetails && props.row.latest_event && props.row.type === 'antenna'">
<b-tag type="is-danger" size="is-medium" v-if="props.row.antennaCriteria.events !== 'true' && !showDetails && props.row.type === 'antenna'">No</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="props.row.antennaCriteria.events !== 'true' && showDetails && props.row.latest_event && props.row.type === 'antenna'">
{{ props.row.latest_event }}
</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="!props.row.antennaCriteria.events && showDetails && !props.row.latest_event && props.row.type === 'antenna'">No</b-tag>
<b-tag type="is-info" size="is-medium" v-if="!props.row.antennaCriteria.events && props.row.type !== 'antenna'">Else</b-tag>
<b-tag type="is-danger" size="is-medium" v-if="props.row.antennaCriteria.events !== 'true' && showDetails && !props.row.latest_event && props.row.type === 'antenna'">No</b-tag>
<b-tag type="is-info" size="is-medium" v-if="props.row.antennaCriteria.events !== 'true' && props.row.type !== 'antenna'">Else</b-tag>
</b-table-column>

<b-table-column field="attendance" label="Agora attendance (AA)">
Expand Down Expand Up @@ -164,7 +164,8 @@ export default {
events: [],
statutoryEvents: [],
summerUniversities: [],
isLoading: false
isLoading: false,
isLoadingAgora: false
}
},
computed: {
Expand Down Expand Up @@ -213,7 +214,7 @@ export default {
this.hideSafeLocals = !this.hideSafeLocals
},
fetchAgorae () {
this.isLoading = true
this.isLoadingAgora = true
this.axios.get(this.services['statutory'], { params: { type: 'agora' } }).then((response) => {
this.agorae = response.data.data
if (this.agorae.length === 0) {
Expand All @@ -222,9 +223,9 @@ export default {
// Automatically set the most recent Agora as the selected one
this.selectedAgora = this.agorae[0]
this.fetchData()
this.isLoading = false
this.isLoadingAgora = false
}).catch((err) => {
this.isLoading = false
this.isLoadingAgora = false
this.$root.showError('Could not fetch statutory data', err)
})
},
Expand All @@ -234,7 +235,10 @@ export default {
this.axios.get(this.services['core'] + '/bodies').then(async (bodiesResponse) => {
this.bodies = bodiesResponse.data.data
this.bodies = this.bodies.filter(x => ['antenna', 'contact antenna', 'contact'].includes(x.type))
this.bodies.forEach(body => { body.antennaCriteria = {} })
this.bodies.forEach(body => {
body.antennaCriteria = {}
body.comments = {}
})

const promises = []
promises.push(this.checkBoardCriterium())
Expand Down Expand Up @@ -282,23 +286,20 @@ export default {
await this.axios.get(this.services['events'] + '/recents', { params: { ends: this.selectedAgora.ends } }).then((response) => {
this.events = response.data.data
}).catch((err) => {
this.isLoading = false
this.$root.showError('Could not fetch event data', err)
})
},
async fetchStatutoryEvents () {
await this.axios.get(this.services['statutory'] + '/recents', { params: { ends: this.selectedAgora.ends } }).then((response) => {
this.statutoryEvents = response.data.data
}).catch((err) => {
this.isLoading = false
this.$root.showError('Could not fetch statutory event data', err)
})
},
async fetchSummerUniversities () {
await this.axios.get(this.services['summeruniversity'] + '/recents', { params: { ends: this.selectedAgora.ends } }).then((response) => {
this.summerUniversities = response.data.data
}).catch((err) => {
this.isLoading = false
this.$root.showError('Could not fetch Summer University data', err)
})
},
Expand Down Expand Up @@ -333,7 +334,7 @@ export default {

for (const body in this.bodies) {
// Check if the last event is in the past 2 years
this.bodies[body].antennaCriteria.events = this.bodies[body].latest_event !== undefined && moment(this.bodies[body].latest_event).diff(moment(this.selectedAgora.ends), 'years', true) <= 2
this.bodies[body].antennaCriteria.events = String(this.bodies[body].latest_event !== undefined && moment(this.bodies[body].latest_event).diff(moment(this.selectedAgora.ends), 'years', true) <= 2)
if (this.bodies[body].latest_event !== undefined) this.bodies[body].latest_event = moment(this.bodies[body].latest_event).format('M[/]YYYY')
}
},
Expand All @@ -346,21 +347,20 @@ export default {

for (const body in this.bodies) {
// Check if the current board was elected within the past year
this.bodies[body].antennaCriteria.boardElection = this.bodies[body].latest_election !== undefined && moment(this.bodies[body].latest_election).diff(moment(this.selectedAgora.ends), 'years', true) <= 1
this.bodies[body].antennaCriteria.boardElection = String(this.bodies[body].latest_election !== undefined && moment(this.bodies[body].latest_election).diff(moment(this.selectedAgora.ends), 'years', true) <= 1)
if (this.bodies[body].latest_election !== undefined) this.bodies[body].latest_election = moment(this.bodies[body].latest_election).format('D[/]M[/]YYYY')
}
}).catch((err) => {
this.isLoading = false
this.$root.showError('Could not fetch boards data', err)
})
},
async checkMembersList () {
await this.axios.get(this.services['statutory'] + '/events/' + this.selectedAgora.id + '/memberslists/missing').then((membersListResponse) => {
for (const body in this.bodies) {
this.bodies[body].antennaCriteria.membersList = this.bodies[body].id in membersListResponse.data.data.map(x => x.id)
await this.axios.get(this.services['statutory'] + '/events/' + this.selectedAgora.id + '/memberslists').then((membersListsResponse) => {
for (const membersList of membersListsResponse.data.data) {
const body = this.bodies.find(x => x.id === membersList.body_id)
body.antennaCriteria.membersList = 'true'
}
}).catch((err) => {
this.isLoading = false
this.$root.showError('Could not fetch members list data', err)
})
},
Expand All @@ -376,7 +376,6 @@ export default {
body.comments[criterionName] = criterion.comment
}
}).catch((err) => {
this.isLoading = false
this.$root.showError('Could not fetch manual Antenna Criteria fulfilment', err)
})
}
Expand Down
13 changes: 11 additions & 2 deletions src/views/network/AntennaCriteriaInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</header>

<section class="modal-card-body">
<template v-if="!local.comments">
<template v-if="noComments">
<i>No comments to display for this body!</i>
</template>

Expand All @@ -27,7 +27,16 @@
<script>
export default {
name: 'AntennaCriteriaInfo',
props: ['local', 'agora', 'services', 'showError', 'showSuccess', 'router']
props: ['local', 'agora', 'services', 'showError', 'showSuccess', 'router'],
computed: {
noComments () {
if (!this.local.comments) return true
for (const comment in this.local.comments) {
if (this.local.comments[comment] !== '' && this.local.comments[comment] != null) return false
}
return true
}
}
}

</script>
2 changes: 1 addition & 1 deletion src/views/network/AntennaCriteriaModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ export default {
// Set the current fulfilment and comments
for (const criterion in this.local.antennaCriteria) {
this.antennaCriteria[criterion] = this.local.antennaCriteria[criterion]
this.comments[criterion] = this.local.comments[criterion]
this.comments[criterion] = this.local.comments[criterion] ?? ''
}

this.isLoading = false
Expand Down