Class: BulkTimeEntriesController

Inherits:
ApplicationController
  • Object
show all
Includes:
BulkTimeEntriesHelper
Defined in:
app/controllers/bulk_time_entries_controller.rb

Instance Method Summary collapse

Methods included from BulkTimeEntriesHelper

#get_issues, #grouped_options_for_issues, #label_for_field, #labeled_option_group_from_collection_for_select

Instance Method Details

#add_entryObject



48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'app/controllers/bulk_time_entries_controller.rb', line 48

def add_entry
  begin
    spent_on = Date.parse(params[:date])
  rescue ArgumentError
    # Fall through
  end
  spent_on ||= today_with_time_zone
  
  @time_entry = TimeEntry.new(:spent_on => spent_on.to_s)
  respond_to do |format|
    format.js {}
  end
end

#indexObject



15
16
17
# File 'app/controllers/bulk_time_entries_controller.rb', line 15

def index
  @time_entries = [TimeEntry.new(:spent_on => today_with_time_zone.to_s)]
end

#load_assigned_issuesObject



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

def load_assigned_issues
  @issues = get_issues(params[:project_id])
  @selected_project = BulkTimeEntriesController.allowed_project?(params[:project_id])
  respond_to do |format|
    format.js {}
  end
end

#saveObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'app/controllers/bulk_time_entries_controller.rb', line 28

def save
  if request.post? 
    @unsaved_entries = {}
    @saved_entries = {}

    params[:time_entries].each_pair do |html_id, entry|
      time_entry = TimeEntry.create_bulk_time_entry(entry)
      if time_entry.new_record?
        @unsaved_entries[html_id] = time_entry
      else
        @saved_entries[html_id] = time_entry
      end
    end
    
    respond_to do |format|
      format.js {}
    end
  end
end