2872: Merge branch 'master' into 2872-folder-nav
[arvados.git] / apps / workbench / app / views / application / _content.html.erb
1 <% content_for :content_top do %>
2   <% if @object and not @object.is_a?(Group) and @object.class.goes_in_projects? and @object.owner_uuid == current_user.uuid %>
3     <div class="pull-right" style="width: 40%">
4       <div class="alert alert-warning alert-dismissable">
5         <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
6         <strong>Hey.</strong> This <%= @object.class_for_display.downcase %> belongs to your account, but it's not in any of your projects. If you want it to be easy to find in the future, you should move it to a project.<br />
7         <%= button_to(choose_projects_path(
8                    title: 'Move to...',
9                    editable: true,
10                    action_name: 'Move',
11                    action_href: url_for(action: :update),
12                    action_method: 'patch',
13                    action_data: {selection_param: @object.resource_param_name+'[owner_uuid]', success: 'page-refresh'}.to_json),
14                   { class: "btn btn-primary btn-sm", remote: true, method: 'get' }) do %>
15           <i class="fa fa-fw fa-folder"></i> Choose a project...
16         <% end %>
17       </div>
18     </div>
19   <% end %>
20 <% end %>
21
22 <% content_for :js do %>
23   tab_pane_valid_state = {};
24
25   function ajaxRefreshTabPane(pane) {
26     if (!tab_pane_valid_state[pane]) {
27       tab_pane_valid_state[pane] = true;
28       $(document).trigger('ajax:send');
29       $.ajax('<%=j url_for @object %>?tab_pane='+pane, {dataType: 'html', type: 'GET'}).
30         done(function(data, status, jqxhr) {
31           $('#' + pane + ' > div > div').html(data);
32           $(document).trigger('ajax:complete');
33           ajaxRefreshTabPane(pane);
34         });
35     }
36   }
37
38   $(window).on('load', smart_scroll_fixup);
39   $(document).on('shown.bs.tab', 'ul.nav-tabs > li > a', smart_scroll_fixup);
40
41   $(document).on('shown.bs.tab', function(e) {
42     ajaxRefreshTabPane(e.target.id.slice(0, -4));
43   });
44
45   $(document).on('arv-log-event', function() {
46     <% pane_list.each do |pane| %>
47     tab_pane_valid_state['<%=j pane %>'] = false;
48     <% end %>
49     ajaxRefreshTabPane($('.tab-pane.active')[0].id);
50   });
51 <% end %>
52
53 <% content_for :tab_panes do %>
54
55 <% comparable = controller.respond_to? :compare %>
56
57 <ul class="nav nav-tabs">
58   <% pane_list.each_with_index do |pane, i| %>
59     <li class="<%= 'active' if i==0 %>"><a href="#<%= pane %>" data-toggle="tab" id="<%= pane %>-tab"> <%= pane.gsub('_', ' ') %></a></li>
60   <% end %>
61 </ul>
62 <div class="tab-content">
63 <% pane_list.each_with_index do |pane, i| %>
64   <div id="<%= pane %>"
65        class="tab-pane fade <%= 'in active' if i==0 %> arv-log-event-listener"
66 <% if controller.action_name == "index" %>
67        data-object-kind="arvados#<%= ArvadosApiClient.class_kind controller.model_class %>"
68 <% else %>
69        data-object-uuid="<%= @object.uuid %>"
70 <% end %>
71 >
72
73 <% content_for :js do %>
74   <% if i == 0 %>
75     tab_pane_valid_state['<%=j pane %>'] = true;
76   <% else %>
77     tab_pane_valid_state['<%=j pane %>'] = false;
78     $(document).on('ready', function() {
79       ajaxRefreshTabPane('<%=j pane %>');
80     });
81   <% end %>
82 <% end %>
83
84     <div id="<%= pane %>-scroll" class="<%= 'smart-scroll' if pane.match(/graph/) %>" style="margin-top:0.5em;">
85       <div class="pane-content">
86         <% if i == 0 %>
87           <%= render(partial: 'show_' + pane.downcase,
88                      locals: { comparable: comparable, objects: @objects }) %>
89           <% else %>
90             <%= image_tag 'ajax-loader.gif' %>
91         <% end %>
92       </div>
93     </div>
94   </div>
95 <% end %>
96 </div>
97
98 <% end %>