Module: MenusHelper
- Defined in:
- app/helpers/menus_helper.rb
Instance Method Summary collapse
- #icon_for_sidebar_menu(section) ⇒ Object
- #menu_assigned_topic_counter ⇒ Object
- #menu_requested_contact_training_topic ⇒ Object
- #menu_requested_training_topic ⇒ Object
- #remote_sidebar_menu(title, section) ⇒ Object
Instance Method Details
#icon_for_sidebar_menu(section) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'app/helpers/menus_helper.rb', line 64 def (section) { home: 'home', activities: 'file', articles: 'books', communications: 'envelope', customers: 'user', customers_training: 'file-certificate', quotes: 'qrcode', orders: 'box-usd', engineering: 'puzzle-piece', ap: 'donate', ar: 'hand-holding-usd', ledger: 'book-alt', hr_and_training: 'graduation-cap', items: 'tags', logistics: 'ship', marketing: 'megaphone', reports: 'file-chart-pie', tech: 'wrench', phone: 'phone', it: 'laptop' }[section.to_sym] || 'folder' end |
#menu_assigned_topic_counter ⇒ Object
2 3 4 5 6 |
# File 'app/helpers/menus_helper.rb', line 2 def if (assigned_topic_counter = @context_user.assigned_or_requested_employee_topics.size) > 0 content_tag(:span, assigned_topic_counter, class: 'ms-2 badge bg-primary').html_safe end end |
#menu_requested_contact_training_topic ⇒ Object
14 15 16 17 18 |
# File 'app/helpers/menus_helper.rb', line 14 def if (requested_training_counter = ContactTrainingTopic.where(state: 'requested').size) > 0 content_tag(:span, requested_training_counter, class: 'ms-2 badge bg-secondary').html_safe end end |
#menu_requested_training_topic ⇒ Object
8 9 10 11 12 |
# File 'app/helpers/menus_helper.rb', line 8 def if (requested_training_counter = EmployeeTopic.where(state: 'requested').size) > 0 content_tag(:span, requested_training_counter, class: 'ms-2 badge bg-secondary').html_safe end end |
#remote_sidebar_menu(title, section) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/menus_helper.rb', line 20 def (title, section) return unless section == :home || current_user.employee_record..nil? || current_user.employee_record..include?(section.to_s) id = "#{section}_section" load_url = (section: section, target: id) # Keep the existing <ul class="dropdown-menu"> as Bootstrap's dropdown # target so its `display: none` / `.show` mechanics are unchanged. The # <turbo-frame> wraps the *items* inside the <ul>, which lets us # re-fetch counts on every open by re-setting the frame's src. # Listening on show.bs.dropdown (instead of click) avoids re-fetching # when the toggle is clicked to *close* the dropdown. content_tag :li, class: 'list-group-item dropdown-item p-0 border-bottom' do content_tag :div, class: 'dropright submenu w-100 d-flex', data: { controller: 'sidebar-submenu', 'sidebar-submenu-url-value': load_url, action: 'show.bs.dropdown->sidebar-submenu#refresh' } do entry_title = fa_icon((section), class: 'fa-fw', text: title) concat link_to(entry_title.html_safe, load_url, class: 'dropdown-toggle dropdown-item w-100 px-3', data: { 'bs-toggle': 'dropdown' }) concat content_tag(:ul, class: 'list-group-flush dropdown-menu p-0 submenu') { # target="_top" so menu items (e.g. "USA Customers to Lead # Qualify") perform full-page Turbo navigation instead of # trying to load the destination page inside this frame. A # specific link can opt back in to in-frame loading with # data-turbo-frame="<frame id>" if ever needed. turbo_frame_tag(id, target: '_top', data: { 'sidebar-submenu-target': 'frame' }) { content_tag(:li, fa_icon('spinner', class: 'fa-spin fa-lg', text: 'Loading...'), class: 'list-group-item dropdown-item') } } end end end |