mysociety/alaveteli

View on GitHub
app/views/admin_comment/edit.html.erb

Summary

Maintainability
Test Coverage
<h1>Edit annotation</h1>

<%= foi_error_messages_for 'comment' %>

<div class="row">
  <div class="span12">
    <table class="table table-striped table-condensed">
      <tbody>
        <tr>
          <td colspan="2">
            By <%= both_links(@comment.user) %>
          </td>
        </tr>

        <tr>
          <td colspan="2">
            On <%= both_links(@comment.info_request) %>
          </td>
        </tr>
      </tbody>
    </table>
  </div>
</div>

<%= form_tag admin_comment_path(@comment), :method => 'put' do %>

  <p><label for="comment_body">Body of annotation</label><br/>
    <%= text_area 'comment', 'body', :rows => 10, :cols => 60  %></p>

  <p><label for="comment_visible">Visible</label>
    <%= select('comment', "visible", [["Yes – show comment",true],["No – hide comment",false]]) %>
  </p>

  <p><label for="comment_attention_requested">Admin attention requested</label>
    <%= select('comment', "attention_requested",
               [
                  ["Yes – flag for further attention", true],
                  ["No – clear flag", false]
                ]) %>
  </p>

  <p><%= submit_tag 'Save', :accesskey => 's', :class => 'btn btn-success' %></p>
<% end %>

<hr>
<h2>Events</h2>
<div class="accordion" id="events">
  <% @comment.info_request_events.each do |info_request_event| %>
    <div class="accordion-group">
      <div class="accordion-heading">
        <span class="item-title">
          <a href="#event_<%=info_request_event.id%>" data-toggle="collapse" data-parent="#events"><%= chevron_right %></a>
          <%= "Event #{ info_request_event.id }" %>:
          <strong>
            <%=h info_request_event.event_type.humanize %><% if !info_request_event.calculated_state.nil? %>; state: <%= info_request_event.calculated_state %><% end %>
          </strong>
          <em>
            <%= info_request_event.created_at%>
          </em>
        </span>
      </div>
      <div id="event_<%=info_request_event.id%>" class="accordion-body collapse">
        <table class="table table-striped table-condensed">
          <tbody>
            <tr>
              <td>
                <% if info_request_event.described_state != 'waiting_clarification' and info_request_event.event_type == 'response' %>
                  <%= form_tag admin_info_request_event_path(info_request_event), :method => 'put', :class => "form form-inline admin-table-form admin-inline-form" do %>
                    <%= submit_tag "Was clarification request", :class => "btn btn-mini btn-primary" %>
                  <% end %>
                <% end %>
              </td>
              <td></td>
            </tr>

            <% info_request_event.for_admin_column(
                 :event_type, :params, :created_at
               ) do |name, value| %>
              <tr>
                <td>
                  <b><%= name.humanize %></b>
                </td>
                <td>
                  <% if name == 'params' %>
                    <%= render :partial => 'params',
                               :locals => {
                                  :params => info_request_event.params_diff
                               } %>
                  <% else %>
                    <%= admin_value(value) %>
                  <% end %>
                </td>
              </tr>
            <% end %>
          </tbody>
        </table>
      </div>
    </div>
  <% end %>
</div>