5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 21:56:21 +00:00

fix: principio de funcionalidad filtros #13586 #15112

This commit is contained in:
maki 2024-04-29 13:34:16 -03:00
parent f2f6656b4c
commit ff83c97070
3 changed files with 20 additions and 19 deletions

View file

@ -157,7 +157,7 @@ class PostsController < ApplicationController
# #
# @return [Hash] # @return [Hash]
def filter_params def filter_params
@filter_params ||= params.permit(:q, :category, :layout, :page).to_hash.select do |_, v| @filter_params ||= params.permit(:q, :category, :page, layout: []).to_hash.select do |_, v|
v.present? v.present?
end.transform_keys(&:to_sym) end.transform_keys(&:to_sym)
end end

View file

@ -7,17 +7,17 @@
= render 'sites/build', site: @site, class: 'btn-block' = render 'sites/build', site: @site, class: 'btn-block'
= render 'layouts/details', summary: t('posts.filters.title') do = render 'layouts/details', summary: t('posts.filters.title') do
.border.border-magenta.p-1 %form.border.border-magenta.p-1{method: :get}
%legend.font-weight-bold.m-0.h6= 'Tipo de contenido' %legend.font-weight-bold.m-0.h6= 'Tipo de contenido'
.custom-control.custom-checkbox
- @site.schema_organization.each do |schema, _|
.row.no-gutters - @site.schema_organization.each do |schema, _|
- schema = @site.layouts[schema] .custom-control.custom-checkbox
%input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layouts", class: "" } - schema = @site.layouts[schema]
%label.custom-control-label.font-weight-normal{ for: schema }= schema.humanized_name %input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layout[]", class: "", value: schema.name }
%button.btn.btn-secondary.mt-3{ type: 'submit' }= t('.filters.submit') %label.custom-control-label.font-weight-normal{ for: schema }= schema.humanized_name
= render 'layouts/details', summary: t('posts.new'), summary_class: "h3 magenta font-weight-bold m-0 p-2", details_class: "d-flex border border-magenta justify-content-between align-items-center w-100 mb-3", open: "+", closed: "+", open_class: "h1 magenta font-weight-bold m-0", closed_class: "h1 magenta font-weight-bold m-0" do %button.btn.btn-secondary.mt-3{ type: 'submit' }= t('.filters.submit')
= render 'layouts/details', summary: t('posts.new'), summary_class: "h4 magenta font-weight-bold m-0 px-2", details_class: "d-flex border border-magenta justify-content-between align-items-center w-100 mb-3", open: "+", closed: "+", open_class: "h1 magenta font-weight-bold m-0", closed_class: "h1 magenta font-weight-bold m-0" do
%table.table-sm.w-100 %table.table-sm.w-100
%tbody %tbody
- @site.schema_organization.each do |schema, _| - @site.schema_organization.each do |schema, _|

View file

@ -13,12 +13,13 @@
%span.input-group-text.background-white.magenta.border.border-magenta.border-top.border-left-0.border-right.border-bottom %span.input-group-text.background-white.magenta.border.border-magenta.border-top.border-left-0.border-right.border-bottom
%i.fa.fa-fw.fa-search %i.fa.fa-fw.fa-search
%input.sr-only{ type: 'submit' } %input.sr-only{ type: 'submit' }
- @filter_params.each do |param, value| - @filter_params.each do |param, values|
- if param == 'layout' - [values].flatten.each do |value|
- value = @site.layouts[value.to_sym].humanized_name - if param == :layout
= link_to site_posts_path(@site, **@filter_params.reject { |k, _| k == param }), - value = @site.layouts[value.to_sym].humanized_name
class: 'btn btn-secondary btn-sm', = link_to site_posts_path(@site, **@filter_params),
title: t('posts.remove_filter_help', filter: value), class: 'btn btn-secondary btn-sm',
aria: { labelledby: "help-filter-#{param}" } do title: t('posts.remove_filter_help', filter: value),
= value aria: { labelledby: "help-filter-#{param}" } do
&times; = value
&times;