noesya/osuny

View on GitHub
app/views/admin/university/people/show.html.erb

Summary

Maintainability
Test Coverage
<% content_for :title, @l10n %>

<div class="row g-5">
  <div class="col-md-4">
    <%= osuny_panel t('activerecord.attributes.university/person.picture'), small: true do %>
      <%= kamifusen_tag @person.best_picture, class: 'img-fluid col-4 col-md-8' %>
      <% if @person.best_picture_inherits_from_user? %>
        <p>
          <span class="small text-muted">
            <%= t 'admin.inheritance.sentence_html', link: link_to_if(can?(:read, @person.user), @l10n.to_s, [:admin, @person.user]) %>
          </span>
        </p>
      <% end %>
      <% if @l10n.picture_credit.present? %>
        <div class="small mb-0">
          <%= sanitize @l10n.picture_credit %>
        </div>
      <% end %>
    <% end if @person.best_picture.attached? %>

    <% if @person.categories.any? %>
      <%= osuny_panel University::Person.human_attribute_name('categories'), small: true do %>
        <ul class="list-unstyled">
          <% @person.categories.ordered.each do |category| %>
            <li>
              <%= osuny_link_localized_if can?(:read, category),
                                          category,
                                          [:admin, category] %>
            </li>
          <% end %>
        </ul>
      <% end %>
    <% end %>

    <%= render 'admin/application/l10n/widget', about: @person, l10n: @l10n, small: true %>

    <%= render 'admin/application/meta_description/show', about: @l10n %>
  </div>
  <div class="col-md-8">

    <%= render 'admin/application/summary/show', about: @l10n, small: true %>

    <% unless @l10n.biography.blank? %>
      <%= osuny_panel University::Person::Localization.human_attribute_name('biography'), small: true do %>
        <%= sanitize @l10n.biography %>
      <% end %>
    <% end %>

    <%= osuny_panel University::Person.human_attribute_name('contacts'), small: true do %>
      <div class="row">
        <% if @person.user.present? %>
          <div class="col-md-6">
            <%= osuny_label University::Person.human_attribute_name('user') %>
            <p><%= link_to_if can?(:read, @person.user), @person.user, admin_user_path(@person.user) %></p>
          </div>
        <% end %>
        <% unless @person.gender.blank? %>
          <div class="col-md-6">
            <%= osuny_label University::Person.human_attribute_name('gender') %>
            <p><%= t("activerecord.attributes.university/person.genders.#{@person.gender}") %></p>
          </div>
        <% end %>
        <% unless @person.email.blank? %>
          <div class="col-md-6">
            <%= osuny_label University::Person.human_attribute_name('email') %>
            <%= personal_attribute_visibility_tag(@person.email_visibility) %>
            <p><%= link_to @person.email, "mailto:#{@person.email}", target: '_blank' %></p>
          </div>
        <% end %>
        <% ['phone_mobile', 'phone_personal', 'phone_professional'].each do |phone| %>
          <% unless @person[phone].blank? %>
            <div class="col-md-6">
              <%= osuny_label University::Person.human_attribute_name(phone) %>
              <%= personal_attribute_visibility_tag(@person["#{phone}_visibility"]) %>
              <p><%= link_to @person[phone], "tel:#{@person[phone]}", target: '_blank' %></p>
            </div>
          <% end %>
        <% end %>
        <% unless @person.birthdate.blank? %>
          <div class="col-md-6">
            <%= osuny_label University::Person.human_attribute_name('birthdate') %>
            <p><%= l(@person.birthdate, format: :birthday) %></p>
          </div>
        <% end %>
        <% [:address, :zipcode, :city].each do |property| %>
          <% value = @person.send property %>
          <% next if value.blank? %>
          <div class="col-md-6">
            <%= osuny_label University::Person.human_attribute_name(property) %>
            <%= personal_attribute_visibility_tag(@person.address_visibility) if property == :address %>
            <p><%= value %></p>
          </div>
        <% end %>
        <% if @person.country.present? %>
          <div class="col-md-6">
            <%= osuny_label University::Person.human_attribute_name(:country) %>
            <p><%= @person.country_name %></p>
          </div>
        <% end %>
      </div>
    <% end %>

    <%= osuny_panel University::Person.human_attribute_name('socials'), small: true do %>
      <div class="row">
        <% unless @l10n.url.blank? %>
          <div class="col-md-6">
            <%= osuny_label University::Person::Localization.human_attribute_name('url') %>
            <p><%= link_to @l10n.url, @l10n.url, target: '_blank' %></p>
          </div>
        <% end %>
        <% unless @l10n.linkedin.blank? %>
          <div class="col-md-6">
            <%= osuny_label University::Person::Localization.human_attribute_name('linkedin') %>
            <%= personal_attribute_visibility_tag(@person.linkedin_visibility) %>
            <p><%= link_to @l10n.linkedin, @l10n.linkedin, target: '_blank' %></p>
          </div>
        <% end %>
        <% unless @l10n.twitter.blank? %>
          <div class="col-md-6">
            <%= osuny_label University::Person::Localization.human_attribute_name('twitter') %>
            <%= personal_attribute_visibility_tag(@person.twitter_visibility) %>
            <p><%= link_to @l10n.twitter, "https://twitter.com/#{@l10n.twitter}", target: '_blank' %></p>
          </div>
        <% end %>
        <% unless @l10n.mastodon.blank? %>
          <div class="col-md-6">
            <%= osuny_label University::Person::Localization.human_attribute_name('mastodon') %>
            <%= personal_attribute_visibility_tag(@person.mastodon_visibility) %>
            <p><%= link_to @l10n.mastodon, @l10n.mastodon, target: '_blank' %></p>
          </div>
        <% end %>
      </div>
    <% end unless @l10n.url.blank? && @l10n.linkedin.blank? && @l10n.twitter.blank? && @l10n.mastodon.blank? %>

  </div>
