5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-10-04 21:26:57 +00:00

Merge branch 'issue-10491' into panel.sutty.nl
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
f 2023-04-05 19:31:24 -03:00
commit 20cfaf0777
3 changed files with 26 additions and 24 deletions

View file

@ -44,6 +44,6 @@ class MetadataLocales < MetadataHasAndBelongsToMany
def posts def posts
other_locales.map do |locale| other_locales.map do |locale|
site.posts(lang: locale).where(layout: post.layout.value) site.posts(lang: locale).where(layout: post.layout.value)
end.reduce(&:concat) || PostRelation.new end.reduce(&:concat) || PostRelation.new(site: site, lang: 'any')
end end
end end

View file

@ -1,9 +1,10 @@
%tr{ id: attribute } - if site.locales.count > 1
%th= post_label_t(attribute, post: post) %tr{ id: attribute }
%td %th= post_label_t(attribute, post: post)
%ul %td
- metadata.value.each do |uuid| %ul
- p = site.docs.find(uuid, uuid: true) - metadata.value.each do |uuid|
%li{ dir: t("locales.#{p.lang.value}.dir"), lang: p.lang.value } - p = site.docs.find(uuid, uuid: true)
= link_to p.title.value, %li{ dir: t("locales.#{p.lang.value}.dir"), lang: p.lang.value }
site_post_path(site, p.id, locale: p.lang.value) = link_to p.title.value,
site_post_path(site, p.id, locale: p.lang.value)

View file

@ -1,18 +1,19 @@
%fieldset - if site.locales.count > 1
%legend= post_label_t(attribute, post: post) %fieldset
%legend= post_label_t(attribute, post: post)
= render 'posts/attribute_feedback', = render 'posts/attribute_feedback',
post: post, attribute: attribute, metadata: metadata post: post, attribute: attribute, metadata: metadata
- site.locales.each do |locale| - site.locales.each do |locale|
- next if post.lang.value == locale - next if post.lang.value == locale
- locale_t = t("locales.#{locale}.name", default: locale.to_s.humanize) - locale_t = t("locales.#{locale}.name", default: locale.to_s.humanize)
- value = metadata.value.find do |v| - value = metadata.value.find do |v|
- metadata.values[locale].values.include? v - metadata.values[locale].values.include? v
.form-group .form-group
= label_tag "#{base}_#{attribute}_#{locale}", locale_t = label_tag "#{base}_#{attribute}_#{locale}", locale_t
= select_tag("#{plain_field_name_for(base, attribute)}[]", = select_tag("#{plain_field_name_for(base, attribute)}[]",
options_for_select(metadata.values[locale], value), options_for_select(metadata.values[locale], value),
**field_options(attribute, metadata), include_blank: t('.empty')) **field_options(attribute, metadata), include_blank: t('.empty'))