Sha256: f60a9db22e59846860d4a286fbba17b93f9f7c19e82a95ff40c2335457527465

Contents?: true

Size: 1.31 KB

Versions: 24

Compression:

Stored size: 1.31 KB

Contents

module IshManager
  module ApplicationHelper


    #
    # api paths
    #
    def api_map_path map
      "/api/maps/view/#{map.slug}"
    end

    def api_marker_path marker
      "/api/markers/view/#{marker.id}"
    end


    def current_layout
      layout = controller.class.send(:_layout)
      if layout.nil?
        '<default>'
      elsif layout.instance_of? String or layout.instance_of? Symbol
        layout
      else
        layout.inspect
        # File.basename(layout.identifier).split('.').first
      end
    end

    # def email_contexts_for_lead_path lead
    #   "/manager/email_contexts/for_lead/#{lead.id.to_s}"
    # end

    def pretty_date input
      return input.strftime("%Y-%m-%d")
    end

    def pp_errors errors
      return errors
    end

    def user_path user
      if user.class == 'String'
        "/users/#{user}"
      elsif user.class == User
        "/users/#{user.id}"
      elsif user.class == NilClass
        "/users"
      end
    end

    def pretty_date date
      # date.to_s[0, 10]
      date&.strftime('%Y-%m-%d')
    end
    def pp_date a; pretty_date a; end

    def pp_amount a
      return '-' if !a
      "$ #{'%.2f' % a}"
    end
    def pp_money a; pp_amount a; end
    def pp_percent a
      "#{(a*100).round(2)}%"
    end

    def pp_bool a
      a ? 'Y' : '-'
    end

  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
ish_manager-0.1.8.382 app/helpers/ish_manager/application_helper.rb
ish_manager-0.1.8.381 app/helpers/ish_manager/application_helper.rb
ish_manager-0.1.8.380 app/helpers/ish_manager/application_helper.rb
ish_manager-0.1.8.379 app/helpers/ish_manager/application_helper.rb