Module: Breeze::BreezeHelper

Includes:
OptionsHelper, SharedHelper
Included in:
ViewHelper
Defined in:
app/helpers/breeze/breeze_helper.rb

Instance Method Summary collapse

Methods included from SharedHelper

#markdown, #markdown_image, #prose_classes, #renderer, #rows

Methods included from OptionsHelper

#background_option, #column_option, #date_precision, #height_option, #item_align_option, #margin_option, #options, #order_option, #prose_option, #shade_option, #slider_columns_option, #text_align_option, #text_color_option, #text_columns_option

Instance Method Details

#aspect_ratio(image) ⇒ Object



14
15
16
17
# File 'app/helpers/breeze/breeze_helper.rb', line 14

def aspect_ratio image
  x , y = image.aspect_ratio
  "#{x} / #{y}"
end

#card_field_name(card) ⇒ Object



19
20
21
22
23
# File 'app/helpers/breeze/breeze_helper.rb', line 19

def card_field_name(card)
  name = card.header
  name += "*" unless card.option("compulsory") == "no"
  name
end

#last_change_classObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/breeze/breeze_helper.rb', line 34

def last_change_class
  digit = last_change_digit
  return "" if digit > 9
  digit = 9 - digit
  reds = { "1" => "bg-red-100","2" => "bg-red-200","3" => "bg-red-100",
           "4" => "bg-red-400","5" => "bg-red-500","6" => "bg-red-600",
           "7" => "bg-red-700","8" => "bg-red-600","9" => "bg-red-900"}

  clazz = reds[digit.to_s].to_s
  clazz += " " + "text-white" if digit > 7
  clazz
end

#last_change_digitObject



25
26
27
28
29
30
31
32
# File 'app/helpers/breeze/breeze_helper.rb', line 25

def last_change_digit
  last = ChangeSet.current.last
  return 10 unless last
  last = (Time.now - last).to_i
  return 9 if ( last >= 600 )
  digit =  last / 60
  digit
end

#last_change_textObject



47
48
49
50
51
# File 'app/helpers/breeze/breeze_helper.rb', line 47

def last_change_text
  digit = last_change_digit
  return "no change" if digit > 9
  "#{digit} min. by #{ChangeSet.current.last_editor}"
end

#updated_by(owner) ⇒ Object



7
8
9
10
11
12
13
# File 'app/helpers/breeze/breeze_helper.rb', line 7

def updated_by(owner)
  member = owner.updated_by
  return member if member.is_a? String
  return "" if member.nil?
  return member.name if member.respond_to? :name
  member.email
end