Module: MailyHerald::Webui::ApplicationHelper
- Includes:
- Breadcrumbs::HelperExtensions
- Defined in:
- app/helpers/maily_herald/webui/application_helper.rb
Instance Method Summary collapse
- #boolean_icon(value, options = {}) ⇒ Object
- #content_for_expert ⇒ Object
- #display_context_attributes(attributes) ⇒ Object
- #display_help_icon(title, options = {}) ⇒ Object
- #filter_box(field_name = :filter) ⇒ Object
- #form_for(object, options = {}, &block) ⇒ Object
- #friendly_name(obj) ⇒ Object
- #icon(icon, text = "", html_options = {}) ⇒ Object
- #link_to_context_attributes_overview(list, options = {}) ⇒ Object
- #render_breadcrumbs ⇒ Object
- #render_context_attributes_info(list) ⇒ Object
- #render_main_menu ⇒ Object
- #smart_listing_config_profile ⇒ Object
- #tw(key, options = {}) ⇒ Object
- #work_mode_t(mode) ⇒ Object
Methods included from Breadcrumbs::HelperExtensions
Instance Method Details
#boolean_icon(value, options = {}) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 112 def boolean_icon value, = {} = { :style => :check, :text => :active, }.merge() i = case [:style] when :check value ? "check-square-o" : "square-o" when :toggle value ? "toggle-on" : "toggle-off" end text = case [:text] when :active value ? tw("commons.active") : tw("commons.inactive") when :enabled value ? tw("commons.enabled") : tw("commons.disabled") when :yes value ? tw("commons.positive") : tw("commons.negative") end icon(i, text) end |
#content_for_expert ⇒ Object
69 70 71 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 69 def content_for_expert yield if expert_mode? end |
#display_context_attributes(attributes) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 54 def display_context_attributes attributes content_tag(:ul) do attributes.each do |k, v| if v.is_a?(Hash) concat(content_tag(:li) do concat(k) concat(display_context_attributes(v)) end) else concat(content_tag(:li, k)) end end end end |
#display_help_icon(title, options = {}) ⇒ Object
137 138 139 140 141 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 137 def display_help_icon title, = {} link_to "#", class: "link link-help", data: {toggle: "tooltip", placement: [:placement] || "right"}, title: ([:scope] ? tw("#{options[:scope]}.help.#{title}") : t(".help.#{title}")) do icon(:question) end end |
#filter_box(field_name = :filter) ⇒ Object
143 144 145 146 147 148 149 150 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 143 def filter_box field_name = :filter content_tag(:div, class: "filter filter-search") do concat(text_field_tag(field_name, params[field_name], class: "search form-control", placeholder: "Search...", autocomplete: "off")) concat((class: "btn", type: "submit") do icon(:search) end) end end |
#form_for(object, options = {}, &block) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 86 def form_for(object, = {}, &block) .reverse_merge!({builder: MailyHerald::Webui::FormBuilder}) layout = case [:layout] when :inline "form-inline" when :horizontal "form-horizontal" end if layout [:html] ||= {} [:html][:class] = [[:html][:class], layout].compact.join(" ") end super(object, , &block) end |
#friendly_name(obj) ⇒ Object
81 82 83 84 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 81 def friendly_name obj return unless obj obj.respond_to?(:title) && obj.title.present? ? obj.title : obj.try(:name) end |
#icon(icon, text = "", html_options = {}) ⇒ Object
102 103 104 105 106 107 108 109 110 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 102 def icon(icon, text="", ={}) content_class = "fa fa-#{icon}" content_class << " #{html_options[:class]}" if .key?(:class) [:class] = content_class html = content_tag(:i, nil, ) html << " #{text}" unless text.blank? html.html_safe end |
#link_to_context_attributes_overview(list, options = {}) ⇒ Object
43 44 45 46 47 48 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 43 def link_to_context_attributes_overview list, = {} link_to context_variables_list_path(id: list, context: list.context_name), data: {toggle: "modal", target: "#modal-generic"}, class: ["link link-help", [:class]] do html = concat(icon(:list)) html.concat(" ").concat(list.context_name) if [:text] end if list.try(:context_name) end |
#render_breadcrumbs ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 25 def if content_tag(:ul, :class => "breadcrumb") do .each do |b| unless .last == b concat(content_tag(:li) do concat(link_to(b[:name].is_a?(Symbol) ? tw(b[:name]) : b[:name], b[:url])) end) else concat(content_tag(:li, :class => "active") do concat(b[:name].is_a?(Symbol) ? tw(b[:name]) : b[:name]) end) end end end end end |
#render_context_attributes_info(list) ⇒ Object
50 51 52 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 50 def render_context_attributes_info list render partial: "maily_herald/webui/shared/context_attributes", locals: {list: list} end |
#render_main_menu ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 6 def content_tag(:ul, :class => "nav nav-main") do .items.each do |i| title = i[:title] || i[:name] title = tw(title) if title.is_a?(Symbol) url = i[:url] url = self.instance_eval(&url) if url.is_a?(Proc) classes = [] classes << "active" if == i[:name] concat(content_tag(:li, :class => classes) do concat(link_to(title, url)) end) end end end |
#smart_listing_config_profile ⇒ Object
152 153 154 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 152 def smart_listing_config_profile :maily_herald end |
#tw(key, options = {}) ⇒ Object
77 78 79 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 77 def tw(key, = {}) t(key, {scope: [:maily_herald, :webui]}.merge()) end |
#work_mode_t(mode) ⇒ Object
73 74 75 |
# File 'app/helpers/maily_herald/webui/application_helper.rb', line 73 def work_mode_t mode t(mode, {scope: [:maily_herald, :webui, :work_modes]}) end |