Module: ContainersHelper

Defined in:
app/helpers/containers_helper.rb

Instance Method Summary collapse

Instance Method Details



97
98
99
# File 'app/helpers/containers_helper.rb', line 97

def add_or_move_to_container_link(object)
  link_to( (object.contained? ? 'Move to another' : 'Add to' ) + ' container', containerize_collection_object_path(object) )
end

#container_autocomplete_tag(container) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'app/helpers/containers_helper.rb', line 28

def container_autocomplete_tag(container)
  return nil if container.nil?
  a = [
    identifier_short_tag(container.identifiers.first),
    container.name,
    container.print_label
  ].compact

  a = [ container.id ] if a.empty?
  a.join('&nsbp;').html_safe
end

#container_collection_item_count(container) ⇒ Object



57
58
59
60
61
# File 'app/helpers/containers_helper.rb', line 57

def container_collection_item_count(container)
  return (:em, 'no container provided') if container.blank?
  v = container.all_contained_objects.count
  v == 0 ? 'empty' : v
end

#container_label(container) ⇒ Object



20
21
22
23
24
25
26
# File 'app/helpers/containers_helper.rb', line 20

def container_label(container)
  return nil if container.nil?
  [ identifier_label(container.identifiers.first),
    container.name,
    container.print_label,
  ].compact.join.html_safe
end


15
16
17
18
# File 'app/helpers/containers_helper.rb', line 15

def container_link(container)
  return nil if container.nil?
  link_to(container_tag(container.metamorphosize).html_safe, container.metamorphosize)
end

#container_location(object) ⇒ String?

Returns a string representation of the containers location, includes disposition of the containers if provided

Returns:

  • (String, nil)

    a string representation of the containers location, includes disposition of the containers if provided



65
66
67
68
69
70
71
72
73
74
# File 'app/helpers/containers_helper.rb', line 65

def container_location(object)
  return nil if !object.containable?
  parts = [] 
  object.enclosing_containers.each do |c| 
    s = c.name.blank? ? c.class.class_name : c.name
    s += " [#{c.disposition}]" if !c.disposition.blank? 
    parts.push s 
  end
  parts.join('; ') 
end


46
47
48
49
50
# File 'app/helpers/containers_helper.rb', line 46

def container_parent_link(container)
  return nil if container.container_item.nil?
  return nil if container.container_item.parent.nil?
  link_to(container.container_item.parent.contained_object)
end

#container_parent_tag(container) ⇒ Object



40
41
42
43
44
# File 'app/helpers/containers_helper.rb', line 40

def container_parent_tag(container)
  return nil if container.container_item.nil?
  return nil if container.container_item.parent.nil?
  container_tag(container.container_item.parent.contained_object)
end

#container_tag(container) ⇒ Object



3
4
5
6
7
8
9
10
11
12
# File 'app/helpers/containers_helper.rb', line 3

def container_tag(container)
  return nil if container.nil?
  container.name ? 
    container.name : 
    [container.class.name, 
     "[#{container.to_param}]",
     (:i, 'unnamed'), 
     (:span, container.container_items.count.to_s + ' inside', class: [:feedback, 'feedback-thin', 'feedback-secondary'])
  ].join(' ').html_safe
end

#containers_search_formObject



53
54
55
# File 'app/helpers/containers_helper.rb', line 53

def containers_search_form
  render('/containers/quick_search_form')
end

#draw_container_tag(container) ⇒ Object

TODO: move content to containers/_card



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/helpers/containers_helper.rb', line 77

def draw_container_tag(container)
  return nil if container.nil?

  (:div, class: :draw_container) do
    (:h2) do
      'Container details'
    end + 
    
    (:h3) do
      container_tag(container)
    end +

    (:div) do
      (:ol, class: [:object_tag_list]) do
        container.container_items.collect{ |a| (:li, container_item_tag(a)) }.join('').html_safe
      end
    end
  end
end