</div>

<%= render 'admin/communication/contents/editor', about: @l10n %>

<div class="row">
  <div class="offset-lg-4 col-lg-8">
    <% if @teacher_involvements.any? %>
      <%= osuny_panel t('education.teachings') do %>
        <p><%= "#{@teacher_involvements.count} #{Education::Program.model_name.human(count: @teacher_involvements.count).downcase}" %></p>
        <%= link_to t('show'), admin_education_teacher_path(@person), class: 'action' %>
      <% end %>
    <% end %>
    <% if @administrator_involvements.any? %>
      <%= render  'admin/university/people/show/roles',
                  involvements: @administrator_involvements,
                  param_name: :roles_page %>
    <% end %>

    <%
    action = ''
    action += link_to t('university.manage_experiences'),
                      experiences_admin_university_person_path(@person),
                      class: button_classes if can?(:update, @person)
    %>
    <%= osuny_panel University::Person::Experience.model_name.human(count: 2), action: action do %>
      <%= render 'admin/university/people/experiences/list', experiences: @person.experiences.ordered(current_language) %>
    <% end %>

    <%= osuny_panel Research::Laboratory.model_name.human(count: 2) do %>
      <%= render 'admin/research/laboratories/list', laboratories: @person.laboratories.ordered(current_language) %>
    <% end if @person.laboratories.any? %>

    <%= render 'admin/application/connections/list', about: @person %>

    <% if current_user.server_admin? %>
      <%= osuny_panel t('static') do  %>
        <%= link_to 'Administrator',
                    static_administrator_admin_university_person_path(@person),
                    classes: button_classes,
                    target: :_blank %><br>
        <%= link_to 'Author',
                    static_author_admin_university_person_path(@person),
                    classes: button_classes,
                    target: :_blank %><br>
      <% end %>
    <% end %>
  </div>
</div>

<% content_for :action_bar_left do %>
  <%= destroy_link @person %>
  <%= static_link static_admin_university_person_path(@person) %>
<% end %>

<% content_for :action_bar_right do %>
  <%= edit_link @person %>
<% end %>