3201: Simplify logic to decide "My Projects" is selectable.
authorBrett Smith <brett@curoverse.com>
Wed, 9 Jul 2014 01:32:40 +0000 (21:32 -0400)
committerBrett Smith <brett@curoverse.com>
Wed, 9 Jul 2014 01:32:57 +0000 (21:32 -0400)
Thinking about it on the commute home, I decided that my previous
implementation that inspected action_href (e007ef71) was too clever by
half.  Following the adage that explicit is better than implicit, this
version provides a knob you can turn to just say whether or not "My
Projects" is selectable.

Closes #3201.

apps/workbench/app/views/projects/_choose.html.erb
apps/workbench/app/views/projects/_show_contents.html.erb
apps/workbench/app/views/projects/_show_data_collections.html.erb

index 4bae8aab8fd894b6073439a8f9da8df05c449ff7..3f2027117763899cb545ed37771a59ce8c706e0a 100644 (file)
@@ -21,7 +21,7 @@
                  folder_class = "fa-folder-o"
                  if projectnode[:object].uuid == current_user.uuid
                    row_name = "My Projects"
-                   row_selectable &&= (resource_class_for_uuid(params[:action_href].split("/").last) == Group) rescue false
+                   row_selectable &&= params[:my_root_selectable]
                    folder_class = "fa-folder-open-o" if not row_selectable
                  else
                    row_name = projectnode[:object].friendly_link_name || 'New project'
index c3d509f90ab926348647e5c2edbb45216a07000c..0c8fab208e2f657a0c612fb3a844673633cb3df3 100644 (file)
@@ -41,6 +41,7 @@
        choose_projects_path(
         title: 'Move this project to...',
         editable: true,
+        my_root_selectable: true,
         action_name: 'Move',
         action_href: project_path(@object.uuid),
         action_method: 'put',
index a8b58b84481ca92ac2d77e18c1a83e2b2b7edcb4..c632324055a2df8f07217f9efea734e7df68c307 100644 (file)
@@ -41,6 +41,7 @@
        choose_projects_path(
         title: 'Move this project to...',
         editable: true,
+        my_root_selectable: true,
         action_name: 'Move',
         action_href: project_path(@object.uuid),
         action_method: 'put',