2014-12-09 13:10:36 +01:00
|
|
|
require 'digest/md5'
|
2014-11-06 14:46:59 +01:00
|
|
|
module ApplicationHelper
|
2014-12-09 13:10:36 +01:00
|
|
|
|
|
|
|
def get_color(user)
|
|
|
|
@color = Digest::MD5.hexdigest(user.name)[0..5]
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_inverted_color(user)
|
|
|
|
@inverted_color = Digest::MD5.hexdigest(user.name)[0..5].reverse
|
|
|
|
end
|
|
|
|
|
|
|
|
def get_color_style(user)
|
|
|
|
@style = "background-color: #"+ get_color(user) +"; color: #"+
|
|
|
|
get_inverted_color(user)+ ";"
|
|
|
|
end
|
|
|
|
|
2014-12-09 14:39:27 +01:00
|
|
|
def euro(f)
|
|
|
|
"€#{number_with_precision f, precision: 2}"
|
|
|
|
end
|
|
|
|
|
2014-12-09 11:38:10 +01:00
|
|
|
#tijdelijk voor layout
|
|
|
|
def koelkast(status)
|
|
|
|
@koelkast ||= status
|
|
|
|
end
|
|
|
|
|
2014-12-09 14:39:27 +01:00
|
|
|
# Form helpers
|
|
|
|
def form_errors(object)
|
|
|
|
render partial: "form_errors", locals: {object: object}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_text_field(f, tag)
|
|
|
|
render partial: "form_text_field", locals: {f: f, tag: tag}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_password_field(f, tag)
|
|
|
|
render partial: "form_password_field", locals: {f: f, tag: tag}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_text_area(f, tag)
|
|
|
|
render partial: "form_text_area", locals: {f: f, tag: tag}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_fancy_text_area(f, tag)
|
|
|
|
render partial: "form_fancy_text_area", locals: {f: f, tag: tag}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_email_field(f, tag)
|
|
|
|
render partial: "form_email_field", locals: {f: f, tag: tag}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_date_field(f, tag, id, value)
|
|
|
|
render partial: "form_date_field", locals: {f: f, tag: tag, id: id, value: value}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_number_field(f, tag)
|
|
|
|
render partial: "form_number_field", locals: {f: f, tag: tag}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_collection_select(f, *args)
|
|
|
|
# This line enable passing optional arguments such as include_blank to the
|
|
|
|
# partial. If nothing is passed, an empty options hash is appended.
|
|
|
|
args << {} if args.length < 5
|
|
|
|
|
|
|
|
render partial: "form_collection_select", locals: {f: f, args: args}
|
|
|
|
end
|
|
|
|
|
|
|
|
def form_check_box(f, tag)
|
|
|
|
render partial: "form_check_box", locals: {f: f, tag: tag}
|
|
|
|
end
|
2014-12-09 13:10:36 +01:00
|
|
|
|
2014-11-06 14:46:59 +01:00
|
|
|
end
|