mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-16 15:51:41 +00:00
Merge branch 'issue-13177' into 'rails'
#13177 See merge request sutty/sutty!176
This commit is contained in:
commit
0bb59adb79
10 changed files with 86 additions and 18 deletions
|
@ -29,6 +29,11 @@ $sizes: (
|
||||||
"70ch": 70ch,
|
"70ch": 70ch,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
.btn {
|
||||||
|
background-color: var(--foreground);
|
||||||
|
color: var(--background);
|
||||||
|
}
|
||||||
|
|
||||||
@import "bootstrap";
|
@import "bootstrap";
|
||||||
@import "editor";
|
@import "editor";
|
||||||
|
|
||||||
|
@ -204,8 +209,6 @@ svg {
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
background-color: var(--foreground);
|
|
||||||
color: var(--background);
|
|
||||||
border: none;
|
border: none;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
margin-right: 0.3rem;
|
margin-right: 0.3rem;
|
||||||
|
|
|
@ -9,6 +9,13 @@ Layout = Struct.new(:site, :name, :meta, :metadata, keyword_init: true) do
|
||||||
name.to_s
|
name.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Obtiene todos los layouts (schemas) dependientes de este.
|
||||||
|
#
|
||||||
|
# @return [Array]
|
||||||
|
def schemas
|
||||||
|
@schemas ||= site.layouts.to_h.slice(*site.schema_organization[name]).values
|
||||||
|
end
|
||||||
|
|
||||||
def attributes
|
def attributes
|
||||||
@attributes ||= metadata.keys.map(&:to_sym)
|
@attributes ||= metadata.keys.map(&:to_sym)
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ class Site < ApplicationRecord
|
||||||
include Site::Api
|
include Site::Api
|
||||||
include Site::DeployDependencies
|
include Site::DeployDependencies
|
||||||
include Site::BuildStats
|
include Site::BuildStats
|
||||||
|
include Site::LayoutOrdering
|
||||||
include Tienda
|
include Tienda
|
||||||
|
|
||||||
# Cifrar la llave privada que cifra y decifra campos ocultos. Sutty
|
# Cifrar la llave privada que cifra y decifra campos ocultos. Sutty
|
||||||
|
|
38
app/models/site/layout_ordering.rb
Normal file
38
app/models/site/layout_ordering.rb
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Site
|
||||||
|
# Obtiene un listado de layouts (schemas)
|
||||||
|
module LayoutOrdering
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
|
||||||
|
included do
|
||||||
|
|
||||||
|
# Obtiene o genera un listado de layouts (schemas) con sus
|
||||||
|
# dependencias, para poder generar un árbol.
|
||||||
|
#
|
||||||
|
# Por defecto, si el sitio no lo soporta, se obtienen los layouts
|
||||||
|
# ordenados alfabéticamente por traducción.
|
||||||
|
#
|
||||||
|
# @return [Hash]
|
||||||
|
def schema_organization
|
||||||
|
@schema_organization ||=
|
||||||
|
begin
|
||||||
|
schema_organization = data.dig('schema', 'organization')
|
||||||
|
schema_organization&.symbolize_keys!
|
||||||
|
schema_organization&.transform_values! do |ary|
|
||||||
|
ary.map(&:to_sym)
|
||||||
|
end
|
||||||
|
|
||||||
|
schema_organization ||
|
||||||
|
begin
|
||||||
|
layouts = self.layouts.sort_by(&:humanized_name).map(&:name)
|
||||||
|
Hash[layouts.zip([].fill([], 0, layouts.size))]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# TODO: Deprecar cuando renombremos layouts a schemas
|
||||||
|
alias layout_organization schema_organization
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -7,16 +7,12 @@
|
||||||
= render 'sites/build', site: @site, class: 'btn-block'
|
= render 'sites/build', site: @site, class: 'btn-block'
|
||||||
|
|
||||||
%h3= t('posts.new')
|
%h3= t('posts.new')
|
||||||
%table.mb-3
|
%table.table.table-sm.mb-3
|
||||||
- @site.layouts.sort_by(&:humanized_name).each do |layout|
|
%tbody
|
||||||
- next if layout.hidden?
|
- @site.schema_organization.each do |schema, _|
|
||||||
%tr
|
- schema = @site.layouts[schema]
|
||||||
%th= layout.humanized_name
|
- next if schema.hidden?
|
||||||
%td.pl-3= link_to t('posts.add'), new_site_post_path(@site, layout: layout.value), class: 'btn btn-secondary btn-sm'
|
= render 'schemas/row', site: @site, schema: schema, filter: @filter_params
|
||||||
- if @filter_params[:layout] == layout.name.to_s
|
|
||||||
%td= link_to t('posts.remove_filter'), site_posts_path(@site, **@filter_params.merge(layout: nil)), class: 'btn btn-primary btn-sm'
|
|
||||||
- else
|
|
||||||
%td= link_to t('posts.filter'), site_posts_path(@site, **@filter_params.merge(layout: layout.value)), class: 'btn btn-secondary btn-sm'
|
|
||||||
|
|
||||||
- if policy(@site_stat).index?
|
- if policy(@site_stat).index?
|
||||||
= link_to t('stats.index.title'), site_stats_path(@site), class: 'btn'
|
= link_to t('stats.index.title'), site_stats_path(@site), class: 'btn'
|
||||||
|
|
1
app/views/schemas/_add.haml
Normal file
1
app/views/schemas/_add.haml
Normal file
|
@ -0,0 +1 @@
|
||||||
|
= link_to t('.add'), new_site_post_path(site, layout: schema.value), class: 'btn btn-secondary btn-sm m-0'
|
4
app/views/schemas/_filter.haml
Normal file
4
app/views/schemas/_filter.haml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
- if filter[:layout] == schema.name.to_s
|
||||||
|
= link_to t('.remove'), site_posts_path(site, **filter.merge(layout: nil)), class: 'btn btn-primary btn-sm m-0'
|
||||||
|
- else
|
||||||
|
= link_to t('.filter'), site_posts_path(site, **filter.merge(layout: schema.value)), class: 'btn btn-secondary btn-sm m-0'
|
12
app/views/schemas/_row.haml
Normal file
12
app/views/schemas/_row.haml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
%tr
|
||||||
|
%th{ scope: 'row' }
|
||||||
|
- if local_assigns[:parent_schema]
|
||||||
|
%span.text-muted —
|
||||||
|
= schema.humanized_name
|
||||||
|
%td.px-0= render 'schemas/add', **local_assigns
|
||||||
|
%td.px-0= render 'schemas/filter', **local_assigns
|
||||||
|
|
||||||
|
-# XXX: Solo un nivel de recursividad
|
||||||
|
- unless local_assigns[:parent_schema]
|
||||||
|
- schema.schemas.each do |s|
|
||||||
|
= render 'schemas/row', schema: s, site: site, filter: filter, parent_schema: schema
|
|
@ -542,9 +542,6 @@ en:
|
||||||
order: 'Order'
|
order: 'Order'
|
||||||
content: 'Text'
|
content: 'Text'
|
||||||
new: 'Post types'
|
new: 'Post types'
|
||||||
add: 'Add'
|
|
||||||
filter: 'Filter'
|
|
||||||
remove_filter: 'Back'
|
|
||||||
remove_filter_help: 'Remove the filter: %{filter}'
|
remove_filter_help: 'Remove the filter: %{filter}'
|
||||||
categories: 'Everything'
|
categories: 'Everything'
|
||||||
index:
|
index:
|
||||||
|
@ -701,6 +698,12 @@ en:
|
||||||
queries:
|
queries:
|
||||||
show:
|
show:
|
||||||
empty: '(empty)'
|
empty: '(empty)'
|
||||||
|
schemas:
|
||||||
|
add:
|
||||||
|
add: 'Add'
|
||||||
|
filter:
|
||||||
|
filter: 'Filter'
|
||||||
|
remove: 'Back'
|
||||||
build_stats:
|
build_stats:
|
||||||
index:
|
index:
|
||||||
title: "Publications"
|
title: "Publications"
|
||||||
|
|
|
@ -551,9 +551,6 @@ es:
|
||||||
content: 'Cuerpo del artículo'
|
content: 'Cuerpo del artículo'
|
||||||
categories: 'Todos'
|
categories: 'Todos'
|
||||||
new: 'Tipos de artículos'
|
new: 'Tipos de artículos'
|
||||||
add: 'Agregar'
|
|
||||||
filter: 'Filtrar'
|
|
||||||
remove_filter: 'Volver'
|
|
||||||
remove_filter_help: 'Quitar este filtro: %{filter}'
|
remove_filter_help: 'Quitar este filtro: %{filter}'
|
||||||
index:
|
index:
|
||||||
search: 'Buscar'
|
search: 'Buscar'
|
||||||
|
@ -709,6 +706,12 @@ es:
|
||||||
queries:
|
queries:
|
||||||
show:
|
show:
|
||||||
empty: '(vacío)'
|
empty: '(vacío)'
|
||||||
|
schemas:
|
||||||
|
add:
|
||||||
|
add: 'Agregar'
|
||||||
|
filter:
|
||||||
|
filter: 'Filtrar'
|
||||||
|
remove: 'Volver'
|
||||||
build_stats:
|
build_stats:
|
||||||
index:
|
index:
|
||||||
title: "Publicaciones"
|
title: "Publicaciones"
|
||||||
|
|
Loading…
Reference in a new issue