Module: Crm::WarehousesHelper

Defined in:
app/helpers/crm/warehouses_helper.rb

Overview

View helpers for the CRM warehouse dashboard (Crm::WarehousesController),
covering stock status badges and tab-tracking for workflow return paths.

Instance Method Summary collapse

Instance Method Details

#warehouse_stock_status_label(order) ⇒ ActiveSupport::SafeBuffer

Renders a Bootstrap badge for an order's warehouse stock status.

Parameters:

  • order (Order)

    the order whose stock status is displayed

Returns:

  • (ActiveSupport::SafeBuffer)

    the badge markup



12
13
14
15
16
# File 'app/helpers/crm/warehouses_helper.rb', line 12

def warehouse_stock_status_label(order)
  s = order.stock_status
  style = s == :ok ? 'success' : 'warning'
  (:span, s, class: "badge bg-#{style}", style: 'font-size: 1em')
end

#warehouse_tab_idString?

Returns the tab id for the currently rendering warehouse tab action,
so workflow links can preserve the active tab in their return_path.

The warehouse dashboard tabs are member actions named tab_<id>
(for example tab_at_warehouse, tab_picking, tab_held_orders).
turbo_tabs reads ?tab=<id> from the URL and tab_panel uses the same
param to render the matching frame on first paint. Without this,
redirects back to /warehouses/:id land without ?tab= and the user
is dropped onto whatever tab happens to be first.

Returns:

  • (String, nil)

    the tab id, or nil when not on a tab action



29
30
31
32
33
# File 'app/helpers/crm/warehouses_helper.rb', line 29

def warehouse_tab_id
  return nil unless action_name.to_s.start_with?('tab_')

  action_name.to_s.sub(/\Atab_/, '')
end