MiraitSystems/enju_trunk

View on GitHub
app/views/agents/_index_expression.html.erb

Summary

Maintainability
Test Coverage
<div id="content_detail" class="ui-corner-all">
<h1 class="title"><%= t('page.listing', :model => t('agent.contributor')) -%></h1>
<div id="content_list">

  <h2 class="resource_title">
    [E]
    <%= link_to expression.original_title, expression -%>
  </h2>

<%= form_for :agents, :url => expression_agents_path(expression), :html => {:method => 'get'} do -%>
  <p>
    <%= t('page.search_term') -%>: <%= search_field_tag 'query', h(@query), {:id => 'search_form_top', :class => 'search_form', :placeholder => t('page.search_term')} -%>
    <%- if can? :update, expression -%>
      <%= render 'page/add' %>
    <%- end -%>
    <%= submit_tag t('page.search') -%>
    <%= link_to t('page.back_to_index'), expression_agents_path(expression) -%>
  </p>
<%- end -%>

<table class="index">
  <tr>
    <th><%= t('activerecord.attributes.agent.full_name') -%></th>
    <th><%= t('activerecord.models.agent_type') -%></th>
    <th><%= t('activerecord.attributes.agent.date_of_birth') -%></th>
    <th id="edit_icons"></th>
  </tr>
  <%- @agents.each do |agent| -%>
    <%- if agent.user.blank? -%>
      <tr class="line<%= cycle("0", "1") -%>">
        <td><%= link_to agent.full_name, agent -%></td>
        <td><%= agent.agent_type.display_name.localize -%></td>
        <td><%= l(agent.date_of_birth, :format => :only_date) if agent.date_of_birth -%></td>
        <td>
          <%- if can? :destroy, agent -%>
            <%- if params[:mode] == 'add' -%>
              <%= link_to t('page.add'), new_expression_realize_path(expression, :agent_id => agent.id) unless expression.contributors.include?(agent) -%>
            <%- else -%>
              <%= link_to t('page.destroy'), expression_realize_path(expression, expression.realized(agent)), :confirm => t('page.are_you_sure'), :method => :delete -%>
            <%- end -%>
          <%- end -%>
        </td>
      </tr>
    <%- end -%>
  <%- end -%>
</table>

<%= paginate(@agents) -%>
</div>
</div>

<div id="submenu" class="ui-corner-all">
  <h3>
    <%= link_to h("#{t('page.total')}: #{@count[:query_result]}"),
      url_for(params.merge(:action => 'index', :library => nil, :role => nil, :agent_type => nil))  %>
  </h3>
  <% if @count[:query_result] > 0 %>
    <%= render 'agent_type_facet' %>
    <br />
  <% end %>
  <ul>
    <%- if can? :create, Agent -%>
      <li><%= link_to t('page.new', :model => t('activerecord.models.agent')), new_expression_agent_path(expression) -%></li>
    <%- end -%>
  </ul>
</div>