Diferencia entre revisiones de «Módulo:Wikidata»

m Permitir ocultar vía CSS personal sólo el lápiz (sin quitar el enlace a Wikidata del pie de la tabla)
Añadida opcion de filtro negativo a filtroValor y filtroCalificador
Línea 273: Línea 273:
if (opciones.filtroCalificador ~= nil and opciones.filtroCalificador ~= '') then
if (opciones.filtroCalificador ~= nil and opciones.filtroCalificador ~= '') then
local opts = split(opciones.filtroCalificador, ';')
local opts = split(opciones.filtroCalificador, ';')
local negative = false
tablaOrdenada = p.filtroCalificadores(tablaOrdenada, opts[1], split(opts[2], ','))
if (#opts > 2) then
if (opts[3]=='n') then
negative = true
elseif (opts[3]=='p') then
negative = false
end
end
tablaOrdenada = p.filtroCalificadores(tablaOrdenada, opts[1], split(opts[2], ','), negative)
end
end
if (opciones.filtroValor ~= nil and opciones.filtroValor ~= '') then
if (opciones.filtroValor ~= nil and opciones.filtroValor ~= '') then
tablaOrdenada = p.filtroValores(tablaOrdenada, split(opciones.filtroValor, ','))
local opts = split(opciones.filtroValor, ';')
local negative = false
if (#opts > 1) then
if (opts[2]=='n') then
negative = true
elseif (opts[2]=='p') then
negative = false
end
end
tablaOrdenada = p.filtroValores(tablaOrdenada, split(opts[1], ','), negative)
end
end
Línea 576: Línea 594:
========================================================================= `-- ]]
========================================================================= `-- ]]
 
 
function p.filtroCalificadores(t, qualifier, values)
function p.filtroCalificadores(t, qualifier, values, negativo)
local f = {}  -- Tabla que se devolverá con el resultado del filtrado
local f = {}  -- Tabla que se devolverá con el resultado del filtrado
for k,v in pairs(t) do
for k,v in pairs(t) do
Línea 590: Línea 608:
end
end
end
end
if counts then -- Si uno de los valores del cualificador dio true se inserta el elemento
if counts and not negativo then -- Si uno de los valores del cualificador dio true se inserta el elemento
table.insert(f, v)
elseif not counts and negativo then -- Si ninguno de los valores del cualificador dio true se inserta el elemento
table.insert(f, v)
table.insert(f, v)
end
end
Línea 602: Línea 622:
========================================================================= `-- ]]
========================================================================= `-- ]]
 
 
function p.filtroValores(t, values)
function p.filtroValores(t, values, negativo)
local f = {}  -- Tabla que se devolverá con el resultado del filtrado
local f = {}  -- Tabla que se devolverá con el resultado del filtrado
for k,v in pairs(t) do
for k,v in pairs(t) do
Línea 613: Línea 633:
end
end
end
end
if counts then -- Si uno de los valores dio true se inserta el elemento
if counts and not negativo then -- Si uno de los valores del cualificador dio true se inserta el elemento
table.insert(f, v)
elseif not counts and negativo then -- Si ninguno de los valores del cualificador dio true se inserta el elemento
table.insert(f, v)
table.insert(f, v)
end
end