adds project_id arg to 'log time' link to preselect the current project, if any.

This commit is contained in:
Jens Kraemer
2021-10-05 11:25:38 +08:00
parent a2096e3208
commit b4af7e0eb3
2 changed files with 6 additions and 1 deletions

View File

@@ -6,6 +6,7 @@
<% if User.current.logged? %> <% if User.current.logged? %>
window.stopwatch.highlightRunningTimer( window.stopwatch.highlightRunningTimer(
<%= raw Stopwatch::Timer.new(User.current).to_json %> <%= raw Stopwatch::Timer.new(User.current).to_json %>
) );
window.stopwatch.setProjectId('<%= j @project&.id.to_s %>');
<% end %> <% end %>
<% end %> <% end %>

View File

@@ -75,6 +75,10 @@ window.initStopwatch = function(config){
time_entry_id: entryId, time_entry_id: entryId,
time_spent: spentTime time_spent: spentTime
}); });
},
setProjectId: function(projectId){
var a = $('a#stopwatch-menu');
a.attr('href', a.attr('href').replace(/\/new.*$/, '/new?project_id='+projectId));
} }
}); });
}; };