diff --git a/app/controllers/stopwatch_timers_controller.rb b/app/controllers/stopwatch_timers_controller.rb
index 84f0989..f7700ac 100644
--- a/app/controllers/stopwatch_timers_controller.rb
+++ b/app/controllers/stopwatch_timers_controller.rb
@@ -1,6 +1,8 @@
# weiter
#
+# - update title / menu item after starting new entry
# - update time entry row after context menu stop (reflect saved time)
+# - 0:60 anstelle 1:00? Redmine-bug?
#
# - remember last activity, preselect that in 'new' form
# - same for project, unless we are in a project context
@@ -39,8 +41,11 @@ class StopwatchTimersController < ApplicationController
end
def update
- # todo update entry
- if params[:continue]
+ @time_entry.safe_attributes = params[:time_entry]
+ @success = @time_entry.save
+ if !@success
+ edit
+ elsif params[:continue]
new
end
end
@@ -89,8 +94,12 @@ class StopwatchTimersController < ApplicationController
end
def new_time_entry
- TimeEntry.new(project: @project, issue: @issue,
- user: User.current, spent_on: User.current.today)
+ entry = TimeEntry.new(project: @project, issue: @issue,
+ user: User.current, spent_on: User.current.today)
+ if entry.respond_to?(:author=) # Redmine 4
+ entry.author = User.current
+ end
+ entry
end
def find_optional_data
diff --git a/app/views/stopwatch/hooks/_time_entries_context_menu_start.html.erb b/app/views/stopwatch/hooks/_time_entries_context_menu_start.html.erb
index 2080f94..9d972bb 100644
--- a/app/views/stopwatch/hooks/_time_entries_context_menu_start.html.erb
+++ b/app/views/stopwatch/hooks/_time_entries_context_menu_start.html.erb
@@ -2,9 +2,9 @@
<% time_entry = @time_entries.first %>
<% if User.current.is_running_timer? time_entry %>
- <%= context_menu_link l(:label_stopwatch_stop), stop_stopwatch_timer_path(time_entry, context: '1'), class: 'icon-time', remote: true, method: :put %>
+ <%= context_menu_link l(:label_stopwatch_stop), stop_stopwatch_timer_path(time_entry, context: '1'), class: 'icon icon-time', remote: true, method: :put %>
<% else %>
- <%= context_menu_link l(:label_stopwatch_start), start_stopwatch_timer_path(time_entry, context: '1'), class: 'icon-time', remote: true, method: :put %>
+ <%= context_menu_link l(:label_stopwatch_start), start_stopwatch_timer_path(time_entry, context: '1'), class: 'icon icon-time', remote: true, method: :put %>
<% end %>
<% end %>
diff --git a/app/views/stopwatch_timers/create.js.erb b/app/views/stopwatch_timers/create.js.erb
index f66581c..d494fc6 100644
--- a/app/views/stopwatch_timers/create.js.erb
+++ b/app/views/stopwatch_timers/create.js.erb
@@ -1 +1,4 @@
hideModal();
+window.stopwatch.highlightRunningTimer(
+ <%= raw Stopwatch::Timer.new(User.current).to_json %>
+);
diff --git a/app/views/stopwatch_timers/update.js.erb b/app/views/stopwatch_timers/update.js.erb
index 38dcbc6..4c3726c 100644
--- a/app/views/stopwatch_timers/update.js.erb
+++ b/app/views/stopwatch_timers/update.js.erb
@@ -1,5 +1,9 @@
-hideModal();
+<% if @success %>
+ hideModal();
+<% else %>
+ $('#ajax-modal').html('<%= j render partial: 'stopwatch_timers/edit' %>');
+<% end %>
<% if params[:continue] %>
$('#ajax-modal').html('<%= j render partial: 'stopwatch_timers/new' %>');
- showModal('ajax-modal', '600px');
+ showModal('ajax-modal', '700px');
<% end %>
diff --git a/lib/stopwatch.rb b/lib/stopwatch.rb
index 9e64f03..0b14ec8 100644
--- a/lib/stopwatch.rb
+++ b/lib/stopwatch.rb
@@ -1,3 +1,2 @@
module Stopwatch
-
end