Module: PickItemsHelper
- Defined in:
- app/helpers/pick_items_helper.rb
Instance Method Summary collapse
- #global_quick_actions(itemizable) ⇒ Object
- #group_locked?(group) ⇒ Boolean
- #group_name(group) ⇒ Object
- #line_item_name(li_fields) ⇒ Object
- #pick_item_add_button(catalog_item, options = {}) ⇒ Object
- #underscore(item_category) ⇒ Object
Instance Method Details
#global_quick_actions(itemizable) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'app/helpers/pick_items_helper.rb', line 40 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 if 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: 'block-ui-on-click dropdown_item', data: { 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: 'block-ui-on-click dropdown_item', data: { 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 end |
#group_locked?(group) ⇒ Boolean
16 17 18 |
# File 'app/helpers/pick_items_helper.rb', line 16 def group_locked?(group) (group.respond_to?(:editing_locked?) && group.editing_locked?) || false end |
#group_name(group) ⇒ Object
12 13 14 |
# File 'app/helpers/pick_items_helper.rb', line 12 def group_name(group) group.try(:name_with_room) || group.to_s end |
#line_item_name(li_fields) ⇒ Object
6 7 8 9 10 |
# File 'app/helpers/pick_items_helper.rb', line 6 def line_item_name(li_fields) name = li_fields.object.name name += " (#{li_fields.object.item.amps} amps)" if (add_amps_to_name and name.downcase.index('amps').nil?) name end |
#pick_item_add_button(catalog_item, options = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/helpers/pick_items_helper.rb', line 20 def (catalog_item, = {}) 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: [:split], 'bs-toggle': 'tooltip', placement: 'left', title: ( [: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 = [:label] == false ? nil : ( [:label] || 'Add' ) fa_icon( [:icon_type] || "plus-circle", text: label ) end end |
#underscore(item_category) ⇒ Object
2 3 4 |
# File 'app/helpers/pick_items_helper.rb', line 2 def underscore(item_category) item_category.gsub(/ /,'_').downcase end |