Module: ContainersHelper

Defined in:
app/helpers/containers_helper.rb

Instance Method Summary (collapse)

Instance Method Details



66
67
68
# File 'app/helpers/containers_helper.rb', line 66

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

- (Object) container_collection_item_count(container)



30
31
32
33
34
# File 'app/helpers/containers_helper.rb', line 30

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


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

- (String?) container_location(object)

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



38
39
40
41
42
43
44
45
46
47
# File 'app/helpers/containers_helper.rb', line 38

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


19
20
21
22
23
# File 'app/helpers/containers_helper.rb', line 19

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

- (Object) container_parent_tag(container)



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

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

- (Object) container_tag(container)



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

- (Object) containers_search_form



26
27
28
# File 'app/helpers/containers_helper.rb', line 26

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

- (Object) draw_container_tag(container)

TODO: move content to containers/_card



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'app/helpers/containers_helper.rb', line 50

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