From ae19af5c9e297bf7dc2fa3999e131ea2a7f581a4 Mon Sep 17 00:00:00 2001 From: josedario87 Date: Wed, 29 Oct 2025 09:38:17 -0600 Subject: [PATCH] =?UTF-8?q?Fix:=20corregir=20renderizado=20de=20par=C3=A1m?= =?UTF-8?q?etros=20en=20MetabaseCardDisplay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Cambiar tipo de parámetros boolean de 'category' a 'boolean' para que funcione el UToggle - Detectar campos de fecha por nombre aunque sean tipo text en Metabase - Renderizar inputs de fecha con date picker para campos que contienen 'fecha' - Mejorar inicialización de parámetros text que representan fechas Resuelve el problema donde incluir_anulados no aparecía y fecha_desde/fecha_hasta se mostraban como text inputs en lugar de date pickers --- .../metabase/MetabaseCardDisplay.vue | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/nuxt4-app/app/components/metabase/MetabaseCardDisplay.vue b/nuxt4-app/app/components/metabase/MetabaseCardDisplay.vue index be5defa..96c5cec 100644 --- a/nuxt4-app/app/components/metabase/MetabaseCardDisplay.vue +++ b/nuxt4-app/app/components/metabase/MetabaseCardDisplay.vue @@ -242,7 +242,11 @@ function initializeParameters() { for (const [tagName, tagConfig] of Object.entries(templateTags.value)) { const config = tagConfig as any if (config.type === 'boolean') { + // Para boolean, el default viene como array [false] o [true] params[tagName] = config.default?.[0] ?? false + } else if (config.type === 'text' && (tagName.toLowerCase().includes('fecha') || config?.['display-name']?.toLowerCase().includes('fecha'))) { + // Para campos de fecha tipo text, inicializar con string vacío + params[tagName] = config.default ?? '' } else { params[tagName] = config.default ?? '' } @@ -275,7 +279,14 @@ const exportItems = [[ function getParameterType(key: string): string { const config = templateTags.value[key] as any - return config?.type || 'text' + const type = config?.type || 'text' + + // Si es tipo text pero el nombre incluye "fecha", tratar como date + if (type === 'text' && (key.toLowerCase().includes('fecha') || config?.['display-name']?.toLowerCase().includes('fecha'))) { + return 'date' + } + + return type } function getParameterLabel(key: string): string { @@ -321,8 +332,12 @@ async function executeQuery() { paramType = 'date/single' paramValue = parameterValues.value[tagName] || null } else if (config.type === 'boolean') { - paramType = 'category' - paramValue = [parameterValues.value[tagName]] + paramType = 'boolean' + paramValue = parameterValues.value[tagName] + } else if (config.type === 'text' && (tagName.toLowerCase().includes('fecha') || config?.['display-name']?.toLowerCase().includes('fecha'))) { + // Si es tipo text pero parece una fecha, enviar como text + paramType = 'text' + paramValue = parameterValues.value[tagName] || '' } parameters.push({