Module: PolicyManager::ApplicationHelper
- Defined in:
- app/helpers/policy_manager/application_helper.rb
Instance Method Summary collapse
- #bootstrap_class_for(flash_type) ⇒ Object
- #chart(data) ⇒ Object
- #flash_messages(opts = {}) ⇒ Object
- #gravatar_url(user, size) ⇒ Object
- #state_color(state) ⇒ Object
Instance Method Details
#bootstrap_class_for(flash_type) ⇒ Object
4 5 6 |
# File 'app/helpers/policy_manager/application_helper.rb', line 4 def bootstrap_class_for flash_type { success: "alert-success", error: "alert-danger", alert: "alert-warning", notice: "alert-info" }[flash_type.to_sym] || flash_type.to_s end |
#chart(data) ⇒ Object
38 39 40 41 42 43 44 |
# File 'app/helpers/policy_manager/application_helper.rb', line 38 def chart(data) begin column_chart(data.call) rescue Groupdate::Error content_tag(:p, "chart not displayed, Be sure to install time zone support - https://github.com/ankane/groupdate#for-mysql", class: "alert alert-danger") end end |
#flash_messages(opts = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/policy_manager/application_helper.rb', line 8 def (opts = {}) flash.each do |msg_type, | flash.delete(msg_type) concat(content_tag(:div, , class: "alert #{bootstrap_class_for(msg_type)}") do concat content_tag(:button, "<i class='fa fa-times-circle'></i>".html_safe, class: "close", data: { dismiss: 'alert' }) concat end) end session.delete(:flash) nil end |
#gravatar_url(user, size) ⇒ Object
33 34 35 36 |
# File 'app/helpers/policy_manager/application_helper.rb', line 33 def gravatar_url(user, size) gravatar_id = Digest::MD5.hexdigest(user.email.downcase) "http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}" end |
#state_color(state) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/policy_manager/application_helper.rb', line 22 def state_color(state) case state when "pending", "draft" return "tag-yellow" when "progress" return "tag-azure" when "completed", "published" return "tag-green" end end |