Skip to content

Commit

Permalink
closes #46: merged and updated ionixjunior contributions
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Kranz committed Jul 10, 2013
1 parent 7a9378a commit 2d942a0
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/controllers/time_trackers_controller.rb
Expand Up @@ -68,6 +68,7 @@ def stop
unless params[:time_tracker].nil?
@time_tracker.issue_text = params[:time_tracker][:issue_text]
@time_tracker.comments = params[:time_tracker][:comments]
@time_tracker.activity_id = params[:time_tracker][:activity_id]
end
@time_tracker.stop
flash[:error] = l(:stop_time_tracker_error) unless @time_tracker.destroyed?
Expand Down
1 change: 1 addition & 0 deletions app/controllers/tt_overview_controller.rb
Expand Up @@ -14,6 +14,7 @@ class TtOverviewController < ApplicationController
include TimeTrackersHelper

def index
@enumerations = Enumeration.where("type = ? AND active = ?", "TimeEntryActivity", "t").all
@time_tracker = get_current_time_tracker

@limit = 15 # limit for both lists
Expand Down
3 changes: 1 addition & 2 deletions app/models/time_log.rb
Expand Up @@ -87,8 +87,7 @@ def initialize(arguments = nil, *args)
# if issue is the only parameter we get, we will book the whole time to one issue
# method returns the booking.id if transaction was successfully completed, raises an error otherwise
def add_booking(args = {})
tea = TimeEntryActivity.find_or_create_by_name(:name => :time_tracker_activity, :active => false)
default_args = {:started_on => self.started_on, :stopped_at => self.stopped_at, :comments => self.comments, :activity_id => tea.id, :issue => nil, :spent_time => nil, :project_id => self.project_id}
default_args = {:started_on => self.started_on, :stopped_at => self.stopped_at, :comments => self.comments, :activity_id => args[:activity_id], :issue => nil, :spent_time => nil, :project_id => self.project_id}
args = default_args.merge(args)

# TODO check time boundaries
Expand Down
3 changes: 2 additions & 1 deletion app/models/time_tracker.rb
@@ -1,6 +1,7 @@
class TimeTracker < ActiveRecord::Base
unloadable

attr_accessible :comments, :issue_id, :project_id, :start_time, :date, :round, :activity_id
attr_accessible :comments, :issue_id, :issue_text, :project_id, :start_time, :date, :round
attr_accessor :start_time, :date

Expand Down Expand Up @@ -127,7 +128,7 @@ def stop
# if there already is a ticket-nr then we automatically associate the timeLog and the issue using a timeBooking-entry
# and creating a time_entry
issue = help.issue_from_id(issue_id)
time_log.add_booking({:project_id => project_id, :issue => issue}) unless issue.nil? && project_id.nil?
time_log.add_booking({:project_id => project_id, :issue => issue, :activity_id => activity_id}) unless issue.nil? && project_id.nil?
# after creating the TimeLog we can remove the TimeTracker, so the user can start a new one
# print an error-message otherwise
self.destroy if time_log.save
Expand Down
10 changes: 10 additions & 0 deletions app/views/time_trackers/_time_tracker_control.html.erb
Expand Up @@ -44,6 +44,16 @@
<div class="task_form_input"><%= select_tag :project_id_select, proj_list, :onchange => "$('#time_tracker_project_id').val(this.value); updateTTControllerForm(this.form);", :disabled => (@time_tracker.permission_level < 2 || !@time_tracker.issue_id.nil?) %></div>
<%= f.hidden_field :project_id %>
</div>
<div class="task_form_sub_fields">
<div class="input_hint"><%= l(:time_tracker_label_activity) %></div>
<div class="task_form_input">
<select id="time_tracker_activity_id" name="time_tracker[activity_id]">
<% @enumerations.each do |enumeration| %>
<option value="<%= enumeration.id %>"><%= enumeration.name %></option>
<% end %>
</select>
</div>
</div>
<div class="task_form_sub_fields">
<!-- TODO refactor conditions for disabling the Time-Inputs to use special Role-settings instead of admin only -->
<div class="input_hint"><%= l(:time_tracker_label_start_time) %></div>
Expand Down
1 change: 1 addition & 0 deletions config/locales/de.yml
Expand Up @@ -92,6 +92,7 @@ de:
time_tracker_label_project: "Projekt"
time_tracker_label_round: "gerundete Zeitwerte"
time_tracker_label_running_time: "aktuell laufende Zeiterfassung"
time_tracker_label_activity: "Aktivität"
time_tracker_label_show_all_my_logs: "zeige vollständig gebuchte Zeiterfassungen"
time_tracker_label_start_date: "Startdatum"
time_tracker_label_start_time: "Startzeit"
Expand Down
1 change: 1 addition & 0 deletions config/locales/en.yml
Expand Up @@ -91,6 +91,7 @@ en:
time_tracker_label_project: "Project"
time_tracker_label_round: "Round Time"
time_tracker_label_running_time: "Running Time"
time_tracker_label_activity: "Activity"
time_tracker_label_show_all_my_logs: "Show fully booked TimeLogs"
time_tracker_label_start_date: "Start date"
time_tracker_label_start_time: "Start time"
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/012_add_tt_activity.rb
Expand Up @@ -8,6 +8,6 @@ def down
tea = TimeEntryActivity.where(:name => :time_tracker_activity).first
TimeEntryActivity.destroy(tea.id) unless tea.nil?
rescue
Rails.logger.info "Can't delete the TimeEntryActivity. There are still redmine activities with this booked."
Rails.logger.info "Can't delete the TimeEntryActivity. There are still redmine activities booked with this."
end
end
9 changes: 9 additions & 0 deletions db/migrate/017_add_activity_support.rb
@@ -0,0 +1,9 @@
class AddActivitySupport < ActiveRecord::Migration
def self.up
add_column :time_trackers, :activity_id, :integer
end

def self.down
remove_column :time_trackers, :activity_id
end
end
13 changes: 13 additions & 0 deletions db/migrate/018_remove_tt_activity.rb
@@ -0,0 +1,13 @@
class RemoveTtActivity < ActiveRecord::Migration
def up
tea = TimeEntryActivity.where(:name => :time_tracker_activity).first
TimeEntryActivity.destroy(tea.id) unless tea.nil?
rescue
Rails.logger.info "Can't delete the TimeEntryActivity. There are still redmine activities booked with this."
end

def down
tea = TimeEntryActivity.where(:name => :time_tracker_activity).first
TimeEntryActivity.create(:name => :time_tracker_activity, :active => true) if tea.nil?
end
end

0 comments on commit 2d942a0

Please sign in to comment.