shapeable/prototype-web

View on GitHub
web-app/app/helpers/application_helper.rb

Summary

Maintainability
A
0 mins
Test Coverage
module ApplicationHelper
  def form_errors_class(object)
    if object.send(:errors).present?
      "has-errors"
    end
  end

  def get_years
    (1930..Date.today.year).to_a.reverse
  end

  def get_lenguages
      I18n.locale == :en ?  ['English','Spanish'] : ['Ingles','Español']
  end

  def get_name(model)
    I18n.locale == :en ?  model.name : model.name_es
  end

  def get_dasboard
    session['dashboard'] ||= 'overview'
  end

  def get_dashboard_dates
    I18n.locale == :en ?  ['Last month','Current month', '2 Months before'] : ['Último mes','Mes actual','2 meses atrás']
  end

  def get_dashboard_regions
    I18n.locale == :en ?  ['All Regions','North California', 'South California'] : ['Todas las regiones','Norte de California','Sur de California']
  end

  def get_dashboard_kpi
    I18n.locale == :en ? {'Users'=>'120,000', 'Users reached'=> '25%', 'Active events'=>'5'} : {'Usuarios'=>'120,000', 'Alcance'=> '25%', 'Eventos activos'=>'5'}
  end

  def get_messages_type
     I18n.locale == :en ?  {'Donation centers'=>'1','Meeting points'=>'2', 'Important Broadcast'=>'3'} : {'Centros de acopio'=>'1','Puntos de reunión'=>'2', 'Transmisión importante'=>'3'}
  end

  def get_alert_type
    I18n.locale == :en ?  ['Dept of interior IGEMS','Weather hazards', 'Other'] : ['Departamento de IGEMS', 'Alertas de clima','Otro']
  end

  def alert_class_for(flash_type)
      case flash_type.to_sym
      when :success
        "flash-success"
      when :error
        "flash-error"
      when :alert
        "flash-notice"
      when :notice
        "flash-alert"
    else
        flash_type.to_s
    end
  end
end