Module: ApplicationHelper

Includes:
ActionView::Helpers::NumberHelper
Included in:
Invoice, Prawn::LetterDocument
Defined in:
app/helpers/application_helper.rb

Overview

Methods added to this helper will be available to all templates in the application.

Instance Method Summary collapse

Instance Method Details

#currency_fmt(value) ⇒ Object



16
17
18
19
20
21
# File 'app/helpers/application_helper.rb', line 16

def currency_fmt(value)
  # We often do get -0.0 but don't like it
  value = 0.0 if value.to_s.match %r{^-[0.]*$}

  number = number_with_precision(value, :precision => 2, :separator => '.', :delimiter => "'")
end

#current_tenantObject

Tenancy



11
12
13
# File 'app/helpers/application_helper.rb', line 11

def current_tenant
  current_user.tenant
end

Plugins



4
5
6
7
8
# File 'app/helpers/application_helper.rb', line 4

def engine_stylesheet_link_tag(options = {})
  Bookyt::Engine.engines.map {|engine|
    stylesheet_link_tag engine, options
  }.join.html_safe
end


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

def icon_delete_link_to(model, path)
  link_to t('bookyt.destroy'), path, :remote => true, :method => :delete, :confirm => t_confirm_delete(model), :class => 'icon-delete-text', :title => t('bookyt.destroy')
end

CRUD helpers



24
25
26
# File 'app/helpers/application_helper.rb', line 24

def icon_edit_link_to(path)
  link_to t('bookyt.edit'), path, :method => :get, :class => 'icon-edit-text', :title => t('bookyt.edit')
end

#list_item_actions_for(resource) ⇒ Object



32
33
34
35
36
# File 'app/helpers/application_helper.rb', line 32

def list_item_actions_for(resource)
  model_name = resource.class.to_s.underscore

  render 'layouts/list_item_actions_for', :model_name => model_name, :resource => resource
end

#show_new_form(model) ⇒ Object

Nested form helpers



39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'app/helpers/application_helper.rb', line 39

def show_new_form(model)
  model_name = model.to_s.underscore

  output = <<EOF
$('##{model_name}_list').replaceWith('#{escape_javascript(render('form'))}');
addAutofocusBehaviour();
addAutocompleteBehaviour();
addDatePickerBehaviour();
addAutogrowBehaviour();
EOF

  return output.html_safe
end