Fix: corregir renderizado de parámetros en MetabaseCardDisplay
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 48s
All checks were successful
build-and-deploy / build-and-deploy (push) Successful in 48s
- 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
This commit is contained in:
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user