Module: LoanItemsHelper

Defined in:
app/helpers/loan_items_helper.rb

Instance Method Summary collapse

Instance Method Details



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

def loan_item_link(loan_item)
  return nil if loan_item.nil?
  link_to(loan_item_tag(loan_item), loan_item) # metamorphosize_if(loan_item.loan_item_object))
end

#loan_item_tag(loan_item) ⇒ Object



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

def loan_item_tag(loan_item)
  return nil if loan_item.nil?
  [
    object_tag(loan_item.loan_item_object),
    "[#{loan_item_total_string(loan_item)} total]",
    (loan_item.returned? ? "returned #{loan_item.date_returned}" : nil),
    (loan_item.disposition.blank? ? nil : (:span, loan_item.disposition, class: :warning)),
    "(#{loan_item.loan_item_object_type})"
  ].compact.join(' ').html_safe
end

#loan_item_total_string(loan_item) ⇒ Object

def loan_items_search_form

  render('/loan_items/quick_search_form')
end


23
24
25
26
27
28
29
# File 'app/helpers/loan_items_helper.rb', line 23

def loan_item_total_string(loan_item)
  if t = loan_item.total_items
    t
  else
    'undefined'
  end
end

#loan_item_type_status(loan_item) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/helpers/loan_items_helper.rb', line 31

def loan_item_type_status(loan_item)
  case loan_item.loan_item_object_type
  when 'CollectionObject'
    loan_item.loan_item_object.type_materials.pluck(:type_type).join('; ').presence
  when 'Container'
    l = [ ]
    loan_item.loan_item_object.all_collection_object_ids.each do |o|
      if t = CollectionObject.find(o).type_materials.load
        l.push t.pluck(:type_type)
      end
    end
    l.flatten.compact.uniq.join('; ').presence
  else
    nil
  end
end