scinote-web/app/helpers/application_helper.rb

56 lines
1.3 KiB
Ruby
Raw Normal View History

2016-02-12 23:52:43 +08:00
module ApplicationHelper
2016-07-29 21:47:41 +08:00
def module_page?
controller_name == 'my_modules'
2016-02-12 23:52:43 +08:00
end
2016-07-29 21:47:41 +08:00
def experiment_page?
controller_name == 'experiments'
2016-02-12 23:52:43 +08:00
end
2016-07-29 21:47:41 +08:00
def project_page?
controller_name == 'projects' ||
(controller_name == 'reports' && action_name == 'index')
2016-02-12 23:52:43 +08:00
end
def display_tooltip(message, len = Constants::NAME_TRUNCATION_LENGTH)
if message.strip.length > Constants::NAME_TRUNCATION_LENGTH
"<div class='modal-tooltip'>#{truncate(message.strip, length: len)} \
<span class='modal-tooltiptext'>#{message.strip}</span></div>".html_safe
else
truncate(message.strip, length: len)
end
end
def sample_types_page_project?
2016-12-14 17:35:48 +08:00
controller_name == 'sample_types' &&
@my_module.nil? &&
@experiment.nil?
end
def sample_groups_page_project?
2016-12-14 17:35:48 +08:00
controller_name == 'sample_groups' &&
@my_module.nil? &&
@experiment.nil?
end
def sample_types_page_my_module?
2016-12-14 17:35:48 +08:00
controller_name == 'sample_types' && !@my_module.nil?
end
def sample_groups_page_my_module?
2016-12-14 17:35:48 +08:00
controller_name == 'sample_groups' && !@my_module.nil?
end
def sample_groups_page_experiment?
controller_name == 'sample_groups' &&
@my_module.nil? &&
!@experiment.nil?
end
def sample_types_page_expermient?
controller_name == 'sample_types' &&
@my_module.nil? &&
!@experiment.nil?
end
2016-02-12 23:52:43 +08:00
end