Module: ContainersHelper

Defined in:
app/helpers/containers_helper.rb

Instance Method Summary collapse

Instance Method Details



86
87
88
# File 'app/helpers/containers_helper.rb', line 86

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



21
22
23
24
25
26
27
28
29
30
31
# File 'app/helpers/containers_helper.rb', line 21

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



50
51
52
53
54
# File 'app/helpers/containers_helper.rb', line 50

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



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

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


8
9
10
11
# File 'app/helpers/containers_helper.rb', line 8

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



58
59
60
61
62
63
64
65
66
67
# File 'app/helpers/containers_helper.rb', line 58

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


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

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



33
34
35
36
37
# File 'app/helpers/containers_helper.rb', line 33

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
# 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 + ']').html_safe
end

#containers_search_formObject



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

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

#draw_container_tag(container) ⇒ Object

TODO: move content to containers/_card



70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'app/helpers/containers_helper.rb', line 70

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

  (:div, class: :draw_container) do
    (:div) do
      container_tag(container)
    end +

    (:div) do
      (:ul) do
        container.container_items.collect { |a| (:li, container_item_tag(a)) }
      end
    end
  end
end