mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-26 10:06:23 +00:00
Merge branch 'issue-13586-2' of 0xacab.org:sutty/sutty into panel.testing.sutty.nl
This commit is contained in:
commit
b17b3b141c
10 changed files with 94 additions and 39 deletions
|
@ -631,3 +631,8 @@ $bezier: cubic-bezier(0.75, 0, 0.25, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
hr {
|
||||||
|
border-bottom: 1px solid #dee2e6;
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
|
|
@ -19,6 +19,25 @@ module ApplicationHelper
|
||||||
[root, name]
|
[root, name]
|
||||||
end
|
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)
|
def plain_field_name_for(*names)
|
||||||
root, name = field_name_for(*names)
|
root, name = field_name_for(*names)
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,13 @@
|
||||||
@param :summary_class [String] Clases para el summary
|
@param :summary_class [String] Clases para el summary
|
||||||
|
|
||||||
- local_assigns[:summary_class] ||= 'h3'
|
- 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] }
|
%summary.d-flex.flex-row.align-items-center.justify-content-between{ class: local_assigns[:summary_class] }
|
||||||
%span= summary
|
%span= summary
|
||||||
%span.hide-when-open ▶
|
%span.hide-when-open{ class: local_assigns[:open_class] }= local_assigns[:closed]
|
||||||
%span.show-when-open ▼
|
%span.show-when-open{ class: local_assigns[:closed_class] }= local_assigns[:open]
|
||||||
= yield
|
= yield
|
||||||
|
|
|
@ -13,14 +13,31 @@
|
||||||
= render 'sites/build', site: @site, class: 'btn-block'
|
= render 'sites/build', site: @site, class: 'btn-block'
|
||||||
= render 'sites/moderation_queue', site: @site, class: 'btn-block'
|
= render 'sites/moderation_queue', site: @site, class: 'btn-block'
|
||||||
|
|
||||||
%h3= t('posts.new')
|
= render 'layouts/details', summary: t('posts.filters.title') do
|
||||||
%table.table.table-sm.mb-3
|
|
||||||
|
%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
|
%tbody
|
||||||
- @site.schema_organization.each do |schema, _|
|
- @site.schema_organization.each do |schema, _|
|
||||||
- schema = @site.layouts[schema]
|
- schema = @site.layouts[schema]
|
||||||
- next if schema.hidden?
|
- next if schema.hidden?
|
||||||
= render 'schemas/row', site: @site, schema: schema, filter: @filter_params
|
= render 'schemas/row', site: @site, schema: schema, filter: @filter_params
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- if policy(@site_stat).index?
|
- if policy(@site_stat).index?
|
||||||
= link_to t('stats.index.title'), site_stats_path(@site), class: 'btn btn-secondary'
|
= link_to t('stats.index.title'), site_stats_path(@site), class: 'btn btn-secondary'
|
||||||
|
|
||||||
|
@ -46,30 +63,13 @@
|
||||||
|
|
||||||
%section.col
|
%section.col
|
||||||
.d-flex.justify-content-between.align-items-center.pl-2-plus.pr-2-plus.mb-2
|
.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
|
- if @site.locales.size > 1
|
||||||
%nav#locales
|
%nav#locales
|
||||||
- @site.locales.each do |locale|
|
- @site.locales.each do |locale|
|
||||||
= link_to @site.data.dig(locale.to_s, 'locale') || locale, site_posts_path(@site, **@filter_params.merge(locale: 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' : ''}"
|
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?
|
- if @posts.empty?
|
||||||
%h2= t('posts.empty')
|
%h2= t('posts.empty')
|
||||||
- else
|
- else
|
||||||
|
|
|
@ -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'
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
%tr
|
%tr.border-top.border-magenta
|
||||||
%th.w-100{ scope: 'row' }
|
|
||||||
|
%th.font-weight-normal.w-100.position-relative{ scope: 'row' }
|
||||||
- if local_assigns[:parent_schema]
|
- if local_assigns[:parent_schema]
|
||||||
%span.text-muted —
|
%span.text-muted —
|
||||||
= schema.humanized_name
|
= render 'schemas/add', schema: schema, **local_assigns
|
||||||
%td.px-0.text-nowrap
|
|
||||||
= render 'schemas/add', **local_assigns
|
|
||||||
= render 'schemas/filter', **local_assigns
|
|
||||||
|
|
||||||
-# XXX: Solo un nivel de recursividad
|
-# XXX: Solo un nivel de recursividad
|
||||||
- unless local_assigns[:parent_schema]
|
- unless local_assigns[:parent_schema]
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
.hyphens{ lang: site.default_locale }
|
.hyphens{ lang: site.default_locale }
|
||||||
%h1= site.title
|
%h1= site.title
|
||||||
%p.lead= site.description
|
%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
|
||||||
|
×
|
||||||
|
|
|
@ -705,6 +705,9 @@ en:
|
||||||
next: Next page
|
next: Next page
|
||||||
empty: "There are no results for those search parameters."
|
empty: "There are no results for those search parameters."
|
||||||
caption: Post list
|
caption: Post list
|
||||||
|
filters:
|
||||||
|
title: Filters
|
||||||
|
submit: Submit
|
||||||
attribute_ro:
|
attribute_ro:
|
||||||
file:
|
file:
|
||||||
download: Download file
|
download: Download file
|
||||||
|
@ -762,7 +765,7 @@ en:
|
||||||
date: 'date'
|
date: 'date'
|
||||||
order: 'Order'
|
order: 'Order'
|
||||||
content: 'Text'
|
content: 'Text'
|
||||||
new: 'Post types'
|
new: 'Add content'
|
||||||
remove_filter_help: 'Remove the filter: %{filter}'
|
remove_filter_help: 'Remove the filter: %{filter}'
|
||||||
categories: 'Everything'
|
categories: 'Everything'
|
||||||
index:
|
index:
|
||||||
|
|
|
@ -713,6 +713,9 @@ es:
|
||||||
next: Página siguiente
|
next: Página siguiente
|
||||||
empty: No hay artículos con estos parámetros de búsqueda.
|
empty: No hay artículos con estos parámetros de búsqueda.
|
||||||
caption: Lista de artículos
|
caption: Lista de artículos
|
||||||
|
filters:
|
||||||
|
title: Filtros
|
||||||
|
submit: Aplicar
|
||||||
attribute_ro:
|
attribute_ro:
|
||||||
file:
|
file:
|
||||||
download: Descargar archivo
|
download: Descargar archivo
|
||||||
|
@ -771,7 +774,7 @@ es:
|
||||||
order: 'Posición'
|
order: 'Posición'
|
||||||
content: 'Cuerpo del artículo'
|
content: 'Cuerpo del artículo'
|
||||||
categories: 'Todos'
|
categories: 'Todos'
|
||||||
new: 'Tipos de artículos'
|
new: 'Agregar contenido'
|
||||||
remove_filter_help: 'Quitar este filtro: %{filter}'
|
remove_filter_help: 'Quitar este filtro: %{filter}'
|
||||||
index:
|
index:
|
||||||
search: 'Buscar'
|
search: 'Buscar'
|
||||||
|
|
Loading…
Reference in a new issue