Skip to content
Snippets Groups Projects
Commit d9a33dd8 authored by Pierre-Jean CHANCELLIER's avatar Pierre-Jean CHANCELLIER
Browse files

correct queries for future_sorties

parent 48689a10
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,9 @@ ...@@ -50,6 +50,9 @@
" "
:memberStatus="member.status" /> :memberStatus="member.status" />
</div> </div>
<div v-if="['adhesion', 'certif'].includes(type)" class="d-sm-none">
<BadgeDate :date="date(member)" styleDate="long" />
</div>
<BadgeStatus :membre="member" /> <BadgeStatus :membre="member" />
<BadgeDispo <BadgeDispo
:isDispo="member.minDatePassed" :isDispo="member.minDatePassed"
...@@ -103,7 +106,6 @@ export default { ...@@ -103,7 +106,6 @@ export default {
type: Array, type: Array,
required: true required: true
}, },
displayHead: { displayHead: {
type: Boolean, type: Boolean,
default: true default: true
...@@ -116,13 +118,12 @@ export default { ...@@ -116,13 +118,12 @@ export default {
type: Boolean, type: Boolean,
default: true default: true
}, },
adhesion: { type: {
type: Boolean, type: String,
default: false default: "default",
}, validator: function (value) {
certif: { return ["adhesion", "certif", "default"].indexOf(value) !== -1
type: Boolean, }
default: false
}, },
defaultSortDir: { defaultSortDir: {
type: String, type: String,
...@@ -144,8 +145,8 @@ export default { ...@@ -144,8 +145,8 @@ export default {
this.currentSort = s this.currentSort = s
}, },
date(member) { date(member) {
if (this.adhesion) return member.limitDate if (this.type == "adhesion") return member.limitDate
if (this.certif) return member.received_certifications.limit if (this.type == "certif") return member.received_certifications.limit
return Math.min(member.limitDate, member.received_certifications.limit) return Math.min(member.limitDate, member.received_certifications.limit)
}, },
getOrder(a, b, order) { getOrder(a, b, order) {
...@@ -173,9 +174,9 @@ export default { ...@@ -173,9 +174,9 @@ export default {
modifier modifier
) )
} else if (this.currentSort == "date_sortie") { } else if (this.currentSort == "date_sortie") {
if (this.adhesion) { if (this.type == "adhesion") {
return this.getOrder(a["limitDate"], b["limitDate"], modifier) return this.getOrder(a["limitDate"], b["limitDate"], modifier)
} else if (this.certif) { } else if (this.type == "certif") {
return this.getOrder( return this.getOrder(
a["received_certifications"]["limit"], a["received_certifications"]["limit"],
b["received_certifications"]["limit"], b["received_certifications"]["limit"],
...@@ -202,7 +203,7 @@ export default { ...@@ -202,7 +203,7 @@ export default {
}) })
}, },
getTitleDate() { getTitleDate() {
if (this.adhesion || this.certif) { if (["adhesion", "certif"].includes(this.type)) {
return this.$t("date") return this.$t("date")
} else { } else {
return this.$t("membre.datelimpertestatut") return this.$t("membre.datelimpertestatut")
......
...@@ -235,7 +235,7 @@ export const FAVORIS = gql` ...@@ -235,7 +235,7 @@ export const FAVORIS = gql`
} }
` `
// Pour la page index // Pour la page previsions/futures_sorties
export const NEXT_EXITS = gql` export const NEXT_EXITS = gql`
query NextExits($group: [String!], $start: Int64, $period: Int64) { query NextExits($group: [String!], $start: Int64, $period: Int64) {
memEnds(group: $group, startFromNow: $start, period: $period) { memEnds(group: $group, startFromNow: $start, period: $period) {
...@@ -251,6 +251,46 @@ export const NEXT_EXITS = gql` ...@@ -251,6 +251,46 @@ export const NEXT_EXITS = gql`
__typename __typename
limit limit
} }
sent_certifications {
__typename
pending
}
}
}
`
// Pour la page previsions/futures_sorties
export const NEXT_LOOSE_CERTS = gql`
query NextLoseCerts(
$group: [String!]
$start: Int64
$period: Int64
$missingIncluded: Boolean
) {
certEnds(
group: $group
startFromNow: $start
period: $period
missingIncluded: $missingIncluded
) {
id {
__typename
pubkey
uid
status
hash
minDatePassed
minDate
limitDate
received_certifications {
__typename
limit
}
sent_certifications {
__typename
pending
}
}
date
} }
} }
` `
...@@ -6,60 +6,34 @@ ...@@ -6,60 +6,34 @@
<input type="checkbox" id="favoris" v-model="favoris" /> <input type="checkbox" id="favoris" v-model="favoris" />
<label for="favoris" class="form-label">{{ $t("favoris.use") }}</label> <label for="favoris" class="form-label">{{ $t("favoris.use") }}</label>
</div> </div>
<div class="col-10 mb-4" v-if="!favoris">
<div class="form-group row period">
<label for="period" class="col-sm-6 col-form-label">{{
$t("previsions.period.title") + "&nbsp;:"
}}</label>
<div class="col-sm-6 col-md-5 col-lg-4 col-xl-3">
<select
class="form-control"
id="period"
aria-describedby="periodHelp"
v-model="period"
@change="save">
<option
v-for="index in 30"
:key="index"
:value="index"
v-html="$tc('jours', index)"></option>
</select>
<small id="periodHelp" class="form-text text-muted">{{
$t("previsions.period.desc")
}}</small>
</div>
</div>
</div>
</div> </div>
<NavigationLoader :isLoading="$apollo.queries.wwResult.loading" /> <NavigationLoader :isLoading="$apollo.loading" />
<transition name="fade"> <transition name="fade">
<div <div class="alert alert-danger" v-if="error && !$apollo.loading">
class="alert alert-danger"
v-if="error && !$apollo.queries.wwResult.loading">
{{ error }} {{ error }}
</div> </div>
</transition> </transition>
<transition name="fade"> <transition name="fade">
<div v-if="wwResult && !$apollo.queries.wwResult.loading"> <div class="row" v-if="!$apollo.loading">
<div class="row"> <div class="col-lg-6" v-if="memEnds">
<div class="col-lg-6"> <h2 class="h4 text-danger text-center">
<h2 class="h4 text-danger text-center"> {{ $t("statut.renew") }}
{{ $t("statut.bientotmanquecertif") }} </h2>
</h2> <MemberList
<MemberList defaultSort="date_sortie"
defaultSort="date_sortie" :members="memEnds"
:members="wwResult['outOfCerts']" :displayPubkey="false"
:displayPubkey="false" type="adhesion" />
:certif="true" /> </div>
</div> <div class="col-lg-6" v-if="certEnds">
<div class="col-lg-6"> <h2 class="h4 text-danger text-center">
<h2 class="h4 text-danger text-center">{{ $t("statut.renew") }}</h2> {{ $t("statut.bientotmanquecertif") }}
<MemberList </h2>
defaultSort="date_sortie" <MemberList
:members="wwResult['membership']" defaultSort="date_sortie"
:displayPubkey="false" :members="certEnds"
:adhesion="true" /> :displayPubkey="false"
</div> type="certif" />
</div> </div>
</div> </div>
</transition> </transition>
...@@ -68,6 +42,7 @@ ...@@ -68,6 +42,7 @@
<script> <script>
import { NEXT_EXITS } from "@/graphql/queries.js" import { NEXT_EXITS } from "@/graphql/queries.js"
import { NEXT_LOOSE_CERTS } from "@/graphql/queries.js"
export default { export default {
data() { data() {
...@@ -87,55 +62,36 @@ export default { ...@@ -87,55 +62,36 @@ export default {
} }
], ],
error: null, error: null,
period: 30,
favoris: false favoris: false
} }
}, },
methods: { computed: {
save() {
localStorage.setItem("previsions_period", this.period)
},
getParams() { getParams() {
if (this.favoris && localStorage.favourites) { if (this.favoris) {
return { group: this.$favourites.list } return localStorage.favourites
? { group: "wotwizard-nobody", period: 2635200 }
: { group: this.$favourites.list, period: 2635200 }
} }
return { period: this.period * 24 * 60 * 60 } return { period: 2635200 }
} }
}, },
apollo: { apollo: {
wwResult: { memEnds: {
query: NEXT_EXITS, query: NEXT_EXITS,
variables() { variables() {
return this.getParams() return this.getParams
},
error(err) {
this.error = err.message
}
},
certEnds: {
query: NEXT_LOOSE_CERTS,
variables() {
return this.getParams
}, },
update(data) { update(data) {
let result = { membership: [], outOfCerts: [] } return data.certEnds.map((item) => item.id)
data.memEnds.forEach((member) => {
if (this.favoris) {
result.membership.push(member)
result.outOfCerts.push(member)
} else {
if (
["danger", "warning"].includes(
this.$options.filters.dateStatus(member.limitDate)
)
) {
result.membership.push(member)
}
if (
["danger", "warning"].includes(
this.$options.filters.dateStatus(
member.received_certifications.limit
)
)
) {
result.outOfCerts.push(member)
}
}
})
return result
}, },
error(err) { error(err) {
this.error = err.message this.error = err.message
...@@ -151,25 +107,6 @@ export default { ...@@ -151,25 +107,6 @@ export default {
}, },
mounted() { mounted() {
$nuxt.$emit("changeRoute", this.breadcrumb) $nuxt.$emit("changeRoute", this.breadcrumb)
if (localStorage.previsions_sorties) {
this.period = localStorage.getItem("previsions_period")
}
} }
} }
</script> </script>
<style lang="scss">
.period {
text-align: center;
select {
text-align: inherit;
}
@media (min-width: 576px) {
label {
text-align: right;
}
}
}
</style>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment