Module: LogsHelper
- Defined in:
- app/helpers/logs_helper.rb
Instance Method Summary collapse
- #account_select_tag(selected_account = nil) ⇒ Object
- #cell(value) ⇒ Object
- #link_to_edit_or_show(str, month) ⇒ Object
- #make_income_expense_data(account) ⇒ Object
- #make_moves_data ⇒ Object
- #select_cell(acc = nil) ⇒ Object
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 account_select_tag(selected_account=nil) = (@accounts, 'id', 'name', selected_account.try(:id)) select_tag "", "<option value='_none_'>--</option>" + 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 |
#link_to_edit_or_show(str, month) ⇒ Object
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(account) items = account.expenses.all(in_month) + account.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_data ⇒ Object
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 account_select_tag(acc) else "<div>#{h acc.name if acc}</div>" end end |