'Start/Stop tracking' on issues#show

This commit is contained in:
Jens Kraemer
2021-10-05 05:27:35 +08:00
parent bd6711a59f
commit 033e1739d2
22 changed files with 375 additions and 28 deletions

View File

@@ -4,8 +4,12 @@
<legend><%= t @time_entry.new_record? ? '.legend_new' : '.legend_edit' %></legend>
<p><label for="stopwatch_time_entry_project_id"><%= l :field_project %><span class="required"> *</span></label><%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).to_a, :selected => @time_entry.project, :include_blank => true), { no_label: true }, id: 'stopwatch_time_entry_project_id' %></p>
<p>
<%= f.text_field :issue_id, :size => 6, :required => Setting.timelog_required_fields.include?('issue_id') %>
<p><label for="stopwatch_time_entry_issue_id"><%= l :field_issue %>
<% if Setting.timelog_required_fields.include?('issue_id') %>
<span class="required"> *</span>
<% end %>
</label>
<%= f.text_field :issue_id, :size => 6, no_label: true, id: 'stopwatch_time_entry_issue_id' %>
<span id="stopwatch_time_entry_issue">
<%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>
</span>
@@ -24,10 +28,10 @@
<%= javascript_tag do %>
$(document).ready(function(){
$('#time_entry_project_id').change(function(){
$('#time_entry_issue_id').val('');
$('#stopwatch_time_entry_project_id').change(function(){
$('#stopwatch_time_entry_issue_id').val('');
});
$('#time_entry_project_id, #time_entry_issue_id').change(function(){
$('#stopwatch_time_entry_project_id, #stopwatch_time_entry_issue_id').change(function(){
$.ajax({
url: '<%= j update_form_stopwatch_timers_path(time_entry_id: @time_entry.id, format: 'js') %>',
type: 'post',
@@ -36,7 +40,7 @@
});
});
observeAutocompleteField('time_entry_issue_id',
observeAutocompleteField('stopwatch_time_entry_issue_id',
function(request, callback) {
var url = '<%= j auto_complete_issues_path %>';
var data = {
@@ -46,7 +50,7 @@
<% if @time_entry.new_record? && @project %>
project_id = '<%= @project.id %>';
<% else %>
project_id = $('#time_entry_project_id').val();
project_id = $('#stopwatch_time_entry_project_id').val();
<% end %>
if(project_id){
data['project_id'] = project_id;
@@ -64,8 +68,8 @@
},
{
select: function(event, ui) {
$('#time_entry_issue').text('');
$('#time_entry_issue_id').val(ui.item.value).change();
$('#stopwatch_time_entry_issue').text('');
$('#stopwatch_time_entry_issue_id').val(ui.item.value).change();
}
}
);

View File

@@ -1,10 +1,12 @@
<h3 class="title"><%= l(:button_log_time) %> - <%= format_date User.current.today %></h3>
<%= render partial: 'entries_list', locals: { entries: @entries } %>
<% if @entries %>
<%= render partial: 'stopwatch_timers/entries_list', locals: { entries: @entries } %>
<% end %>
<%= labelled_form_for @time_entry, url: stopwatch_timers_path, method: :post, remote: true do |f| %>
<% @time_entry.hours ||= 0 %>
<%= render partial: 'entry_form', locals: { f: f } %>
<%= render partial: 'stopwatch_timers/entry_form', locals: { f: f } %>
<p class="buttons">
<%= submit_tag l(:button_create) %>

View File

@@ -1,4 +1,5 @@
hideModal();
window.stopwatch.highlightRunningTimer(
window.stopwatch.timerStarted(
<%= raw Stopwatch::Timer.new(User.current).to_json %>
);

View File

@@ -7,9 +7,10 @@
<% end %>
<% if @started_time_entry %>
window.stopwatch.timerStarted('<%= @started_time_entry.id %>',
'<%= j format_hours @started_time_entry.hours %>');
window.stopwatch.timerStarted(
<%= raw Stopwatch::Timer.new(User.current).to_json %>
);
<% else %>
window.stopwatch.timerStopped();
window.stopwatch.timerStopped();
<% end %>