Module: HrLite::ApplicationHelper
- Defined in:
- app/helpers/hr_lite/application_helper.rb
Constant Summary collapse
- NAV_ITEMS =
[ { label: "Home", path: :root_path, match: [ "/" ] }, { label: "Attendance", path: :attendance_path, match: [ "/attendance" ] }, { label: "Leaves", path: :leave_requests_path, match: [ "/leave_requests", "/leave_balances" ] }, { label: "Calendar", path: :calendar_path, match: [ "/calendar", "/holidays" ] }, { label: "Kudos", path: :kudos_path, match: [ "/kudos" ] }, { label: "Slips", path: :salary_slips_path, match: [ "/salary_slips" ] }, { label: "Career", path: :career_path, match: [ "/career", "/appraisals", "/profile" ] } ].freeze
- ADMIN_NAV_ITEMS =
[ { label: "Overview", path: :admin_overview_path, match: [ "/admin/overview" ] }, { label: "Team attendance", path: :admin_attendances_path, match: [ "/admin/attendances" ] }, { label: "Approvals", path: :admin_leave_requests_path, match: [ "/admin/leave_requests", "/admin/leave_balances" ] } ].freeze
- LEADERSHIP_NAV_ITEMS =
[ { label: "Employees", path: :admin_employees_path, match: [ "/admin/employees" ] }, { label: "Payroll", path: :admin_payroll_runs_path, match: [ "/admin/payroll_runs", "/admin/salary_slips" ] }, { label: "Settings", path: :admin_leave_types_path, match: [ "/admin/leave_types", "/admin/office_locations", "/admin/holidays", "/admin/setting" ] }, { label: "Audit", path: :admin_audit_logs_path, match: [ "/admin/audit_logs" ] } ].freeze
Instance Method Summary collapse
- #hr_lite_route?(helper_name) ⇒ Boolean
-
#hrl_amount_in_words(amount) ⇒ Object
Indian-system amount in words for the slip footer.
- #hrl_money(amount) ⇒ Object
-
#hrl_nav_items(items) ⇒ Object
Only items whose routes exist yet (the nav grows with each phase).
- #hrl_nav_link(item) ⇒ Object
- #hrl_pagination ⇒ Object
-
#render_kudo_message(kudo) ⇒ Object
Mention-marker-aware, XSS-safe kudos message rendering.
Instance Method Details
#hr_lite_route?(helper_name) ⇒ Boolean
31 32 33 |
# File 'app/helpers/hr_lite/application_helper.rb', line 31 def hr_lite_route?(helper_name) hr_lite.respond_to?(helper_name) end |
#hrl_amount_in_words(amount) ⇒ Object
Indian-system amount in words for the slip footer. Delegates to the PORO so host-rendered templates (config.render_pdf) work too.
85 86 87 |
# File 'app/helpers/hr_lite/application_helper.rb', line 85 def hrl_amount_in_words(amount) HrLite::AmountInWords.words(amount) end |
#hrl_money(amount) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'app/helpers/hr_lite/application_helper.rb', line 68 def hrl_money(amount) return "—" if amount.nil? whole, fraction = HrLite::Money.round2(amount).to_s("F").split(".") sign = whole.start_with?("-") ? "-" : "" whole = whole.delete_prefix("-") # Indian digit grouping: last three digits together, then pairs # (12,34,567 — not the western 1,234,567). if whole.length > 3 head = whole[0..-4].reverse.scan(/\d{1,2}/).join(",").reverse whole = "#{head},#{whole[-3..]}" end "#{sign}#{HrLite.config.currency_symbol}#{whole}.#{fraction.ljust(2, '0')}" end |
#hrl_nav_items(items) ⇒ Object
Only items whose routes exist yet (the nav grows with each phase).
27 28 29 |
# File 'app/helpers/hr_lite/application_helper.rb', line 27 def hrl_nav_items(items) items.select { |item| hr_lite_route?(item[:path]) } end |
#hrl_nav_link(item) ⇒ Object
35 36 37 38 39 40 41 |
# File 'app/helpers/hr_lite/application_helper.rb', line 35 def hrl_nav_link(item) href = hr_lite.public_send(item[:path]) active = item[:match].any? do |prefix| prefix == "/" ? request.path == href : request.path.start_with?("#{hr_lite.root_path.chomp('/')}#{prefix}") end link_to item[:label], href, class: "hrl-nav__link #{'hrl-nav__link--active' if active}" end |
#hrl_pagination ⇒ Object
64 65 66 |
# File 'app/helpers/hr_lite/application_helper.rb', line 64 def hrl_pagination render "hr_lite/shared/pagination" end |
#render_kudo_message(kudo) ⇒ Object
Mention-marker-aware, XSS-safe kudos message rendering. Every literal chunk is escaped; only markers whose id has a mention row become highlighted chips (with the CURRENT display name — stale-name safe).
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'app/helpers/hr_lite/application_helper.rb', line 46 def (kudo) mentioned = kudo.kudo_mentions.index_by(&:user_id) out = +"" rest = kudo..to_s while (m = HrLite::MentionParser::MARKER.match(rest)) out << ERB::Util.html_escape(m.pre_match) mention = mentioned[m[2].to_i] if mention out << %(<span class="hrl-mention">@#{ERB::Util.html_escape(HrLite.display_name(mention.user))}</span>) else out << ERB::Util.html_escape("@#{m[1]}") end rest = m.post_match end out << ERB::Util.html_escape(rest) out.html_safe end |