From 6bc013c8593bdb9d184fadcd6f091ab1e2d4d8eb Mon Sep 17 00:00:00 2001 From: f Date: Wed, 5 Apr 2023 19:30:59 -0300 Subject: [PATCH] fix: no mostrar el campo si no hay locales --- app/views/posts/attribute_ro/_locales.haml | 19 +++++++------- app/views/posts/attributes/_locales.haml | 29 +++++++++++----------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/app/views/posts/attribute_ro/_locales.haml b/app/views/posts/attribute_ro/_locales.haml index 3ac22933..16ecb532 100644 --- a/app/views/posts/attribute_ro/_locales.haml +++ b/app/views/posts/attribute_ro/_locales.haml @@ -1,9 +1,10 @@ -%tr{ id: attribute } - %th= post_label_t(attribute, post: post) - %td - %ul - - metadata.value.each do |uuid| - - p = site.docs.find(uuid, uuid: true) - %li{ dir: t("locales.#{p.lang.value}.dir"), lang: p.lang.value } - = link_to p.title.value, - site_post_path(site, p.id, locale: p.lang.value) +- if site.locales.count > 1 + %tr{ id: attribute } + %th= post_label_t(attribute, post: post) + %td + %ul + - metadata.value.each do |uuid| + - p = site.docs.find(uuid, uuid: true) + %li{ dir: t("locales.#{p.lang.value}.dir"), lang: p.lang.value } + = link_to p.title.value, + site_post_path(site, p.id, locale: p.lang.value) diff --git a/app/views/posts/attributes/_locales.haml b/app/views/posts/attributes/_locales.haml index 23f66700..4978f6b4 100644 --- a/app/views/posts/attributes/_locales.haml +++ b/app/views/posts/attributes/_locales.haml @@ -1,18 +1,19 @@ -%fieldset - %legend= post_label_t(attribute, post: post) +- if site.locales.count > 1 + %fieldset + %legend= post_label_t(attribute, post: post) - = render 'posts/attribute_feedback', - post: post, attribute: attribute, metadata: metadata + = render 'posts/attribute_feedback', + post: post, attribute: attribute, metadata: metadata - - site.locales.each do |locale| - - next if post.lang.value == locale - - locale_t = t("locales.#{locale}.name", default: locale.to_s.humanize) - - value = metadata.value.find do |v| - - metadata.values[locale].values.include? v + - site.locales.each do |locale| + - next if post.lang.value == locale + - locale_t = t("locales.#{locale}.name", default: locale.to_s.humanize) + - value = metadata.value.find do |v| + - metadata.values[locale].values.include? v - .form-group - = label_tag "#{base}_#{attribute}_#{locale}", locale_t + .form-group + = label_tag "#{base}_#{attribute}_#{locale}", locale_t - = select_tag("#{plain_field_name_for(base, attribute)}[]", - options_for_select(metadata.values[locale], value), - **field_options(attribute, metadata), include_blank: t('.empty')) + = select_tag("#{plain_field_name_for(base, attribute)}[]", + options_for_select(metadata.values[locale], value), + **field_options(attribute, metadata), include_blank: t('.empty'))