Merge branch '12690-12748-crunchstat-summary'
[arvados.git] / apps / workbench / app / views / application / _choose.html.erb
1 <%# Copyright (C) The Arvados Authors. All rights reserved.
2
3 SPDX-License-Identifier: AGPL-3.0 %>
4
5 <div class="modal arv-choose modal-with-loading-spinner">
6   <div class="modal-dialog" style="width:80%">
7     <div class="modal-content">
8       <div class="modal-header">
9         <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
10         <h4 class="modal-title"><%= params[:title] || "Choose #{@objects.resource_class.andand.class_for_display}" %></h4>
11       </div>
12
13       <div class="modal-body">
14         <% if params[:message].present? %>
15           <p> <%= params[:message] %> </p>
16         <% end %>
17
18         <% project_filters, chooser_filters = (params[:filters] || []).partition do |attr, op, val|
19              attr == "owner_uuid" and op == "="
20            end %>
21         <div class="input-group">
22           <% if params[:by_project].to_s != "false" %>
23             <% if project_filters.empty?
24                  selected_project_name = 'All projects'
25                else
26                  val = project_filters.last.last
27                  if val == current_user.uuid
28                    selected_project_name = "Home"
29                  else
30                    selected_project_name = Group.find(val).name rescue val
31                  end
32                end
33                %>
34             <div class="input-group-btn" data-filterable-target=".modal.arv-choose .selectable-container">
35               <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
36                 <%= selected_project_name %> <span class="caret"></span>
37               </button>
38               <ul class="dropdown-menu" role="menu">
39                 <li>
40                   <%= link_to '#', class: 'chooser-show-project' do %>
41                     All projects
42                   <% end %>
43                 </li>
44                 <li class="divider" />
45                 <%= render partial: "projects_tree_menu", locals: {
46                       :project_link_to => Proc.new do |pnode, &block|
47                         link_to "#", {
48                           class: "chooser-show-project",
49                           data: {'project_uuid' => pnode[:object].uuid},
50                         }, &block
51                       end,
52                       :top_button => nil
53                     } %>
54               </ul>
55             </div>
56           <% end %>
57           <input type="text" value="<%=params[:preconfigured_search_str] || ''%>" class="form-control filterable-control focus-on-display" placeholder="Search" data-filterable-target=".modal.arv-choose .selectable-container"/>
58         </div>
59         <div style="height: 1em" />
60
61         <% preview_pane = (params[:preview_pane].to_s != "false") %>
62         <div class="row" style="height: 20em">
63           <div class="<%= 'col-sm-6' if preview_pane %> col-xs-12 arv-filterable-list selectable-container <%= 'multiple' if multiple %>"
64                style="height: 100%; overflow-y: scroll"
65                data-infinite-scroller="#choose-scroll"
66                id="choose-scroll"
67                data-infinite-content-params-from-chooser="<%= {filters: chooser_filters}.to_json %>"
68                <% if project_filters.any? %>
69                  data-infinite-content-params-from-project-dropdown="<%= {filters: project_filters, project_uuid: project_filters.last.last}.to_json %>"
70                <% end %>
71                <%
72                   action_data = JSON.parse params['action_data'] if params['action_data']
73                   use_preview_sel = action_data ? action_data['use_preview_selection'] : false
74                 %>
75                data-infinite-content-href="<%= url_for partial: true,
76                                                        use_preview_selection: use_preview_sel %>">
77           </div>
78           <% if preview_pane %>
79             <div class="col-sm-6 col-xs-12 modal-dialog-preview-pane" style="height: 100%; overflow-y: scroll">
80             </div>
81           <% end %>
82         </div>
83
84         <div class="modal-footer">
85           <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
86           <button class="btn btn-primary" aria-hidden="true" data-enable-if-selection disabled><%= raw(params[:action_name]) || 'Select' %></button>
87           <div class="modal-error hide" style="text-align: left; margin-top: 1em;">
88           </div>
89         </div>
90       </div>
91     </div>
92   </div>
93 </div>