5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 01:06: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]
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?
end.transform_keys(&:to_sym)
end

View file

@ -7,17 +7,17 @@
= render 'sites/build', site: @site, class: 'btn-block'
= 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'
.custom-control.custom-checkbox
- @site.schema_organization.each do |schema, _|
.row.no-gutters
- schema = @site.layouts[schema]
%input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layouts", class: "" }
%label.custom-control-label.font-weight-normal{ for: schema }= schema.humanized_name
%button.btn.btn-secondary.mt-3{ type: 'submit' }= t('.filters.submit')
= 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
- @site.schema_organization.each do |schema, _|
.custom-control.custom-checkbox
- schema = @site.layouts[schema]
%input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layout[]", class: "", value: schema.name }
%label.custom-control-label.font-weight-normal{ for: schema }= schema.humanized_name
%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
%tbody
- @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
%i.fa.fa-fw.fa-search
%input.sr-only{ type: 'submit' }
- @filter_params.each do |param, value|
- if param == 'layout'
- value = @site.layouts[value.to_sym].humanized_name
= link_to site_posts_path(@site, **@filter_params.reject { |k, _| k == param }),
class: 'btn btn-secondary btn-sm',
title: t('posts.remove_filter_help', filter: value),
aria: { labelledby: "help-filter-#{param}" } do
= value
&times;
- @filter_params.each do |param, values|
- [values].flatten.each do |value|
- if param == :layout
- value = @site.layouts[value.to_sym].humanized_name
= link_to site_posts_path(@site, **@filter_params),
class: 'btn btn-secondary btn-sm',
title: t('posts.remove_filter_help', filter: value),
aria: { labelledby: "help-filter-#{param}" } do
= value
&times;