Module: AdminHelper
- Includes:
- Pagy::Frontend
- Defined in:
- app/helpers/admin_helper.rb
Overview
typed: ignore
Instance Method Summary collapse
-
#dynamic_pricings_formatter(package) ⇒ Object
This is for UI on admin restaurant package management page localhost:3000/admin/restaurants/xxx/restaurant_packages.
- #link_to_admin_reservations_path_by_id(reservation_id, label = nil, css_class = nil) ⇒ Object
- #link_to_admin_restaurants_path_by_id(restaurant_id, label = nil, css_class = nil) ⇒ Object
- #link_to_log(request_uuid, label = nil) ⇒ Object
-
#optional_locales ⇒ Object
Returns locales excluding required translations (EN and TH) Uses MyLocaleManager::REQUIRED_TRANSLATIONS as the source of truth.
-
#optional_locales_with_labels ⇒ Object
Returns locale information with human-readable labels Useful for rendering translation fields.
- #staff_signed_in? ⇒ Boolean
Instance Method Details
#dynamic_pricings_formatter(package) ⇒ Object
This is for UI on admin restaurant package management page localhost:3000/admin/restaurants/xxx/restaurant_packages
8 9 10 11 12 13 |
# File 'app/helpers/admin_helper.rb', line 8 def dynamic_pricings_formatter(package) pricing_formats = package.dynamic_pricings.map do |pricing| HhMoney.new(pricing.price_cents, pricing.price_currency).default_format end "#{package.dynamic_price_pricing_model} - #{package.dynamic_price_dynamic_pricing_type}: #{pricing_formats.join(', ')}" end |
#link_to_admin_reservations_path_by_id(reservation_id, label = nil, css_class = nil) ⇒ Object
21 22 23 24 25 26 |
# File 'app/helpers/admin_helper.rb', line 21 def link_to_admin_reservations_path_by_id(reservation_id, label = nil, css_class = nil) label = reservation_id if label.blank? # http://localhost:3000/admin/reservations?queries%5Bid%5D=4875610 link_to label, admin_reservations_path(queries: { id: reservation_id }, locale: I18n.locale), class: css_class end |
#link_to_admin_restaurants_path_by_id(restaurant_id, label = nil, css_class = nil) ⇒ Object
28 29 30 31 32 |
# File 'app/helpers/admin_helper.rb', line 28 def link_to_admin_restaurants_path_by_id(restaurant_id, label = nil, css_class = nil) label = restaurant_id if label.blank? link_to label, admin_restaurants_path(q: { name_like: restaurant_id }, locale: I18n.locale), class: css_class end |
#link_to_log(request_uuid, label = nil) ⇒ Object
15 16 17 18 19 |
# File 'app/helpers/admin_helper.rb', line 15 def link_to_log(request_uuid, label = nil) label = "Log: #{request_uuid}" if label.blank? link = "https://logs.hungryhub.com/app/discover#/?_g=(filters:!(),refreshInterval:(pause:!t,value:0),time:(from:now-20m,to:now))&_a=(columns:!(_source),filters:!(),index:d6a2eff0-a07e-11ee-9925-0323ed948260,interval:auto,query:(language:kuery,query:'custom_payload.request_id%20:%20%22#{request_uuid}%22%20'),sort:!())" link_to label, link end |
#optional_locales ⇒ Object
Returns locales excluding required translations (EN and TH) Uses MyLocaleManager::REQUIRED_TRANSLATIONS as the source of truth
90 91 92 |
# File 'app/helpers/admin_helper.rb', line 90 def optional_locales MyLocaleManager::AVAILABLE_LOCALES.reject { |locale| MyLocaleManager::REQUIRED_TRANSLATIONS.include?(locale) } end |
#optional_locales_with_labels ⇒ Object
Returns locale information with human-readable labels Useful for rendering translation fields
96 97 98 99 100 101 102 103 104 |
# File 'app/helpers/admin_helper.rb', line 96 def optional_locales_with_labels human_names = MyLocaleManager.new.human_names optional_locales.map do |locale| { code: locale.to_s, label: human_names[locale], } end end |
#staff_signed_in? ⇒ Boolean
34 35 36 |
# File 'app/helpers/admin_helper.rb', line 34 def staff_signed_in? user_signed_in? && current_user.provider.to_s == 'google_oauth2' end |