fixes various UI issues

This commit is contained in:
Jens Kraemer
2025-06-24 15:48:03 +08:00
parent 3c709b1329
commit 8e34eb627c
4 changed files with 12 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
contextMenuHide(); contextMenuHide();
window.stopwatch.updateStartStopLink( window.stopwatch.updateStartStopLink(
'#stopwatch_stop_timer_<%= @issue.id %>', '#stopwatch_stop_timer_<%= @issue.id %>',
'<%= j Stopwatch::IssueLinks.new(@issue).start_timer %>' '<%= j Stopwatch::IssueLinks.new(@issue, self).start_timer %>'
); );
window.stopwatch.timerStopped(); window.stopwatch.timerStopped();

View File

@@ -74,7 +74,7 @@ window.initStopwatch = function(config){
$('a.stopwatch_issue_timer').each(function(){ $('a.stopwatch_issue_timer').each(function(){
var a = $(this); var a = $(this);
a.attr('href', a.attr('href').replace(/stop$/, 'start')); a.attr('href', a.attr('href').replace(/stop$/, 'start'));
a.text(locales.startTimer); a.find('span').text(locales.startTimer);
}); });
}, },
timerStarted: function(data){ timerStarted: function(data){
@@ -94,10 +94,10 @@ window.initStopwatch = function(config){
if(data.issue_id) { if(data.issue_id) {
if(a.data('issueId') == data.issue_id) { if(a.data('issueId') == data.issue_id) {
a.attr('href', href.replace(/start$/, 'stop')); a.attr('href', href.replace(/start$/, 'stop'));
a.text(locales.stopTimer); a.find('span').text(locales.stopTimer);
} else { } else {
a.attr('href', href.replace(/stop$/, 'start')); a.attr('href', href.replace(/stop$/, 'start'));
a.text(locales.startTimer); a.find('span').text(locales.startTimer);
} }
} }
}); });

View File

@@ -4,7 +4,7 @@ module Stopwatch
context.link_to( context.link_to(
context.sprite_icon(:time, I18n.t(:label_stopwatch_start)), context.sprite_icon(:time, I18n.t(:label_stopwatch_start)),
context.start_issue_timer_path(issue), context.start_issue_timer_path(issue),
class: 'stopwatch_issue_timer', class: 'icon stopwatch_issue_timer',
data: { issue_id: issue.id }, data: { issue_id: issue.id },
remote: true, remote: true,
method: 'post' method: 'post'
@@ -15,7 +15,7 @@ module Stopwatch
context.link_to( context.link_to(
context.sprite_icon(:time, I18n.t(:label_stopwatch_stop)), context.sprite_icon(:time, I18n.t(:label_stopwatch_stop)),
context.stop_issue_timer_path(issue), context.stop_issue_timer_path(issue),
class: 'stopwatch_issue_timer', class: 'icon stopwatch_issue_timer',
data: { issue_id: issue.id }, data: { issue_id: issue.id },
remote: true, remote: true,
method: 'post' method: 'post'

View File

@@ -1,4 +1,4 @@
require File.expand_path('../../test_helper', __FILE__) require File.expand_path('../test_helper', __dir__)
class TicketTimerTest < Redmine::IntegrationTest class TicketTimerTest < Redmine::IntegrationTest
include ActiveJob::TestHelper include ActiveJob::TestHelper
@@ -30,6 +30,7 @@ class TicketTimerTest < Redmine::IntegrationTest
assert_not_running assert_not_running
get "/issues/1" get "/issues/1"
assert_response :success
assert_select "div.contextual a", text: /start tracking/i assert_select "div.contextual a", text: /start tracking/i
assert_no_difference ->{TimeEntry.count} do assert_no_difference ->{TimeEntry.count} do
post "/issues/1/timer/start", xhr: true post "/issues/1/timer/start", xhr: true
@@ -77,7 +78,7 @@ class TicketTimerTest < Redmine::IntegrationTest
TimeEntry.delete_all TimeEntry.delete_all
assert_no_difference ->{TimeEntry.count} do assert_no_difference ->{TimeEntry.count} do
post "/issues/1/timer/start", xhr: true post "/issues/1/timer/start", xhr: true
assert_response 200 assert_response :ok
end end
end end
@@ -86,7 +87,7 @@ class TicketTimerTest < Redmine::IntegrationTest
TimeEntry.delete_all TimeEntry.delete_all
with_settings plugin_stopwatch: { 'default_activity' => 'system'} do with_settings plugin_stopwatch: { 'default_activity' => 'system'} do
post "/issues/1/timer/start", xhr: true post "/issues/1/timer/start", xhr: true
assert_response 201 assert_response :created
end end
assert te = TimeEntry.last assert te = TimeEntry.last
assert_equal 1, te.issue_id assert_equal 1, te.issue_id
@@ -98,18 +99,17 @@ class TicketTimerTest < Redmine::IntegrationTest
TimeEntry.delete_all TimeEntry.delete_all
with_settings plugin_stopwatch: { 'default_activity' => '9'} do with_settings plugin_stopwatch: { 'default_activity' => '9'} do
post "/issues/1/timer/start", xhr: true post "/issues/1/timer/start", xhr: true
assert_response 201 assert_response :created
end end
assert te = TimeEntry.last assert te = TimeEntry.last
assert_equal 1, te.issue_id assert_equal 1, te.issue_id
assert_equal 9, te.activity_id assert_equal 9, te.activity_id
end end
private private
def assert_not_running def assert_not_running
refute Stopwatch::Timer.new(User.find(@user.id)).running? assert_not Stopwatch::Timer.new(User.find(@user.id)).running?
end end
def assert_running def assert_running