Started refactoring
[arvados.git] / apps / workbench / app / views / application / _index.html.erb
index 888bcee74c7aedf824930e3a7ba1f1e38ac9f5e0..4c1fdc320608bf15760ae61ff6c3b75eaba06c01 100644 (file)
@@ -1,22 +1,35 @@
-<% if @objects.empty? %>
 
-<p>
-  No <%= controller.model_class.to_s.underscore.pluralize.gsub '_', ' ' %> to display.
+<h2 class="pull-left"><%= controller.model_class.to_s.pluralize.underscore.capitalize.gsub '_', ' ' %></h2>
+<br/>
+<% if controller.model_class.creatable? %>
+<%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", 
+    { action: 'create', return_to: request.url }, 
+    { class: 'btn btn-primary pull-right' } %>
+<% end %>
+
+
+<% if @objects.empty? %>
+<br/>
+<p style="text-align: center">
+  No <%= controller.model_class.to_s.pluralize.underscore.gsub '_', ' ' %> to display.
 </p>
 
 <% else %>
 
-<% attr_blacklist = 'created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at' %>
+<% attr_blacklist = ' created_at modified_at modified_by_user_uuid modified_by_client_uuid updated_at' %>
 
 <table class="table arv-index">
   <thead>
     <tr>
       <% @objects.first.attributes_for_display.each do |attr, attrvalue| %>
-      <% next if attr_blacklist.index attr %>
+      <% next if attr_blacklist.index(" "+attr) %>
       <th class="arv-attr-<%= attr %>">
         <%= controller.model_class.attribute_info[attr.to_sym].andand[:column_heading] or attr.sub /_uuid/, '' %>
       </th>
       <% end %>
+      <th>
+        <!-- a column for delete buttons -->
+      </th>
     </tr>
   </thead>
       
     <% @objects.each do |object| %>
     <tr>
       <% object.attributes_for_display.each do |attr, attrvalue| %>
-      <% next if attr_blacklist.index attr %>
+      <% next if attr_blacklist.index(" "+attr) %>
       <td class="arv-object-<%= object.class.to_s %> arv-attr-<%= attr %>">
         <% if attr == 'uuid' %>
         <%= link_to_if_arvados_object object %>
-        <% elsif object.attribute_editable? attr %>
+        <%= link_to_if_arvados_object(object, { link_text: raw('<i class="icon-hand-right"></i>') }) %>
+        <% else %>
+        <% if object.attribute_editable? attr %>
         <%= render_editable_attribute object, attr %>
         <% else %>
-        <%= link_to_if_arvados_object attrvalue, {referring_attr: attr, referring_object: @object, with_class_name: true} %>
+        <%= resource_class_for_uuid(attrvalue, referring_attr: attr, referring_object: @object).to_s %>
+        <%= attrvalue %>
+        <% end %>
+        <%= 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}) %>
         <% end %>
       </td>
       <% end %>
+      <td>
+        <% if object.editable? %>
+        <%= 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 %>
+        <i class="icon-trash"></i>
+        <!-- <%= object.inspect %> -->
+        <% end %>
+        <% end %>
+      </td>
     </tr>
     <% end %>
   </tbody>
@@ -45,6 +71,3 @@
 
 <% end %>
 
-<% if controller.model_class.creatable? %>
-<%= button_to "Add a new #{controller.model_class.to_s.underscore.gsub '_', ' '}", { action: 'create', return_to: './' }, { class: 'btn btn-primary' } %>
-<% end %>