infusionvlc/infusion

View on GitHub
app/views/proposals/show.html.erb

Summary

Maintainability
Test Coverage
<!-- Modal -->
<div class="modal fade" id="propReportModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
      <div class="modal-body">
        <%= render 'reports/form' %>
      </div>
    </div>
  </div>
</div>

<div class="jumbotron jumbotron-fluid">
  <div class="container">
    <h1><%= @proposal.title %></h1>
    <p class="lead"><%= proposal_votes(@proposal) %></p>
  </div>
</div>
<br/>
<div class="row">
  <div class="col-md-8 col-sm-12 description">
    <h2><%= I18n.t 'activerecord.attributes.proposal.description' %></h2>
    <p><%= sanitize @markdown.render(@proposal.description), attributes: %w(href target) if @proposal.description %></p>
  </div>
  <div class="col-md-4 col-sm-12">
      <% if policy(@proposal).report? %>
        <button data-toggle="modal" data-target="#propReportModal" class="btn btn-warning btn-lg btn-block">
          <%= icon('fas', 'exclamation-triangle')  %> <%= I18n.t 'report.report' %>
        </button>
      <% end %>
      <% if policy(@proposal).edit? %>
        <%= link_to edit_proposal_path(@proposal), class:'btn btn-primary btn-lg btn-block' do %><%= icon('fas', 'pencil') %> <%= I18n.t 'main.edit' %><% end %>
        <% if policy(@proposal).destroy? %>
          <%= link_to proposal_path(@proposal), method: :delete, class:'btn btn-danger btn-lg btn-block' do %><%= icon('fas', 'times') %> <%= I18n.t 'main.delete' %><% end %>
        <% end %>
        <br/>
      <% end %>
      <% if policy(@proposal).vote? %>
        <p><%= I18n.t 'proposal.call_to_action' %></p>
        <%= link_to vote_proposal_path(@proposal), method: :post, class:'btn btn-success btn-lg btn-block' do %><%= icon('fas', 'arrow-up') %> <%= I18n.t 'main.vote' %><% end %>
      <% elsif user_signed_in? %>
        <p><%= I18n.t 'proposal.already_voted' %></p>
      <% else %>
        <p><%= I18n.t 'proposal.call_to_action_no_user' %></p>
        <%= link_to new_user_session_path, class:'btn btn-primary btn-lg btn-block' do %><%= icon('fas', 'sign-in') %> <%= I18n.t 'user.login' %><% end %>
      <% end %>
  </div>
</div>