diff --git a/components/gymRoutes/GymRouteTable.vue b/components/gymRoutes/GymRouteTable.vue index fa689c96..408aff80 100644 --- a/components/gymRoutes/GymRouteTable.vue +++ b/components/gymRoutes/GymRouteTable.vue @@ -764,8 +764,8 @@ export default { formatRoutes () { for (const route of this.routes) { const styles = [] - for (const section of route.sections) { - for (const style of section.styles) { + for (const section of route.sections ?? []) { + for (const style of section.styles ?? []) { styles.push(style) } } diff --git a/components/gymRoutes/forms/GymRouteForm.vue b/components/gymRoutes/forms/GymRouteForm.vue index 25a029ac..aff6ab8d 100644 --- a/components/gymRoutes/forms/GymRouteForm.vue +++ b/components/gymRoutes/forms/GymRouteForm.vue @@ -572,7 +572,7 @@ export default { gym_space_id: this.gymSector.gym_space.id, gym_sector_id: null, gym_id: this.gymSector.gym.id, - sections: this.gymRoute?.sections || [{ grade: null, height: null, styles: [] }] + sections: this.gymRoute?.sections ?? [{ grade: null, height: null, styles: [] }] }, climbingGymList: [ { text: this.$t('models.climbs.sport_climbing'), value: 'sport_climbing' }, @@ -608,6 +608,14 @@ export default { } }, + watch: { + multiPitch (newVal) { + if (!newVal && this.data.sections.length > 1) { + this.data.sections.splice(1) + } + } + }, + mounted () { this.getGymLevels() this.multiPitch = this.data.sections.length > 1 diff --git a/components/gymRoutes/partial/GymRouteClimbingSimpleStyleIcons.vue b/components/gymRoutes/partial/GymRouteClimbingSimpleStyleIcons.vue index a4bf2c5c..2f4d049a 100644 --- a/components/gymRoutes/partial/GymRouteClimbingSimpleStyleIcons.vue +++ b/components/gymRoutes/partial/GymRouteClimbingSimpleStyleIcons.vue @@ -28,8 +28,8 @@ export default { methods: { icons () { const styles = [] - for (const section of this.gymRoute.sections) { - for (const style of section.styles) { + for (const section of this.gymRoute.sections ?? []) { + for (const style of section.styles ?? []) { styles.push(style) } } diff --git a/components/gymRoutes/partial/GymRouteClimbingStyleIcons.vue b/components/gymRoutes/partial/GymRouteClimbingStyleIcons.vue index a56e784f..d3635783 100644 --- a/components/gymRoutes/partial/GymRouteClimbingStyleIcons.vue +++ b/components/gymRoutes/partial/GymRouteClimbingStyleIcons.vue @@ -2,7 +2,7 @@