diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 99dc6f7d..870c139e 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -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 diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index afe28a7f..a555343b 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -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, _| diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index f1afbe65..c2e5c8c2 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -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 - × + - @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 + ×