Fix appels récursifs

This commit is contained in:
The17thDoctor 2023-03-30 16:00:54 +02:00
parent fd7e31f66b
commit e24163efa1

View File

@ -21,7 +21,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr if={!state.loading} each={etablissement in state.items}> <tr each={etablissement in state.items}>
<td>{etablissement.fields.g_ea_lib_vx}</td> <td>{etablissement.fields.g_ea_lib_vx}</td>
<td>{etablissement.fields.ville_etab}</td> <td>{etablissement.fields.ville_etab}</td>
<td>{etablissement.fields.dep}</td> <td>{etablissement.fields.dep}</td>
@ -43,12 +43,13 @@
return { return {
onBeforeMount(props, state) { onBeforeMount(props, state) {
state = { state = {
items: null items: null,
breakCycle: false
} }
}, },
onUpdated(props, state) { onUpdated(props, state) {
if (!props.shouldShowInfos) return if (!props.shouldShowInfos || state.breakCycle) return
fetchEtablissement(props.course).then((response) => { fetchEtablissement(props.course).then((response) => {
response.forEach(etablissement => { response.forEach(etablissement => {
// calcul la moyenne // calcul la moyenne
@ -63,9 +64,11 @@
etablissement.fields.moyenne = ((pct_TBF*19)+(pct_TB*17)+(pct_B*15)+(pct_AB*13)+(pct_sansmention*11))/100 etablissement.fields.moyenne = ((pct_TBF*19)+(pct_TB*17)+(pct_B*15)+(pct_AB*13)+(pct_sansmention*11))/100
}) })
state.breakCycle = true
this.update({ this.update({
items: response items: response
}) })
state.breakCycle = false
}) })
} }
} }