Module: Crm::StorageLocationsHelper

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

Overview

View helpers for the CRM storage locations screens.

Instance Method Summary collapse

Instance Method Details

#storage_location_breadcrumb(storage_location = @storage_location) ⇒ String

Renders a breadcrumb trail of the location's zone/aisle/section/level/bin,
each crumb linking to the storage locations index filtered to that level.

Parameters:

  • storage_location (StorageLocation) (defaults to: @storage_location)

    location to render (defaults to @storage_location)

Returns:

  • (String)

    HTML-safe breadcrumb list items



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/helpers/crm/storage_locations_helper.rb', line 12

def storage_location_breadcrumb(storage_location = @storage_location)
  bc_array = []
  concatenated_filter = {}
  %i[zone aisle section level bin].each do |filter|
    location_val = storage_location.send(filter)
    location_val_formatted = storage_location.send(:"formatted_#{filter}")
    concatenated_filter["#{filter}_eq"] = location_val
    bc_array << tag.li(class: 'breadcrumb-item') do
      link_to "#{filter.to_s.humanize} #{location_val_formatted}", store_storage_locations_path(storage_location.store, q: concatenated_filter)
    end
  end
  bc_array.join.html_safe
end

#storage_location_reference(storage_location = @storage_location) ⇒ String

Renders the location's dot-joined reference (e.g. "A.01.02.03.04"), each
segment linking to the storage locations index filtered to that level.

Parameters:

  • storage_location (StorageLocation) (defaults to: @storage_location)

    location to render (defaults to @storage_location)

Returns:

  • (String)

    HTML-safe reference links joined by dots



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'app/helpers/crm/storage_locations_helper.rb', line 31

def storage_location_reference(storage_location = @storage_location)
  bc_array = []
  concatenated_filter = {}
  storage_location.index_fields.each do |filter|
    location_val = storage_location.send(filter)
    location_val_formatted = storage_location.send(:"formatted_#{filter}")
    concatenated_filter["#{filter}_eq"] = location_val
    bc_array << link_to(location_val_formatted,
                store_storage_locations_path(storage_location.store, q: concatenated_filter),
                title: filter.to_s.humanize,
                data: { 'bs-toggle': 'tooltip' },
                class: 'btn btn-link')
  end
  bc_array.join('.').html_safe
end