Module: StudiesHelper
- Defined in:
- app/helpers/studies_helper.rb
Instance Method Summary collapse
- #accession_all_samples_button(study) ⇒ Object
- #bad_icon ⇒ Object
- #checklist_fallback_link(text, path) ⇒ Object
-
#checklist_item(condition:, good:, bad:, action: nil, action_permission: nil, fallback: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists.
-
#display_file_icon(document) ⇒ Object
rubocop:todo Metrics/MethodLength.
- #display_owners(study) ⇒ Object
- #good_icon ⇒ Object
- #label_asset_state(asset) ⇒ Object
- #status_link_title(study) ⇒ Object
- #study_link(study, options) ⇒ Object
Instance Method Details
#accession_all_samples_button(study) ⇒ Object
80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/studies_helper.rb', line 80 def (study) if !accessioning_enabled? tag.span('Accessioning is currently disabled.', class: 'text-muted') elsif !(permitted_to_accession?(study) && study.samples_accessionable?) tag.span('Unable to accession study.', class: 'text-muted') else link_to('<i class="fa fa-upload"></i> Accession all samples'.html_safe, accession_all_samples_study_path(study), class: 'btn btn-sm btn-outline-primary') end end |
#bad_icon ⇒ Object
47 48 49 |
# File 'app/helpers/studies_helper.rb', line 47 def bad_icon icon('fas', 'xmark', class: 'text-danger') end |
#checklist_fallback_link(text, path) ⇒ Object
51 52 53 |
# File 'app/helpers/studies_helper.rb', line 51 def checklist_fallback_link(text, path) "Please contact a #{link_to(text, path)}".html_safe # rubocop:disable Rails/OutputSafety end |
#checklist_item(condition:, good:, bad:, action: nil, action_permission: nil, fallback: nil) ⇒ Object
rubocop:disable Metrics/ParameterLists
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/helpers/studies_helper.rb', line 55 def checklist_item(condition:, good:, bad:, action: nil, action_permission: nil, fallback: nil) # rubocop:disable Metrics/ParameterLists content_tag(:div) do if condition safe_join([good_icon, ' ', good]) else safe_join( [ bad_icon, ' ', bad, content_tag(:span, class: 'text-muted') do safe_join( [ ' — ', (action if action && (.nil? || )), (fallback if fallback && ( == false)) ] ) end ] ) end end end |
#display_file_icon(document) ⇒ Object
rubocop:todo Metrics/MethodLength
19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/helpers/studies_helper.rb', line 19 def display_file_icon(document) # rubocop:todo Metrics/MethodLength return icon('fas', 'exclamation-circle', class: 'text-danger') unless document case document.content_type when /pdf/ icon('far', 'file-pdf', title: 'PDF') when /word/ icon('far', 'file-word', title: 'Word') when /excel/ icon('far', 'file-excel', title: 'Excel') else icon('far', 'file-alt') end end |
#display_owners(study) ⇒ Object
7 8 9 |
# File 'app/helpers/studies_helper.rb', line 7 def display_owners(study) owners_for_display(study.owners) end |
#good_icon ⇒ Object
43 44 45 |
# File 'app/helpers/studies_helper.rb', line 43 def good_icon icon('fas', 'check', class: 'text-success') end |
#label_asset_state(asset) ⇒ Object
34 35 36 |
# File 'app/helpers/studies_helper.rb', line 34 def label_asset_state(asset) asset.closed? ? 'closed' : 'open' end |
#status_link_title(study) ⇒ Object
3 4 5 |
# File 'app/helpers/studies_helper.rb', line 3 def status_link_title(study) study.inactive? || study.pending? ? 'Open' : 'Close' end |
#study_link(study, options) ⇒ Object
38 39 40 41 |
# File 'app/helpers/studies_helper.rb', line 38 def study_link(study, ) link_text = tag.strong(study.name) << ' ' << badge(study.state, type: 'study-state') link_to(link_text, study_path(study), ) end |