scinote-web/app/helpers/sidebar_helper.rb

48 lines
1.2 KiB
Ruby
Raw Normal View History

2016-02-12 23:52:43 +08:00
module SidebarHelper
def currently_active?(my_module)
@my_module.present? and @my_module.id == my_module.id
end
def is_canvas?
action_name == "canvas"
end
def project_action_to_link_to(project)
case action_name
when 'samples'
2016-02-12 23:52:43 +08:00
return samples_project_path(project)
when 'archive', 'module_archive', 'experiment_archive'
return experiment_archive_project_url(project)
2016-02-12 23:52:43 +08:00
else
return project_path(project)
2016-02-12 23:52:43 +08:00
end
end
2016-07-29 21:47:41 +08:00
def experiment_action_to_link_to(experiment)
case action_name
when 'samples'
return samples_experiment_path(experiment)
when 'archive', 'module_archive', 'experiment_archive'
return module_archive_experiment_url(experiment)
else
return canvas_experiment_path(experiment)
end
2016-07-29 21:47:41 +08:00
end
2016-02-12 23:52:43 +08:00
def module_action_to_link_to(my_module)
case action_name
when 'results'
2016-02-12 23:52:43 +08:00
return results_my_module_url(my_module)
when 'activities'
2016-02-12 23:52:43 +08:00
return activities_my_module_url(my_module)
when 'samples'
2016-02-12 23:52:43 +08:00
return samples_my_module_url(my_module)
when 'archive', 'module_archive', 'experiment_archive'
2016-02-12 23:52:43 +08:00
return archive_my_module_url(my_module)
else
2016-07-21 19:11:15 +08:00
return protocols_my_module_url(my_module)
2016-02-12 23:52:43 +08:00
end
end
end