Module: LoansHelper

Defined in:
app/helpers/loans_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) keywords_on_loanable_items



65
66
67
# File 'app/helpers/loans_helper.rb', line 65

def keywords_on_loanable_items
  Keyword.joins(:tags).where(project_id: sessions_current_project_id).where(tags: {tag_object_type: ['Container', 'Otu', 'CollectionObject']}).distinct.all
end

- (Object) loan_due_back_tag(loan)



59
60
61
62
63
# File 'app/helpers/loans_helper.rb', line 59

def loan_due_back_tag(loan)
  'Due back on ' + 
    ( loan.date_return_expected.present? ? loan.date_return_expected.to_s : 'NOT PROVIDED' ) +
   '.'
end

- (Object) loan_history_tag(object)



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

def loan_history_tag(object)
  (:li, "Loaned #{object.times_loaned} times.")
end


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

def loan_link(loan)
  return nil if loan.nil?
  link_to(loan_tag(loan).html_safe, loan)
end

- (Object) loan_overdue_tag(loan)



46
47
48
49
50
51
52
53
54
55
56
57
# File 'app/helpers/loans_helper.rb', line 46

def loan_overdue_tag(loan)
  if loan.date_return_expected.present?
    if loan.overdue?
      "#{loan.days_overdue} days overdue."
    else
      "#{loan.days_until_due} days until due."  
    end
  else
    (:span, 'Due date NOT PROVIDED.', data: {icon: :warning})
  end

end

- (Object) loan_status_tag(object)



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

def loan_status_tag(object)
  if object.has_loans? && object.has_been_loaned?
    (:h3, 'Loan status') + 
      (:ul) do
      (on_loan_tag(object) +
       loan_history_tag(object)).html_safe
    end
  end
end

- (Object) loan_tag(loan)



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

def loan_tag(loan)
  return nil if loan.nil?
  [loan.id, loan.loan_recipients.collect{|a| a.name}.join(', '), loan.recipient_address].delete_if{|b| b.blank? }.join(' - ').gsub(/\n/, '; ') 
end

- (Object) loans_search_form



13
14
15
# File 'app/helpers/loans_helper.rb', line 13

def loans_search_form
  render('/loans/quick_search_form')
end

- (Object) on_loan_tag(object)



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

def on_loan_tag(object)
  if object.has_loans? && object.on_loan?
    (:li) do
      ['On ' +  link_to('loan', object.loan) + '.', 
        loan_overdue_tag(object.loan), 
        loan_due_back_tag(object.loan)
      ].join(' ').html_safe
         #{overdue_tag(object.loan)}").html_safe
    end
  else
    ''
  end
end