Module: PickItemsHelper

Defined in:
app/helpers/pick_items_helper.rb

Overview

View helper: pick items.

Instance Method Summary collapse

Instance Method Details

#global_quick_actions(itemizable) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/helpers/pick_items_helper.rb', line 42

def global_quick_actions(itemizable)
  return unless itemizable.respond_to?(:room_configurations)

  global_quick_actions = []
  locked_rooms = itemizable.room_configurations.select(&:editing_locked?)
  locked_rooms_count = locked_rooms.size
  return unless locked_rooms_count.positive?

  global_quick_actions << fa_icon('gear', text: pluralize(locked_rooms_count, 'Room Actions'))
  if locked_rooms.all? { |rc| rc.installation_plan_image.present? }
    global_quick_actions << link_to('Revise all locked rooms - keep plans',
                              quick_revise_all_rooms_pick_items_path(itemizable.class.name.foreign_key => itemizable.id, keep_plan: true),
                              class: 'dropdown_item',
                              data: { controller: 'ui-blocker', turbo_confirm: "Are you sure? This will affect #{locked_rooms_count} rooms.", turbo_method: :put })
  end
  global_quick_actions << link_to('Revise all locked rooms - skip plans',
                            quick_revise_all_rooms_pick_items_path(itemizable.class.name.foreign_key => itemizable.id, keep_plan: false),
                            class: 'dropdown_item',
                            data: { controller: 'ui-blocker', turbo_confirm: "Are you sure? This will affect #{locked_rooms_count} rooms.", turbo_method: :put })
  render_simple_drop_down(global_quick_actions, { class: 'float-end' })
end

#group_locked?(group) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'app/helpers/pick_items_helper.rb', line 18

def group_locked?(group)
  (group.respond_to?(:editing_locked?) && group.editing_locked?) || false
end

#group_name(group) ⇒ Object



14
15
16
# File 'app/helpers/pick_items_helper.rb', line 14

def group_name(group)
  group.try(:name_with_room) || group.to_s
end

#line_item_name(li_fields) ⇒ Object



8
9
10
11
12
# File 'app/helpers/pick_items_helper.rb', line 8

def line_item_name(li_fields)
  name = li_fields.object.name
  name += " (#{li_fields.object.item.amps} amps)" if add_amps_to_name && name.downcase.index('amps').nil?
  name
end

#pick_item_add_button(catalog_item, options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/helpers/pick_items_helper.rb', line 22

def pick_item_add_button(catalog_item, options = {})
  button_tag type: 'button', class: 'btn btn-outline-primary btn-block picker_add',
                 data: {
                   action: 'click->pick-items#addItem',
                   'catalog-item-id': catalog_item.catalog_item_id,
                   sku: catalog_item.item_sku,
                   name: catalog_item.item_name,
                   split: options[:split],
                   'bs-toggle': 'tooltip',
                   placement: 'left',
                   title: ( options[:split] ? "Adds the item as a new line" : ''),
                   'product-category': catalog_item.product_category_name,
                   'single-qty-item': Item::SINGLE_QUANTITY_SKUS.include?(catalog_item.item_sku) || nil
                 } do
    label = options[:label] == false ? nil : (options[:label] || 'Add')

    fa_icon(options[:icon_type] || "plus-circle", text: label)
  end
end

#underscore(item_category) ⇒ Object



4
5
6
# File 'app/helpers/pick_items_helper.rb', line 4

def underscore(item_category)
  item_category.tr(' ', '_').downcase
end