Module: NamespacesHelper

Defined in:
app/helpers/namespaces_helper.rb

Instance Method Summary collapse

Instance Method Details

#namespace_autocomplete_tag(namespace) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/helpers/namespaces_helper.rb', line 8

def namespace_autocomplete_tag(namespace)
  return nil if namespace.nil?
  r = []

  if namespace.verbatim_short_name.blank?
    r.push namespace.short_name
  else
    r.push (:span, '[' + namespace.verbatim_short_name + ']', class: [:feedback, 'feedback-thin', 'feedback-warning'] )
  end

  r.push (:span, namespace.name, class: [:feedback, 'feedback-thin', 'feedback-primary'] )

  if !namespace.institution.blank?
    r.push (:span, namespace.institution, class: [:feedback, 'feedback-thin', 'feedback-secondary'] )
  end

  r.join('<br/>').html_safe
end


27
28
29
30
# File 'app/helpers/namespaces_helper.rb', line 27

def namespace_link(namespace)
  return nil if namespace.nil?
  link_to(namespace_tag(namespace).html_safe, namespace)
end

#namespace_select_tag(namespace_element) ⇒ Object



36
37
38
39
40
# File 'app/helpers/namespaces_helper.rb', line 36

def namespace_select_tag(namespace_element)
  select_tag(namespace_element,
             options_for_select(Namespace.pluck(:short_name).uniq),
             prompt: 'Select a namespace')
end

#namespace_tag(namespace) ⇒ Object



3
4
5
6
# File 'app/helpers/namespaces_helper.rb', line 3

def namespace_tag(namespace)
  return nil if namespace.nil? || !namespace.persisted?
  namespace.short_name + ': ' + namespace.name
end

#namespaces_search_formObject



32
33
34
# File 'app/helpers/namespaces_helper.rb', line 32

def namespaces_search_form
  render('/namespaces/quick_search_form')
end