Module: Crm::CycleCountsHelper

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

Instance Method Summary collapse

Instance Method Details

#cycle_count_command_options(cycle_count = @cycle_count) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/helpers/crm/cycle_counts_helper.rb', line 2

def cycle_count_command_options(cycle_count = @cycle_count)
  [].tap do |opts|
    if cycle_count.draft?
      opts << link_to('Count Items', edit_count_cycle_count_path(cycle_count))
      opts << link_to('Edit Items', edit_items_cycle_count_path(cycle_count))
      opts << link_to('View Count', cycle_count_path(cycle_count))
      opts << link_to(cycle_count_path(cycle_count), data: { turbo_method: :delete, turbo_confirm: 'Are you sure?' }) do
                '<i class="fa-solid fa-trash-can me-1"></i>Delete'.html_safe
              end
    else
      opts << link_to('View Count', cycle_count_path(cycle_count))
    end
  end.compact
end

#cycle_count_status_badge(cycle_count) ⇒ Object



17
18
19
20
21
22
23
24
25
# File 'app/helpers/crm/cycle_counts_helper.rb', line 17

def cycle_count_status_badge(cycle_count)
  state_class = case cycle_count.state
                when 'draft' then 'bg-warning bg-opacity-10 text-warning'
                when 'processed' then 'bg-success bg-opacity-10 text-success'
                else 'bg-secondary bg-opacity-10 text-secondary'
                end

  tag.span(cycle_count.human_state_name, class: "badge #{state_class}")
end