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

Merge branch 'issue-13586-2' of 0xacab.org:sutty/sutty into panel.testing.sutty.nl

This commit is contained in:
f 2024-05-02 14:14:49 -03:00
commit b17b3b141c
No known key found for this signature in database
10 changed files with 94 additions and 39 deletions

View file

@ -631,3 +631,8 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
}
}
}
hr {
border-bottom: 1px solid #dee2e6;
}

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

@ -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)

View file

@ -7,10 +7,13 @@
@param :summary_class [String] Clases para el summary
- local_assigns[:summary_class] ||= 'h3'
- local_assigns[:closed] ||= '&#x25B6'.html_safe;
- local_assigns[:open] ||= '&#x25BC'.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 &#x25B6;
%span.show-when-open &#x25BC;
%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

View file

@ -13,13 +13,30 @@
= render 'sites/build', site: @site, class: 'btn-block'
= render 'sites/moderation_queue', site: @site, class: 'btn-block'
%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
= render 'layouts/details', summary: t('posts.filters.title') do
%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
%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'
@ -46,30 +63,13 @@
%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
- @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
&times;
- if @posts.empty?
%h2= t('posts.empty')
- else

View file

@ -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'

View file

@ -1,11 +1,9 @@
%tr
%th.w-100{ scope: 'row' }
%tr.border-top.border-magenta
%th.font-weight-normal.w-100.position-relative{ scope: 'row' }
- if local_assigns[:parent_schema]
%span.text-muted &mdash;
= schema.humanized_name
%td.px-0.text-nowrap
= render 'schemas/add', **local_assigns
= render 'schemas/filter', **local_assigns
= render 'schemas/add', schema: schema, **local_assigns
-# XXX: Solo un nivel de recursividad
- unless local_assigns[:parent_schema]

View file

@ -1,3 +1,27 @@
.hyphens{ lang: site.default_locale }
%h1= site.title
%p.lead= site.description
%form.mb-3{ action: site_posts_path }
- @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.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
%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, values|
- [values].flatten.each do |value|
= 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
- if param == :layout
= @site.layouts[value.to_sym].humanized_name
- else
= value
&times;

View file

@ -705,6 +705,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
@ -762,7 +765,7 @@ en:
date: 'date'
order: 'Order'
content: 'Text'
new: 'Post types'
new: 'Add content'
remove_filter_help: 'Remove the filter: %{filter}'
categories: 'Everything'
index:

View file

@ -713,6 +713,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
@ -771,7 +774,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'