noesya/osuny

View on GitHub
app/views/admin/application/property/_text.html.erb

Summary

Maintainability
Test Coverage
<%
value = object.send(property).to_s
if object.respond_to? "best_#{property}"
  value = object.public_send("best_#{property}").to_s
  source = object.public_send("best_#{property}_source")
end
is_blank = Static.blank?(value)
hide_blank ||= false
title = object.class.human_attribute_name(property)
%>
<% unless hide_blank && is_blank %>
  <div class="mb-4">
    <%= osuny_label title %><br>
    <% 
    if source 
      # source is a l10n
      source_about = source.about
      language = source.language
      %>
      <p class="badge bg-light text-black small">
        <%= t 'admin.inheritance.sentence_html', link: link_to(source, [:admin, source_about, { lang: language }]) %>
      </p>
    <% end %>
    <% if is_blank %>
      <i class="<%= Icon::WARNING %> text-danger"></i>
      <%= t 'properties.text.missing' %>
    <% else %>
      <%= sanitize value %>
    <% end %>
  </div>
<% end %>