Module: Crm::CycleCountsHelper

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

Overview

View helper: cycle counts.

Instance Method Summary collapse

Instance Method Details

#cycle_count_command_options(cycle_count = @cycle_count) ⇒ Object



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

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
        fa_icon('trash-can', family: :solid, class: 'me-1') + 'Delete'
      end
    else
      opts << link_to('View Count', cycle_count_path(cycle_count))
    end
  end.compact
end

#cycle_count_status_badge(cycle_count) ⇒ Object



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

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