9d77c4983f351fc516466d01e981eb8a764c29b6
[arvados.git] / apps / workbench / app / views / application / _index.html.erb
1 <% if @objects.empty? %>
2
3 <p>
4   No <%= controller.model_class.to_s.pluralize.underscore.gsub '_', ' ' %> to display.
5 </p>
6
7 <% else %>
8
9 <h2><%= controller.model_class.to_s.pluralize.underscore.capitalize.gsub '_', ' ' %></h2>
10
11 <% attr_blacklist = ' created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at' %>
12
13 <table class="table arv-index">
14   <thead>
15     <tr>
16       <% @objects.first.attributes_for_display.each do |attr, attrvalue| %>
17       <% next if attr_blacklist.index(" "+attr) %>
18       <th class="arv-attr-<%= attr %>">
19         <%= controller.model_class.attribute_info[attr.to_sym].andand[:column_heading] or attr.sub /_uuid/, '' %>
20       </th>
21       <% end %>
22       <th>
23         <!-- a column for delete buttons -->
24       </th>
25     </tr>
26   </thead>
27       
28   <tbody>
29     <% @objects.each do |object| %>
30     <tr>
31       <% object.attributes_for_display.each do |attr, attrvalue| %>
32       <% next if attr_blacklist.index(" "+attr) %>
33       <td class="arv-object-<%= object.class.to_s %> arv-attr-<%= attr %>">
34         <% if attr == 'uuid' %>
35         <%= link_to_if_arvados_object object %>
36         <%= link_to_if_arvados_object(object, { link_text: raw('<i class="icon-hand-right"></i>') }) %>
37         <% else %>
38         <% if object.attribute_editable? attr %>
39         <%= render_editable_attribute object, attr %>
40         <% else %>
41         <%= resource_class_for_uuid(attrvalue, referring_attr: attr, referring_object: @object).to_s %>
42         <%= attrvalue %>
43         <% end %>
44         <%= link_to_if_arvados_object(attrvalue, { referring_object: @object, link_text: raw('<i class="icon-hand-right"></i>') }) if resource_class_for_uuid(attrvalue, {referring_object: @object}) %>
45         <% end %>
46       </td>
47       <% end %>
48       <td>
49         <% if object.editable? %>
50         <%= link_to({action: 'destroy', id: object.uuid}, method: :delete, data: {confirm: "You are about to delete #{controller.model_class} #{object.uuid}.\n\nAre you sure?"}) do %>
51         <i class="icon-trash"></i>
52         <!-- <%= object.inspect %> -->
53         <% end %>
54         <% end %>
55       </td>
56     </tr>
57     <% end %>
58   </tbody>
59
60   <tfoot>
61   </tfoot>
62 </table>
63
64 <% end %>
65
66 <% if controller.model_class.creatable? %>
67 <%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", { action: 'create', return_to: request.url }, { class: 'btn btn-primary' } %>
68 <% end %>