Module: Adherent::ApplicationHelper
- Defined in:
- app/helpers/adherent/application_helper.rb
Instance Method Summary collapse
- #icon_to(icon_file, options = {}, html_options = {}) ⇒ Object
- #icon_to_if(condition, icon_file, options = {}, html_options = {}) ⇒ Object
- #icon_to_users ⇒ Object
- #imputation_with_actions(pay, r) ⇒ Object
- #list_imputations(payment) ⇒ Object
- #non_impute(payment) ⇒ Object
- #two_decimals(montant) ⇒ Object
-
#virgule(montant) ⇒ Object
Pour transformer un montant selon le format numérique français avec deux décimales.
Instance Method Details
#icon_to(icon_file, options = {}, html_options = {}) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/adherent/application_helper.rb', line 5 def icon_to(icon_file, ={}, ={}) raise ArgumentError unless icon_file title = alt = icon_file.split('.')[0].capitalize [:title] ||=title [:class] ||= 'icon_menu' # html_options[:tabindex]= "-1" img_path="adherent/icones/#{icon_file}" link_to image_tag(img_path, :alt=> alt), , end |
#icon_to_if(condition, icon_file, options = {}, html_options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'app/helpers/adherent/application_helper.rb', line 16 def icon_to_if(condition, icon_file, ={}, ={}) raise ArgumentError unless icon_file title = alt = icon_file.split('.')[0].capitalize [:title] ||=title [:class] ||= 'icon_menu' # html_options[:tabindex]= "-1" img_path="adherent/icones/#{icon_file}" link_to_if condition, image_tag(img_path, :alt=> alt), , end |
#icon_to_users ⇒ Object
37 38 39 |
# File 'app/helpers/adherent/application_helper.rb', line 37 def icon_to_users icon_to 'users.png', members_path, title:'Liste des membres' end |
#imputation_with_actions(pay, r) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/adherent/application_helper.rb', line 51 def imputation_with_actions(pay, r) # on gère le cas où l'adhésion a disparu (car le membre a disparu) a = r.adhesion mem = a ? a.member : 'supprimée' html = '' html << "Adhésion #{mem} pour #{number_to_currency(r.amount, locale: :fr)}" html << " " html << "#{icon_to 'detail.png', payment_reglement_path(pay.id, r.id)}" html.html_safe end |
#list_imputations(payment) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/adherent/application_helper.rb', line 41 def list_imputations(payment) content_tag(:ul) do payment.reglements.map do |r| content_tag(:li) do imputation_with_actions(payment, r) end end.join.html_safe end end |
#non_impute(payment) ⇒ Object
62 63 64 |
# File 'app/helpers/adherent/application_helper.rb', line 62 def non_impute(payment) payment.amount - payment.reglements.to_a.sum(&:amount) end |
#two_decimals(montant) ⇒ Object
32 33 34 |
# File 'app/helpers/adherent/application_helper.rb', line 32 def two_decimals(montant) sprintf('%0.02f',montant) rescue '0.00' end |
#virgule(montant) ⇒ Object
Pour transformer un montant selon le format numérique français avec deux décimales
28 29 30 |
# File 'app/helpers/adherent/application_helper.rb', line 28 def virgule(montant) ActionController::Base.helpers.number_with_precision(montant, precision:2) rescue '0,00' end |