Module: EmployeeTopicsHelper
- Defined in:
- app/helpers/employee_topics_helper.rb
Instance Method Summary collapse
- #employee_topic_assign_selectable_header ⇒ Object
- #employee_topic_badge(state) ⇒ Object
- #employee_topic_badge_state_color(state) ⇒ Object
- #employee_topic_state_label(employee_topic) ⇒ Object
- #employee_topics_state_counters(topics, employee) ⇒ Object
-
#select_options_for_employee_topic(employee_topic) ⇒ Object
Assume topic passed is prefetched with party_topic filtered on the current employee.
- #topic_category_selectable_header(topic_category) ⇒ Object
Instance Method Details
#employee_topic_assign_selectable_header ⇒ Object
61 62 63 64 65 66 67 68 69 |
# File 'app/helpers/employee_topics_helper.rb', line 61 def employee_topic_assign_selectable_header content_tag(:div, class: 'checkbox') do content_tag(:label) do concat check_box_tag(:check_all, "1", false, data: { action: "change->check-all#toggle", selector: "input[type=checkbox]" }) concat content_tag(:span, 'Assign Training To', style: 'margin-left:0.5em') end end end |
#employee_topic_badge(state) ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'app/helpers/employee_topics_helper.rb', line 25 def employee_topic_badge(state) return unless state icon_map = { reviewed: { icon: 'thumbs-o-up', style: 'color: green' }, certified: { icon: 'certificate', style: 'color: gold' } } if badge_data = icon_map[state.to_sym] fa_icon(badge_data[:icon], style: badge_data[:style]) end end |
#employee_topic_badge_state_color(state) ⇒ Object
21 22 23 |
# File 'app/helpers/employee_topics_helper.rb', line 21 def employee_topic_badge_state_color(state) { 'requested' => 'primary', 'assigned' => 'warning', 'certified' => 'success'}[state] || 'default' end |
#employee_topic_state_label(employee_topic) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/helpers/employee_topics_helper.rb', line 36 def employee_topic_state_label(employee_topic) css_class = { assigned: :danger, reviewed: :info, certified: :success, cancelled: :default, requested: :warning }[employee_topic.state.to_sym] label_value = employee_topic.human_state_name.titleize if employee_topic.state.to_sym == :certified label_value = fa_icon('diploma', text: label_value) end content_tag(:span, label_value, class: "badge bg-#{css_class}") end |
#employee_topics_state_counters(topics, employee) ⇒ Object
16 17 18 19 |
# File 'app/helpers/employee_topics_helper.rb', line 16 def employee_topics_state_counters(topics, employee) topics.group_by{|t| t.employee_topics.where(employee: employee).first.try(:state) || 'unassigned' }.map{|state,topics| content_tag(:span, "#{state.titleize}: #{topics.size}", class: "badge bg-#{employee_topic_badge_state_color(state)}") }.join(' ').html_safe end |
#select_options_for_employee_topic(employee_topic) ⇒ Object
Assume topic passed is prefetched with party_topic filtered on the current employee
4 5 6 7 8 9 10 11 12 13 14 |
# File 'app/helpers/employee_topics_helper.rb', line 4 def (employee_topic) if employee_topic #State Flow check = employee_topic.possible_events_for_select #Permission check = .select{|o| can? o[1].to_sym, employee_topic } else = [['Assign', 'assign']] end end |
#topic_category_selectable_header(topic_category) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/employee_topics_helper.rb', line 51 def topic_category_selectable_header(topic_category) content_tag(:div, class: 'checkbox') do content_tag(:label) do concat check_box_tag(:check_all, "1", false, data: { action: "change->check-all#toggle", selector: "input[type=checkbox]" }) concat content_tag(:span, topic_category.to_s, class: 'ms-2') end end end |