5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-26 09:56:21 +00:00

feat: poder anidar un artículo #15066

This commit is contained in:
f 2024-04-17 18:09:55 -03:00
parent 5e2bddf7cc
commit 0cf2ec04ba
No known key found for this signature in database
6 changed files with 59 additions and 10 deletions

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
class MetadataHasOneNested < MetadataHasOne
def nested
@nested ||= layout.metadata.dig(name, 'nested')
end
def nested?
true
end
end

View file

@ -0,0 +1,16 @@
-#
@param base [String]
@param locale [String]
@param post [Post]
@param site [Site]
@param dir [String]
- post.attributes.each do |attribute|
- metadata = post[attribute]
- type = metadata.type
- cache [metadata, I18n.locale] do
= render("posts/attributes/#{type}",
base: base, post: post, attribute: attribute,
metadata: metadata, site: site,
dir: dir, locale: locale,
autofocus: (post.attributes.first == attribute))

View file

@ -0,0 +1,19 @@
-#
@param inverse [Symbol]
@param base [String]
@param locale [String]
@param post [Post]
@param site [Site]
@param dir [String]
- post.attributes.each do |attribute|
- next if attribute == :date
- next if attribute == :draft
- next if attribute == inverse
- metadata = post[attribute]
- type = metadata.type
- cache [metadata, I18n.locale] do
= render "posts/attributes/#{type}",
base: base, post: post, attribute: attribute,
metadata: metadata, site: site,
dir: dir, locale: locale, autofocus: false

View file

@ -41,16 +41,7 @@
= hidden_field_tag 'post[layout]', post.layout.name
-# Dibuja cada atributo
- post.attributes.each do |attribute|
- metadata = post[attribute]
- type = metadata.type
- cache [metadata, I18n.locale] do
= render("posts/attributes/#{type}",
base: 'post', post: post, attribute: attribute,
metadata: metadata, site: site,
dir: dir, locale: @locale,
autofocus: (post.attributes.first == attribute))
= render 'posts/attributes', site: site, post: post, dir: dir, base: 'post', locale: @locale
-# Botones de guardado
= render 'posts/submit', site: site, post: post

View file

@ -0,0 +1,6 @@
%tr{ id: attribute }
%th= post_label_t(attribute, post: post)
%td{ dir: dir, lang: locale }
- p = metadata.has_one
- if p
= link_to p.title.value, site_post_path(site, p.id)

View file

@ -0,0 +1,6 @@
- new_post = site.posts(lang: locale).build(layout: metadata.nested)
- base = "#{base}[#{metadata.name}]"
.form-group
= render 'layouts/details', id: metadata.nested, summary: site.layouts[metadata.nested].humanized_name do
= render 'posts/attributes_nested', site: site, post: new_post, dir: dir, base: base, locale: locale, inverse: metadata.inverse