From 03bd94636dcf102f88216204cd62d31550fe99e5 Mon Sep 17 00:00:00 2001 From: Hubert Van De Walle Date: Thu, 24 Sep 2020 12:36:01 +0200 Subject: [PATCH] Fix display of routes info --- src/components/Routes.vue | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/components/Routes.vue b/src/components/Routes.vue index 13f018f..ab904cf 100644 --- a/src/components/Routes.vue +++ b/src/components/Routes.vue @@ -15,27 +15,24 @@ export default { }, methods: { info(route) { - return this.height(route) + this.orientations(route) + this.rating(route) + return [this.height(route), this.orientations(route), this.rating(route)] + .filter(e => !!e) + .join(', ') }, height(route) { - return route.height.heightDiffDifficulties ? route.height.heightDiffDifficulties + ' m, ' : ''; + return route.height.heightDiffDifficulties ? route.height.heightDiffDifficulties + ' m' : ''; }, orientations(route) { - if (route.orientations) { - return route.orientations.join(',') - } + return route.orientations ? route.orientations.join(',') : ''; }, rating(route) { - if (route.rating) { - let str = route.rating.global + ' ' + route.rating.free - if (route.rating.required) - str += '>' + route.rating.required - if (route.rating.engagement) - str += ' ' + route.rating.engagement - if (route.rating.equipmentQuality) - str += ' ' + route.rating.equipmentQuality - return str + let items = [] + + for (let value of Object.values(route.rating)) { + if (value) items.push(value) } + + return items.join(' ') } } }