Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
  • 2 commits
  • 10 files changed
  • 0 commit comments
  • 1 contributor
Commits on Jan 25, 2012
Marc Jeanson When a pomodoro is running, add the ability to reset the timer. This …
…marks the current pomodoro as a reset pomodoro (failed).
33cee73
Marc Jeanson Merge branch 'features/008/pomodoro_reset' 237d2a4
View
6 app/assets/javascripts/activities.js.coffee
@@ -27,3 +27,9 @@ window.pomodoro_timer = (activity_id, pomodoro_id, time_in_seconds) ->
$.ajax
url: '/activities/' + activity_id + '/pomodoros/' + pomodoro_id + '/complete.js'
type: 'PUT'
+
+window.reset_pomodoro_timer = (time_in_seconds) ->
+ $("#reset_timer").html ""
+ $("#timer").resetTimer
+ time_in_seconds: time_in_seconds
+ autostart: false
View
5 app/controllers/pomodoros_controller.rb
@@ -11,6 +11,11 @@ def complete
@pomodoro.complete!
end
+ def reset
+ @pomodoro = @activity.pomodoros.find(params[:id])
+ @pomodoro.reset!
+ end
+
private
def find_activity
@activity = Activity.find params[:activity_id]
View
4 app/models/pomodoro.rb
@@ -6,4 +6,8 @@ class Pomodoro < ActiveRecord::Base
def complete!
self.update_attribute :completed_at, Time.now
end
+
+ def reset!
+ self.update_attribute :reset_at, Time.now
+ end
end
View
1  app/views/activities/_reset_link.html.slim
@@ -0,0 +1 @@
+= link_to t('navigation.reset_pomodoro'), reset_activity_pomodoro_path(activity_id: activity_id, id: pomodoro_id), remote: true, method: :put
View
3  app/views/layouts/_timer.html.slim
@@ -1 +1,4 @@
div id="timer"
+div id="reset_timer"
+ - if @pomodoro
+ == render 'activities/reset_link', locals: { activity_id: @pomodoro.activity.id, pomodoro_id: @pomodoro.id }
View
1  app/views/pomodoros/complete.js.coffee
@@ -0,0 +1 @@
+$("#reset_timer").html ""
View
1  app/views/pomodoros/create.js.coffee
@@ -1 +1,2 @@
pomodoro_timer(<%= @activity.id %>, <%= @pomodoro.id %>, 1500)
+$("#reset_timer").html "<%= escape_javascript(render partial: 'activities/reset_link', locals: { activity_id: @pomodoro.activity.id, pomodoro_id: @pomodoro.id }) %>"
View
1  app/views/pomodoros/reset.js.coffee
@@ -0,0 +1 @@
+reset_pomodoro_timer(1500)
View
1  config/locales/en.yml
@@ -7,6 +7,7 @@ en:
edit_activity: "Edit"
delete_activity: "Delete"
start_pomodoro: "Start"
+ reset_pomodoro: "Reset"
flash:
notices:
activity_created: "The Activity was created"
View
1  config/routes.rb
@@ -4,6 +4,7 @@
resources :pomodoros do
member do
put 'complete'
+ put 'reset'
end
end
end

No commit comments for this range

Something went wrong with that request. Please try again.