From a61207aa30894c10d4d462041f01c1f8bc40b667 Mon Sep 17 00:00:00 2001 From: Luc Claustres Date: Fri, 30 Aug 2024 16:40:59 +0200 Subject: [PATCH] chore: improved forecast fields function with input variables for labels --- map/client/composables/weather.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/map/client/composables/weather.js b/map/client/composables/weather.js index 7c228b2bb..88d03fd7b 100644 --- a/map/client/composables/weather.js +++ b/map/client/composables/weather.js @@ -25,8 +25,8 @@ export function useWeather (options = {}) { // data // functions - function getProbedLocationForecastFields () { - return { + function getProbedLocationForecastFields (variables) { + const fields = { // Only wind/temperature can be available at different levels now windDirection: { property: (activity.forecastLevel ? `properties.windDirection-${activity.forecastLevel}` : 'properties.windDirection') @@ -54,6 +54,15 @@ export function useWeather (options = {}) { property: 'properties.name' } } + // Any given variables to extract labels from ? + if (variables && variables.length > 0) { + _.forOwn(fields, (value, key) => { + // Take care that weather fields are prefixed by 'properties.' because they target feature + const variable = _.find(variables, { name: `${value.property.replace('properties.', '')}` }) + if (variable) value.label = variable.label + }) + } + return fields } function isWeatherProbe (feature) { const { windDirection, windSpeed } = getProbedLocationForecastFields()