3201: Simplify logic to decide "My Projects" is selectable.
[arvados.git] / apps / workbench / app / views / projects / _choose.html.erb
1 <div class="modal">
2   <div class="modal-dialog">
3     <div class="modal-content">
4
5       <div class="modal-header">
6         <button type="button" class="close" onClick="reset_form()" data-dismiss="modal" aria-hidden="true">&times;</button>
7         <h4 class="modal-title"><%= params[:title] || 'Choose project' %></h4>
8       </div>
9
10       <div class="modal-body">
11         <div class="selectable-container" style="height: 15em; overflow-y: scroll">
12           <% [my_project_tree, shared_project_tree].each do |tree| %>
13             <% tree.each do |projectnode| %>
14               <% if projectnode[:object].is_a? String %>
15                 <div class="row" style="padding-left: <%= 1 + projectnode[:depth] %>em; margin-right: 0px">
16                   <i class="fa fa-fw fa-folder-open-o"></i>
17                   <%= projectnode[:object] %>
18                 </div>
19               <% else
20                  row_selectable = !params[:editable] || projectnode[:object].editable?
21                  folder_class = "fa-folder-o"
22                  if projectnode[:object].uuid == current_user.uuid
23                    row_name = "My Projects"
24                    row_selectable &&= params[:my_root_selectable]
25                    folder_class = "fa-folder-open-o" if not row_selectable
26                  else
27                    row_name = projectnode[:object].friendly_link_name || 'New project'
28                  end %>
29                 <div class="<%= 'selectable project' if row_selectable %> row"
30                      style="padding-left: <%= 1 + projectnode[:depth] %>em; margin-right: 0px" data-object-uuid="<%= projectnode[:object].uuid %>">
31                   <i class="fa fa-fw <%= folder_class %>"></i> <%= row_name %>
32                 </div>
33               <% end %>
34             <% end %>
35           <% end %>
36         </div>
37       </div>
38
39       <div class="modal-footer">
40         <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Cancel</button>
41         <button class="btn btn-primary" aria-hidden="true"><%= params[:action_name] || 'Select' %></button>
42         <div class="modal-error hide" style="text-align: left; margin-top: 1em;">
43         </div>
44       </div>
45     </div>
46   </div>
47 </div>