Sha256: 668bd6f6ce8ea31476ad1c8c65566c634e5416cf33739e7d1aeddda31c5f3097

Contents?: true

Size: 1.62 KB

Versions: 8

Compression:

Stored size: 1.62 KB

Contents

module C80Push
  module AdminHelper

    # noinspection RubyResolve
    def first_region(subj)
      res = '-'
      unless subj.regions.count.zero?
        res = subj.regions.first.title
      end
      res.html_safe
    end

    # noinspection RubyResolve
    def ul_offices(subj)
      res = '-'
      unless subj.offices.count.zero?
        res = ''
        subj.offices.each do |office|
          e = "<li>#{office.title}</li>"
          res += e
        end
        res = "<ul>#{res}</ul>".html_safe
      end
      res
    end

    # noinspection RubyResolve
    def ul_dealers(subj)
      res = '-'
      unless subj.dealers.count.zero?
        res = ''
        subj.dealers.each do |dealer|
          e = "<li>#{dealer.title}</li>"
          res += e
        end
        res = "<ul>#{res}</ul>".html_safe
      end
      res
    end

    def dealer_col_title(dealer)
      res = "#{dealer.title}"
      res += "<br><sub>email: #{format_val(dealer.email)}</sub>"
      res += "<br><sub>site: #{format_val(dealer.site)}</sub>"
      res += "<br><sub>цвет: #{format_dealer_preset_val(dealer)}</sub>"
      res.html_safe
    end

    # private

    def format_val(val)
      res = '-'
      unless val.blank?
        res = val
      end
      "<span class='c80_md_link_color'>#{res}</span>".html_safe
    end

    def format_dealer_preset_val(dealer)
      res = '-'
      if dealer.presets.count > 0
        p = dealer.presets.first
        res = format_preset_val(p)
      end
      res.html_safe
    end

    def format_preset_val(preset)
      "<span class='dealer_preset_span' style='background-color:#{preset.color}'></span>"
    end

  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
c80_push-0.1.0.11 app/helpers/c80_push/admin_helper.rb
c80_push-0.1.0.10 app/helpers/c80_push/admin_helper.rb
c80_push-0.1.0.8 app/helpers/c80_push/admin_helper.rb
c80_push-0.1.0.7 app/helpers/c80_push/admin_helper.rb
c80_push-0.1.0.6 app/helpers/c80_push/admin_helper.rb
c80_push-0.1.0.5 app/helpers/c80_push/admin_helper.rb
c80_push-0.1.0.4 app/helpers/c80_push/admin_helper.rb
c80_push-0.1.0.3 app/helpers/c80_push/admin_helper.rb