From 9960ebd646ffc7c9d05c95bf1fb163d89fb737ac Mon Sep 17 00:00:00 2001 From: maki Date: Tue, 20 Feb 2024 14:09:46 -0300 Subject: [PATCH 01/15] mover el buscador #13586 --- app/views/posts/index.haml | 8 -------- app/views/sites/_header.haml | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 69fb2d8f..bb97d8d5 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -39,14 +39,6 @@ %section.col .d-flex.justify-content-between.align-items-center.pl-2-plus.pr-2-plus.mb-2 - %form{ action: site_posts_path } - - @filter_params.each do |param, value| - - next if param == 'q' - %input{ type: 'hidden', name: param, value: value } - .form-group.flex-grow-0.m-0 - %label.sr-only{for: 'q'}= t('.search') - %input#q.form-control.border.border-magenta{ type: 'search', placeholder: t('.search'), name: 'q', value: @filter_params[:q] } - %input.sr-only{ type: 'submit' } - if @site.locales.size > 1 %nav#locales diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index c8931041..c6be7c88 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -1,3 +1,11 @@ .hyphens{ lang: site.default_locale } %h1= site.title %p.lead= site.description + %form{ action: site_posts_path } + - @filter_params.each do |param, value| + - next if param == 'q' + %input{ type: 'hidden', name: param, value: value } + .form-group.flex-grow-0.m-0 + %label.sr-only{for: 'q'}= t('posts.index.search') + %input#q.form-control.border.border-magenta{ type: 'search', placeholder: t('posts.index.search'), name: 'q', value: @filter_params[:q] } + %input.sr-only{ type: 'submit' } From fa2ece19aa013071cc18cb1994652cccf97e2256 Mon Sep 17 00:00:00 2001 From: maki Date: Thu, 29 Feb 2024 15:17:47 -0300 Subject: [PATCH 02/15] feat: buscador con estilos de la refe --- app/views/sites/_header.haml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index c6be7c88..57bea259 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -1,11 +1,15 @@ .hyphens{ lang: site.default_locale } %h1= site.title %p.lead= site.description - %form{ action: site_posts_path } + %form.mb-3{ action: site_posts_path } - @filter_params.each do |param, value| - next if param == 'q' %input{ type: 'hidden', name: param, value: value } .form-group.flex-grow-0.m-0 - %label.sr-only{for: 'q'}= t('posts.index.search') - %input#q.form-control.border.border-magenta{ type: 'search', placeholder: t('posts.index.search'), name: 'q', value: @filter_params[:q] } + %label{for: 'q'}= t('posts.index.search') + .input-group + %input#q.form-control.border.border-magenta.border-right-0{ type: 'search', name: 'q', value: @filter_params[:q] } + .input-group-append + %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' } From 0dc6e5e6652ff1637e907230aad8dc9458a09cb5 Mon Sep 17 00:00:00 2001 From: maki Date: Fri, 1 Mar 2024 16:07:56 -0300 Subject: [PATCH 03/15] feat: contenido del details de filtros #13586 --- app/assets/stylesheets/application.scss | 7 ++++--- app/views/posts/index.haml | 23 +++++++++++++---------- app/views/sites/_header.haml | 9 +++++++++ config/locales/en.yml | 3 +++ config/locales/es.yml | 3 +++ 5 files changed, 32 insertions(+), 13 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 240e61a5..e1e56b8a 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -570,9 +570,10 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); content: '▶'; font-size: 1.8rem; position: absolute; - left: 97%; - bottom: 3%; + right: 0%; + top: 0%; transform: rotate(180deg); + } &[open] { & > summary { @@ -586,4 +587,4 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); hr { border-bottom: 1px solid #dee2e6; -} \ No newline at end of file +} diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index bb97d8d5..9eaf2f1f 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -6,6 +6,18 @@ = render 'sites/build', site: @site, class: 'btn-block' + = render 'layouts/details', summary: t('posts.filters.title') do + .border.border-magenta.p-1 + %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') + %h3= t('posts.new') %table.table.table-sm.mb-3 %tbody @@ -45,16 +57,7 @@ - @site.locales.each do |locale| = link_to @site.data.dig(locale.to_s, 'locale') || locale, site_posts_path(@site, **@filter_params.merge(locale: locale)), class: "mr-2 mt-2 mb-2 #{locale == @locale ? 'active font-weight-bold' : ''}" - .pl-2-plus - - @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 - × + - if @posts.empty? %h2= t('posts.empty') - else diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index 57bea259..f1afbe65 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -13,3 +13,12 @@ %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 + × diff --git a/config/locales/en.yml b/config/locales/en.yml index 1b4f2d86..38cc3aa0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -640,6 +640,9 @@ en: next: Next page empty: "There are no results for those search parameters." caption: Post list + filters: + title: Filters + submit: Submit attribute_ro: file: download: Download file diff --git a/config/locales/es.yml b/config/locales/es.yml index e277f76b..5e8bba9d 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -651,6 +651,9 @@ es: next: Página siguiente empty: No hay artículos con estos parámetros de búsqueda. caption: Lista de artículos + filters: + title: Filtros + submit: Aplicar attribute_ro: file: download: Descargar archivo From fbe2d9b1a96a97e81a331cc4fb2615c02a2df772 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 4 Mar 2024 13:12:22 -0300 Subject: [PATCH 04/15] feat: agregar contenido sin desplegable #13586 --- app/assets/stylesheets/application.scss | 30 ++++++++++++++++++++----- app/views/layouts/_details.haml | 15 +++++++++++++ app/views/posts/index.haml | 19 +++++++++------- app/views/schemas/_row.haml | 9 +++----- 4 files changed, 53 insertions(+), 20 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index e1e56b8a..195cb662 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -561,11 +561,19 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); // details styles .details { - summary { + & > summary { list-style: none; - cursor: default; - position: relative; + cursor: pointer; + + .hide-when-open { + display: inline; + } + + .show-when-open { + display: none; + } } +<<<<<<< HEAD summary::after { content: '▶'; font-size: 1.8rem; @@ -575,16 +583,26 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); transform: rotate(180deg); } +======= + +>>>>>>> 61101723 (feat: poder cambiar el nivel de summary) &[open] { & > summary { - &::after { - transform: rotate(90deg); - } + .hide-when-open { + display: none; + } + + .show-when-open { + display: inline; + } } } +<<<<<<< HEAD } hr { border-bottom: 1px solid #dee2e6; +======= +>>>>>>> 61101723 (feat: poder cambiar el nivel de summary) } diff --git a/app/views/layouts/_details.haml b/app/views/layouts/_details.haml index 306986bf..94203400 100644 --- a/app/views/layouts/_details.haml +++ b/app/views/layouts/_details.haml @@ -1,6 +1,21 @@ -# Detail Cola de Moderación +<<<<<<< HEAD %details.details.py-2 %summary %h3.py-2= summary +======= + @param :id [String] El ID opcional sirve para mantener el historial de + cuál estaba abierto y recuperarlo al cargar la página + @param :summary [String] El resumen + @param :summary_class [String] Clases para el summary + +- local_assigns[:summary_class] ||= 'h3' + +%details.details.py-2{ id: local_assigns[:id], data: { controller: 'details', action: 'toggle->details#store' } } + %summary.d-flex.flex-row.align-items-center.justify-content-between{ class: local_assigns[:summary_class] } + %span= summary + %span.hide-when-open ▶ + %span.show-when-open ▼ +>>>>>>> 61101723 (feat: poder cambiar el nivel de summary) = yield diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 9eaf2f1f..ba0ede1f 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -17,14 +17,17 @@ %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') - - %h3= t('posts.new') - %table.table.table-sm.mb-3 - %tbody - - @site.schema_organization.each do |schema, _| - - schema = @site.layouts[schema] - - next if schema.hidden? - = render 'schemas/row', site: @site, schema: schema, filter: @filter_params + .caja + .d-flex.border.border-magenta.p-2.justify-content-between.align-items-center.w-100 + %h3.magenta.font-weight-bold.m-0= t('posts.new') + %p.h1.magenta.font-weight-bold.m-0= '+' + %table.table-sm.mb-3.w-100 + %tbody + - @site.schema_organization.each do |schema, _| + - schema = @site.layouts[schema] + - next if schema.hidden? + = render 'schemas/row', site: @site, schema: schema, filter: @filter_params + - if policy(@site_stat).index? = link_to t('stats.index.title'), site_stats_path(@site), class: 'btn btn-secondary' diff --git a/app/views/schemas/_row.haml b/app/views/schemas/_row.haml index 1d1fca87..9b727f97 100644 --- a/app/views/schemas/_row.haml +++ b/app/views/schemas/_row.haml @@ -1,12 +1,9 @@ -%tr - %th.w-100{ scope: 'row' } +%tr.border-left.border-right.border-bottom.border-magenta + %th.font-weight-normal.w-100{ scope: 'row' } - if local_assigns[:parent_schema] %span.text-muted — = schema.humanized_name - %td.px-0.text-nowrap - = render 'schemas/add', **local_assigns - = render 'schemas/filter', **local_assigns - + -# XXX: Solo un nivel de recursividad - unless local_assigns[:parent_schema] - schema.schemas.each do |s| From dbf658a4a12d8f876b4739d079a37cd6c0db96c7 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 4 Mar 2024 13:12:22 -0300 Subject: [PATCH 05/15] feat: poder cambiar el nivel de summary (cherry picked from commit 6110172324f6f267f5d10a1b33e2458f061ea67a) --- app/assets/stylesheets/application.scss | 7 ------- app/views/layouts/_details.haml | 6 ------ 2 files changed, 13 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 195cb662..a9bdb997 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -573,7 +573,6 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); display: none; } } -<<<<<<< HEAD summary::after { content: '▶'; font-size: 1.8rem; @@ -583,9 +582,6 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); transform: rotate(180deg); } -======= - ->>>>>>> 61101723 (feat: poder cambiar el nivel de summary) &[open] { & > summary { .hide-when-open { @@ -597,12 +593,9 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); } } } -<<<<<<< HEAD } hr { border-bottom: 1px solid #dee2e6; -======= ->>>>>>> 61101723 (feat: poder cambiar el nivel de summary) } diff --git a/app/views/layouts/_details.haml b/app/views/layouts/_details.haml index 94203400..a679541a 100644 --- a/app/views/layouts/_details.haml +++ b/app/views/layouts/_details.haml @@ -1,10 +1,5 @@ -# Detail Cola de Moderación -<<<<<<< HEAD -%details.details.py-2 - %summary - %h3.py-2= summary -======= @param :id [String] El ID opcional sirve para mantener el historial de cuál estaba abierto y recuperarlo al cargar la página @param :summary [String] El resumen @@ -17,5 +12,4 @@ %span= summary %span.hide-when-open ▶ %span.show-when-open ▼ ->>>>>>> 61101723 (feat: poder cambiar el nivel de summary) = yield From 875de47a400bccb16f51213435a9e43fa63c6c5e Mon Sep 17 00:00:00 2001 From: maki Date: Fri, 8 Mar 2024 13:16:21 -0300 Subject: [PATCH 06/15] fix: estilos de details --- app/assets/stylesheets/application.scss | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index a9bdb997..8846b368 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -599,3 +599,32 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); hr { border-bottom: 1px solid #dee2e6; } + +details { + summary { + .show-when-open { + display: none; + } + + .hide-when-open { + display: block; + } + } + + &[open] { + summary { + .show-when-open { + display: block; + } + + .hide-when-open { + display: none; + } + } + } + + & > summary { + list-style: none; + &::-webkit-details-marker { display: none; } + } +} From c08b2158d89c8b8881f823169acb8b16ecd43c38 Mon Sep 17 00:00:00 2001 From: maki Date: Fri, 8 Mar 2024 13:23:06 -0300 Subject: [PATCH 07/15] fix: flecha de details repetida --- app/assets/stylesheets/application.scss | 39 +------------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index 8846b368..f70869a5 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -573,15 +573,7 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); display: none; } } - summary::after { - content: '▶'; - font-size: 1.8rem; - position: absolute; - right: 0%; - top: 0%; - transform: rotate(180deg); - - } + &[open] { & > summary { .hide-when-open { @@ -599,32 +591,3 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1); hr { border-bottom: 1px solid #dee2e6; } - -details { - summary { - .show-when-open { - display: none; - } - - .hide-when-open { - display: block; - } - } - - &[open] { - summary { - .show-when-open { - display: block; - } - - .hide-when-open { - display: none; - } - } - } - - & > summary { - list-style: none; - &::-webkit-details-marker { display: none; } - } -} From 1f9d9b308b848fd8789648647e3ed668dd2d17c8 Mon Sep 17 00:00:00 2001 From: maki Date: Fri, 8 Mar 2024 13:58:10 -0300 Subject: [PATCH 08/15] feat: agregar contenido como details --- app/views/layouts/_details.haml | 9 ++++++--- app/views/posts/index.haml | 10 ++++------ app/views/schemas/_row.haml | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/views/layouts/_details.haml b/app/views/layouts/_details.haml index a679541a..ca906818 100644 --- a/app/views/layouts/_details.haml +++ b/app/views/layouts/_details.haml @@ -6,10 +6,13 @@ @param :summary_class [String] Clases para el summary - local_assigns[:summary_class] ||= 'h3' +- local_assigns[:closed] ||= '▶'.html_safe; +- local_assigns[:open] ||= '▼'.html_safe; -%details.details.py-2{ id: local_assigns[:id], data: { controller: 'details', action: 'toggle->details#store' } } + +%details.details.py-2{ id: local_assigns[:id], data: { controller: 'details', action: 'toggle->details#store' }, class: local_assigns[:details_class] } %summary.d-flex.flex-row.align-items-center.justify-content-between{ class: local_assigns[:summary_class] } %span= summary - %span.hide-when-open ▶ - %span.show-when-open ▼ + %span.hide-when-open{ class: local_assigns[:open_class] }= local_assigns[:closed] + %span.show-when-open{ class: local_assigns[:closed_class] }= local_assigns[:open] = yield diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index ba0ede1f..afe28a7f 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -17,17 +17,15 @@ %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') - .caja - .d-flex.border.border-magenta.p-2.justify-content-between.align-items-center.w-100 - %h3.magenta.font-weight-bold.m-0= t('posts.new') - %p.h1.magenta.font-weight-bold.m-0= '+' - %table.table-sm.mb-3.w-100 + = 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 + %table.table-sm.w-100 %tbody - @site.schema_organization.each do |schema, _| - schema = @site.layouts[schema] - next if schema.hidden? = render 'schemas/row', site: @site, schema: schema, filter: @filter_params - + + - if policy(@site_stat).index? = link_to t('stats.index.title'), site_stats_path(@site), class: 'btn btn-secondary' diff --git a/app/views/schemas/_row.haml b/app/views/schemas/_row.haml index 9b727f97..78558dc0 100644 --- a/app/views/schemas/_row.haml +++ b/app/views/schemas/_row.haml @@ -1,4 +1,4 @@ -%tr.border-left.border-right.border-bottom.border-magenta +%tr.border-top.border-magenta %th.font-weight-normal.w-100{ scope: 'row' } - if local_assigns[:parent_schema] %span.text-muted — From f2f6656b4cdfd8ae396ee98057bb24e11ec8d23b Mon Sep 17 00:00:00 2001 From: maki Date: Wed, 13 Mar 2024 17:52:47 -0300 Subject: [PATCH 09/15] feat: agregar contenido funcional --- app/views/schemas/_add.haml | 2 +- app/views/schemas/_row.haml | 5 +++-- config/locales/en.yml | 2 +- config/locales/es.yml | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/views/schemas/_add.haml b/app/views/schemas/_add.haml index 0131a6bb..6aaf51c9 100644 --- a/app/views/schemas/_add.haml +++ b/app/views/schemas/_add.haml @@ -1 +1 @@ -= link_to t('.add'), new_site_post_path(site, layout: schema.value), class: 'btn btn-secondary btn-sm m-0' += link_to t(schema.humanized_name), new_site_post_path(site, layout: schema.value), class: 'stretched-link black text-decoration-none' diff --git a/app/views/schemas/_row.haml b/app/views/schemas/_row.haml index 78558dc0..edea4f2f 100644 --- a/app/views/schemas/_row.haml +++ b/app/views/schemas/_row.haml @@ -1,8 +1,9 @@ %tr.border-top.border-magenta - %th.font-weight-normal.w-100{ scope: 'row' } + + %th.font-weight-normal.w-100.position-relative{ scope: 'row' } - if local_assigns[:parent_schema] %span.text-muted — - = schema.humanized_name + = render 'schemas/add', schema: schema, **local_assigns -# XXX: Solo un nivel de recursividad - unless local_assigns[:parent_schema] diff --git a/config/locales/en.yml b/config/locales/en.yml index 38cc3aa0..004b353c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -700,7 +700,7 @@ en: date: 'date' order: 'Order' content: 'Text' - new: 'Post types' + new: 'Add content' remove_filter_help: 'Remove the filter: %{filter}' categories: 'Everything' index: diff --git a/config/locales/es.yml b/config/locales/es.yml index 5e8bba9d..28f60953 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -712,7 +712,7 @@ es: order: 'Posición' content: 'Cuerpo del artículo' categories: 'Todos' - new: 'Tipos de artículos' + new: 'Agregar contenido' remove_filter_help: 'Quitar este filtro: %{filter}' index: search: 'Buscar' From ff83c970704c16213215bda4835ec0b61ca86275 Mon Sep 17 00:00:00 2001 From: maki Date: Mon, 29 Apr 2024 13:34:16 -0300 Subject: [PATCH 10/15] fix: principio de funcionalidad filtros #13586 #15112 --- app/controllers/posts_controller.rb | 2 +- app/views/posts/index.haml | 18 +++++++++--------- app/views/sites/_header.haml | 19 ++++++++++--------- 3 files changed, 20 insertions(+), 19 deletions(-) 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 + × From b8677472912fc924dff370ee3a07e657b7e4424a Mon Sep 17 00:00:00 2001 From: f Date: Mon, 29 Apr 2024 14:07:03 -0300 Subject: [PATCH 11/15] fix: obtener el nombre para humanites #15112 --- app/views/sites/_header.haml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index c2e5c8c2..4bd7a073 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -15,11 +15,12 @@ %input.sr-only{ type: 'submit' } - @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 + - if param == :layout + = @site.layouts[value.to_sym].humanized_name + - else + = value × From f67bd157a9ee4034bbd4fffd4d9824d1b6cfea7d Mon Sep 17 00:00:00 2001 From: f Date: Mon, 29 Apr 2024 14:07:34 -0300 Subject: [PATCH 12/15] feat: eliminar un valor de la lista de parametros --- app/helpers/application_helper.rb | 19 +++++++++++++++++++ app/views/sites/_header.haml | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9f7be213..7d05d1bf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -19,6 +19,25 @@ module ApplicationHelper [root, name] end + # Devuelve los params sin el valor para una llave, detectando si el + # valor es un array. + # + # @param filtering_params [Hash] + # @param key [Symbol,String] + # @param value [Any] + def filter_params_by(filtering_params, key, value) + filtering_params.map do |k, v| + if k == key + case v + when Array then [k, v - [value]] + else nil + end + else + [ k, v ] + end + end.compact.to_h + end + def plain_field_name_for(*names) root, name = field_name_for(*names) diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index 4bd7a073..c4936853 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -15,7 +15,7 @@ %input.sr-only{ type: 'submit' } - @filter_params.each do |param, values| - [values].flatten.each do |value| - = link_to site_posts_path(@site, **@filter_params), + = link_to site_posts_path(@site, **filter_params_by(@filter_params, param, value)), class: 'btn btn-secondary btn-sm', title: t('posts.remove_filter_help', filter: value), aria: { labelledby: "help-filter-#{param}" } do From da758ae457d62035fb5256c391b96e7cf3d2e871 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 29 Apr 2024 14:08:07 -0300 Subject: [PATCH 13/15] fix: poder pasar filtros entre formularios --- app/views/posts/index.haml | 4 ++++ app/views/sites/_header.haml | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index a555343b..129fc835 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -8,6 +8,10 @@ = render 'layouts/details', summary: t('posts.filters.title') do %form.border.border-magenta.p-1{method: :get} + - @filter_params.each do |param, values| + - next if param == :layout + - [values].flatten.each do |value| + %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } %legend.font-weight-bold.m-0.h6= 'Tipo de contenido' diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index c4936853..779ed543 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -2,9 +2,10 @@ %h1= site.title %p.lead= site.description %form.mb-3{ action: site_posts_path } - - @filter_params.each do |param, value| - - next if param == 'q' - %input{ type: 'hidden', name: param, value: value } + - @filter_params.each do |param, values| + - next if param == :q + - [values].flatten.each do |value| + %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } .form-group.flex-grow-0.m-0 %label{for: 'q'}= t('posts.index.search') .input-group From cac98af8da33d9969467bcb559ed2ac15ed4b474 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 29 Apr 2024 14:08:20 -0300 Subject: [PATCH 14/15] feat: tildar los filtros actuales --- app/views/posts/index.haml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 129fc835..28b5aad2 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -13,12 +13,10 @@ - [values].flatten.each do |value| %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } %legend.font-weight-bold.m-0.h6= 'Tipo de contenido' - - - - @site.schema_organization.each do |schema, _| + - @site.schema_organization.each do |key, _| .custom-control.custom-checkbox - - schema = @site.layouts[schema] - %input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layout[]", class: "", value: schema.name } + - schema = @site.layouts[key] + %input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layout[]", class: "", value: schema.name, checked: @filter_params[:layout].include?(key.to_s) } %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 From 1d1d0cde45112df8ebcde44dea90c7e1a1f4883d Mon Sep 17 00:00:00 2001 From: maki Date: Thu, 2 May 2024 10:33:50 -0300 Subject: [PATCH 15/15] =?UTF-8?q?fix:=20algunos=20ajustes=20est=C3=A9ticos?= =?UTF-8?q?=20#13586?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/posts/index.haml | 24 +++++++++++++----------- app/views/sites/_header.haml | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/app/views/posts/index.haml b/app/views/posts/index.haml index 28b5aad2..eaa757f9 100644 --- a/app/views/posts/index.haml +++ b/app/views/posts/index.haml @@ -7,17 +7,19 @@ = render 'sites/build', site: @site, class: 'btn-block' = render 'layouts/details', summary: t('posts.filters.title') do - %form.border.border-magenta.p-1{method: :get} - - @filter_params.each do |param, values| - - next if param == :layout - - [values].flatten.each do |value| - %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } - %legend.font-weight-bold.m-0.h6= 'Tipo de contenido' - - @site.schema_organization.each do |key, _| - .custom-control.custom-checkbox - - schema = @site.layouts[key] - %input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layout[]", class: "", value: schema.name, checked: @filter_params[:layout].include?(key.to_s) } - %label.custom-control-label.font-weight-normal{ for: schema }= schema.humanized_name + + %form{method: :get} + .border.border-magenta.p-1 + - @filter_params.each do |param, values| + - next if param == :layout + - [values].flatten.each do |value| + %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } + %legend.font-weight-bold.m-0.h6= 'Tipo de contenido' + - @site.schema_organization.each do |key, _| + .custom-control.custom-checkbox + - schema = @site.layouts[key] + %input.custom-control-input.magenta{ type: 'checkbox', id: schema, name: "layout[]", class: "", value: schema.name, checked: @filter_params[:layout]&.include?(key.to_s) } + %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 diff --git a/app/views/sites/_header.haml b/app/views/sites/_header.haml index 779ed543..d4302d34 100644 --- a/app/views/sites/_header.haml +++ b/app/views/sites/_header.haml @@ -7,7 +7,7 @@ - [values].flatten.each do |value| %input{ type: 'hidden', name: values.is_a?(Array) ? "#{param}[]" : param, value: value } .form-group.flex-grow-0.m-0 - %label{for: 'q'}= t('posts.index.search') + %label.h3{for: 'q'}= t('posts.index.search') .input-group %input#q.form-control.border.border-magenta.border-right-0{ type: 'search', name: 'q', value: @filter_params[:q] } .input-group-append