Module: Admin::InvoicesHelper
- Defined in:
- app/helpers/admin/invoices_helper.rb
Instance Method Summary collapse
- #active_scaffold_input_options(column, scope = nil, options = {}) ⇒ Object
-
#invoice_activity_types_form_column(column, options) ⇒ Object
Shameless activescaffold copy-pasta:.
- #invoice_amount_column(record) ⇒ Object
- #invoice_is_paid_column(record) ⇒ Object
- #invoice_is_published_column(record) ⇒ Object
- #invoice_is_published_form_column(column, options) ⇒ Object
- #invoice_issued_on_column(record) ⇒ Object
- #invoice_payment_assignments_column(record) ⇒ Object
- #invoice_sub_total_column(record) ⇒ Object
- #invoice_taxes_total_column(record) ⇒ Object
-
#render_action_link(link, url_options, record = nil, html_options = {}) ⇒ Object
This let’s us hook into the action_link names, so we can dynamically generate a label for the publish/unpublish row action.
- #toggle_published_indicator ⇒ Object
- #toggle_published_submit(label, is_focused, url_options = {}) ⇒ Object
Instance Method Details
#active_scaffold_input_options(column, scope = nil, options = {}) ⇒ Object
3 4 5 6 7 |
# File 'app/helpers/admin/invoices_helper.rb', line 3 def (column, scope = nil, = {}) = super(column, scope, ) .merge! :include_seconds => true if column.name == :issued_on end |
#invoice_activity_types_form_column(column, options) ⇒ Object
Shameless activescaffold copy-pasta:
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'app/helpers/admin/invoices_helper.rb', line 95 def invoice_activity_types_form_column(column, ) available_types = ActivityType.find(:all) associated_ids = ( (@record.new_record?) ? available_types : @record.activity_types ).collect(&:id) return 'no options' if available_types.empty? html = '<ul class="checkbox-list">' available_types.each_with_index do |type, i| this_name = "#{[:name]}[#{i}][id]" html << "<li>" html << check_box_tag(this_name, type.id, associated_ids.include?(type.id)) html << "<label for='#{this_name}'>"+type.to_label+"</label>" html << "</li>" end html << '</ul>' html end |
#invoice_amount_column(record) ⇒ Object
29 30 31 |
# File 'app/helpers/admin/invoices_helper.rb', line 29 def invoice_amount_column(record) h_money record.amount end |
#invoice_is_paid_column(record) ⇒ Object
17 18 19 |
# File 'app/helpers/admin/invoices_helper.rb', line 17 def invoice_is_paid_column(record) record.is_published ? (record.is_paid? ? 'Yes' : 'No') : '-' end |
#invoice_is_published_column(record) ⇒ Object
13 14 15 |
# File 'app/helpers/admin/invoices_helper.rb', line 13 def invoice_is_published_column(record) record.is_published ? 'Yes' : 'No' end |
#invoice_is_published_form_column(column, options) ⇒ Object
9 10 11 |
# File 'app/helpers/admin/invoices_helper.rb', line 9 def invoice_is_published_form_column(column, ) select_tag [:name], ([['Yes', 1],['No',0]], (column.is_published) ? 1 : 0 ) end |
#invoice_issued_on_column(record) ⇒ Object
33 34 35 |
# File 'app/helpers/admin/invoices_helper.rb', line 33 def invoice_issued_on_column(record) h record.issued_on.strftime((params[:action] == 'show') ? '%m/%d/%y %I:%M %p' : '%m/%d/%y') end |
#invoice_payment_assignments_column(record) ⇒ Object
37 38 39 40 41 |
# File 'app/helpers/admin/invoices_helper.rb', line 37 def invoice_payment_assignments_column(record) record.payment_assignments.collect{ |asgn| '%s from (Payment %d)' % [asgn.amount.format, asgn.payment_id ] }.join ', ' end |
#invoice_sub_total_column(record) ⇒ Object
21 22 23 |
# File 'app/helpers/admin/invoices_helper.rb', line 21 def invoice_sub_total_column(record) h_money record.sub_total end |
#invoice_taxes_total_column(record) ⇒ Object
25 26 27 |
# File 'app/helpers/admin/invoices_helper.rb', line 25 def invoice_taxes_total_column(record) h_money record.taxes_total end |
#render_action_link(link, url_options, record = nil, html_options = {}) ⇒ Object
This let’s us hook into the action_link names, so we can dynamically generate a label for the publish/unpublish row action
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/helpers/admin/invoices_helper.rb', line 74 def render_action_link(link, , record = nil, = {}) # We don't want to modify the config itself, so we dup it before we start # on changes = .dup if link.action == 'toggle_published' [:link] = (record.is_published) ? 'Un-Publish' : 'Publish' [:onclick] = "Modalbox.show(%s,%s); return false;" % [ url_for(:action => :toggle_published, :id => record.id).to_json, { :title => '%s confirmation' % [(record.is_published) ? 'Un-publish' : 'Publish'], :width => 700 }.to_json ] end super(link, , record, ) end |
#toggle_published_indicator ⇒ Object
43 44 45 |
# File 'app/helpers/admin/invoices_helper.rb', line 43 def toggle_published_indicator loading_indicator_tag :action => :toggle_published, :id => @record.id end |
#toggle_published_submit(label, is_focused, url_options = {}) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'app/helpers/admin/invoices_helper.rb', line 47 def toggle_published_submit( label, is_focused, = {} ) loading_indicator_id = loading_indicator_id(:action => :toggle_published, :id => @record.id) ( label, { :url => { :action => :toggle_published, :id => @record.id, :is_confirmed => 1 }.merge(), :loaded => [ 'Modalbox.hide()', "$(%s).style.visibility = 'visible'" % loading_indicator_id.to_json ].join(';'), :before => [ "$(%s).style.visibility = 'visible'" % loading_indicator_id.to_json, "$$('#MB_content input[type=button]').each(function(i){i.disable();} )", "$('cancel_box').style.display = 'none'" ].join(";"), }, (is_focused) ? {:class => "MB_focusable"} : {} ) end |