AgileVentures/LocalSupport

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

Summary

Maintainability
Test Coverage
<% if @proposed_organisation_edit.editor %>
<div class="centered width_50 proposer">
  <span>This edit proposed by:</span>
  <%= @proposed_organisation_edit.editor.email%>
</div>
<% end %>

<div class="row">
  <div class="col-md-6">
    <h3 class="text-center">Current Information</h3>
    <h4 class="<%= show_class('current', 'name') %>">
      <span class='field_value'>
      <%= @organisation.name %>
      </span>
    </h4>
    <p>
      <%= simple_format @organisation.description, class: show_class('current', 'description') %>
    </p>
    <% if @proposed_organisation_edit.viewable_field?(:address, by: current_user) %>
      <p class="<%= show_class('current', 'address') %>">
        <span><b>Address:</b></span>
        <span class='field_value'>
          <%= @organisation.address %>
        </span>
      </p>
    <% end %>

    <% if @proposed_organisation_edit.editable? :postcode  %>
        <p class="<%= show_class('current', 'postcode') %>">
          <span><b>Postcode:</b></span>
          <span class='field_value'>
            <%= @organisation.postcode %>
          </span>
        </p>
    <% end %>

    <% if @proposed_organisation_edit.viewable_field?(:email, by: current_user)%>
        <p class="<%= show_class('current', 'email') %>">
          <span><b>Email:</b></span>
          <span class='field_value'>
            <a href="mailto:<%= @organisation.email %>"><%= @organisation.email %></a>
          </span>
        </p>
    <% end %>

    <% if @proposed_organisation_edit.editable? :website %>
      <p class="<%= show_class('current', 'website') %>">
        <span><b>Website:</b></span>
        <span class='field_value'>
          <%= link_to @organisation.website, @organisation.website, {:target => '_blank'} if @organisation.website.present?%>
        </span>
      </p>
    <% end %>

    <% if @proposed_organisation_edit.viewable_field?(:telephone, by: current_user)%>
      <p class="<%= show_class('current', 'telephone') %>">
      <span><b>Telephone:</b></span>
      <span class='field_value'>
        <%= @organisation.telephone %>
      </span>
      </p>
    <% end %>

    <% if @proposed_organisation_edit.editable?(:donation_info)  %>
        <p class="<%= show_class('current', 'donation_info') %>">
        <span><b>Donation Info:</b></span>
          <span class='field_value'>
            <%= @organisation.donation_info %>
          </span>
        </p>
    <% end %>

    <% if current_user.try(:superadmin?) %>
        <div class="centered width_25">
          <%= form_for([@proposed_organisation_edit.organisation, @proposed_organisation_edit], :url => {:action => :update}) do |f| %>
            <%= f.hidden_field :id, value: @proposed_organisation_edit.id %>
            <%= f.submit 'Keep Current Information', :class => 'btn btn-primary' %>
          <% end %>
        </div>
    <% end %>
  </div>
  <div class="col-md-6">
    <h3 class="text-center">Proposed Edit</h3>
    <h4 class="<%= show_class('proposed', 'name') %>">
      <span class="field_value">
      <%= @proposed_organisation_edit.name %>
      </span>
    </h4>
    <p>
      <span class="field_value">
      <%= simple_format @proposed_organisation_edit.description, class: show_class('proposed', 'description') %>
      </span>
    </p>

    <% if @proposed_organisation_edit.viewable_field?(:address, by: current_user) %>
      <p class="<%= show_class('proposed', 'address') %>">
        <span><b>Address:</b></span>
        <span class='field_value'>
          <%= @proposed_organisation_edit.address %>
        </span>
      </p>
    <% end %>

    <% if @proposed_organisation_edit.editable? :postcode %>
        <p class="<%= show_class('proposed', 'postcode') %>">
          <span><b>Postcode:</b></span>
          <span class='field_value'>
            <%= @proposed_organisation_edit.postcode %>
          </span>
        </p>
    <% end %>

    <% if @proposed_organisation_edit.viewable_field?(:email, by: current_user) %>
      <p class="<%= show_class('proposed', 'email') %>">
        <span><b>Email:</b></span>
        <span class='field_value'>
          <a href="mailto:<%= @proposed_organisation_edit.email %>"><%= @proposed_organisation_edit.email %></a>
        </span>
      </p>
    <% end %>

    <% if @proposed_organisation_edit.editable? :website %>
      <p class="<%= show_class('proposed', 'website') %>">
        <span><b>Website:</b></span>
        <span class='field_value'>
          <%= link_to @proposed_organisation_edit.website, @proposed_organisation_edit.website, {:target => '_blank'} if @proposed_organisation_edit.website.present?%>
        </span>
      </p>
    <% end %>

    <% if @proposed_organisation_edit.viewable_field?(:telephone, by: current_user) %>
        <p class="<%= show_class('proposed', 'telephone') %>">
          <span><b>Telephone:</b></span>
          <span class='field_value'>
            <%= @proposed_organisation_edit.telephone %>
          </span>
        </p>
    <% end %>

    <% if @proposed_organisation_edit.editable? :donation_info %>
        <p class="<%= show_class('proposed', 'donation_info') %>">
          <span><b>Donation Info:</b></span>
          <span class='field_value'>
            <%= @proposed_organisation_edit.donation_info %>
          </span>
        </p>
    <% end %>

    <% if current_user.try(:superadmin?) %>
        <div class="centered width_25">
          <%= form_for([@proposed_organisation_edit.organisation, @proposed_organisation_edit], :url => {:action => :update}) do |f| %>
            <%= f.hidden_field :id, value: @proposed_organisation_edit.id %>
            <%= f.hidden_field :name, value: @proposed_organisation_edit.name %>
            <%= f.hidden_field :description, value: @proposed_organisation_edit.description %>
            <%= f.hidden_field :donation_info, value: @proposed_organisation_edit.donation_info %>
            <% if @proposed_organisation_edit.editable?(:address, by: @proposed_organisation_edit.editor) %>
            <%= f.hidden_field :address, value: @proposed_organisation_edit.address %>
            <% end %>
            <%= f.hidden_field :postcode, value: @proposed_organisation_edit.postcode %>
            <% if @proposed_organisation_edit.editable?(:telephone, by: @proposed_organisation_edit.editor)%>
            <%= f.hidden_field :telephone, value: @proposed_organisation_edit.telephone %>
            <% end %>
            <%= f.hidden_field :website, value: @proposed_organisation_edit.website %>
            <% if @proposed_organisation_edit.editable?(:email, by: @proposed_organisation_edit.editor)%>
            <%= f.hidden_field :email, value: @proposed_organisation_edit.email %>
            <% end %>
            <%= f.submit 'Accept Edit', :class => 'btn btn-success' %>
          <% end %>
        </div>
    <% end %>
  </div>
</div>