Module: LogsHelper

Defined in:
app/helpers/logs_helper.rb

Instance Method Summary collapse

Instance Method Details

#account_select_tag(selected_account = nil) ⇒ Object



27
28
29
30
31
32
# File 'app/helpers/logs_helper.rb', line 27

def (=nil)
  options = options_from_collection_for_select(@accounts, 'id', 'name',
                                               .try(:id))
  select_tag "",
    "<option value='_none_'>--</option>" + options
end

#cell(value) ⇒ Object



11
12
13
14
15
16
17
# File 'app/helpers/logs_helper.rb', line 11

def cell(value)
  if @mode == :edit
    "<input type='text' value='#{h value}' />"
  else
    "<div>#{h value}</div>"
  end
end


3
4
5
6
7
8
9
# File 'app/helpers/logs_helper.rb', line 3

def link_to_edit_or_show(str, month)
  if @mode == :edit
    link_to_edit_logs str, month
  else
    link_to_show_logs str, month
  end
end

#make_income_expense_data(account) ⇒ Object



34
35
36
37
38
39
40
41
42
43
# File 'app/helpers/logs_helper.rb', line 34

def make_income_expense_data()
  items = .expenses.all(in_month) +
          .incomes.all(in_month)

  make_table_data(items) do |todays, i|
    @cat_all.map{|cat|
      todays.find{|m| m.category == cat && m.position == i}
    }
  end
end

#make_moves_dataObject



45
46
47
48
49
50
51
# File 'app/helpers/logs_helper.rb', line 45

def make_moves_data
  moves = Move.all(in_month)

  make_table_data(moves) do |todays, i|
    [todays.find{|m| m.position == i} || :no_move]
  end
end

#select_cell(acc = nil) ⇒ Object



19
20
21
22
23
24
25
# File 'app/helpers/logs_helper.rb', line 19

def select_cell(acc=nil)
  if @mode == :edit
    (acc)
  else
    "<div>#{h acc.name if acc}</div>"
  end
end