mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-04-02 09:51:57 -04:00
'Start/Stop tracking' on issues#show
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
<%= javascript_tag do %>
|
||||
window.stopwatch = window.initStopwatch({
|
||||
currentTimerUrl: '<%= j current_stopwatch_timers_url %>',
|
||||
hourFormat: '<%= j format_hours 0.0 %>'
|
||||
hourFormat: '<%= j format_hours 0.0 %>',
|
||||
locales: {
|
||||
startTimer: '<%= j l :label_stopwatch_start %>',
|
||||
stopTimer: '<%= j l :label_stopwatch_stop %>'
|
||||
},
|
||||
});
|
||||
<% if User.current.logged? %>
|
||||
window.stopwatch.highlightRunningTimer(
|
||||
|
||||
20
app/views/stopwatch_issue_timers/_new.html.erb
Normal file
20
app/views/stopwatch_issue_timers/_new.html.erb
Normal file
@@ -0,0 +1,20 @@
|
||||
<h3 class="title"><%= l(:button_log_time) %> - <%= format_date User.current.today %> - <%= "#{@issue.tracker} #{@issue.id}: #{truncate @issue.subject}" %></h3>
|
||||
|
||||
<%= labelled_form_for @time_entry, url: stopwatch_timers_path, method: :post, remote: true do |f| %>
|
||||
<% @time_entry.hours ||= 0 %>
|
||||
<%= f.hidden_field :issue_id, value: @issue.id %>
|
||||
|
||||
<fieldset class="box tabular">
|
||||
<legend><%= t 'stopwatch_timers.entry_form.legend_new' %></legend>
|
||||
<p><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %></p>
|
||||
<p><%= f.text_field :comments, :size => 100, :maxlength => 1024, :required => Setting.timelog_required_fields.include?('comments') %></p>
|
||||
<% @time_entry.custom_field_values.each do |value| %>
|
||||
<p><%= custom_field_tag_with_label :time_entry, value %></p>
|
||||
<% end %>
|
||||
</fieldset>
|
||||
|
||||
<p class="buttons">
|
||||
<%= submit_tag l(:button_create) %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
8
app/views/stopwatch_issue_timers/start.js.erb
Normal file
8
app/views/stopwatch_issue_timers/start.js.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<% if @started_time_entry %>
|
||||
window.stopwatch.timerStarted(
|
||||
<%= raw Stopwatch::Timer.new(User.current).to_json %>
|
||||
);
|
||||
<% else %>
|
||||
$('#ajax-modal').html('<%= j render partial: 'new' %>');
|
||||
showModal('ajax-modal', '700px');
|
||||
<% end %>
|
||||
5
app/views/stopwatch_issue_timers/stop.js.erb
Normal file
5
app/views/stopwatch_issue_timers/stop.js.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
window.stopwatch.updateStartStopLink(
|
||||
'#stopwatch_stop_timer_<%= @issue.id %>',
|
||||
'<%= j Stopwatch::IssueLinks.new(@issue).start_timer %>'
|
||||
);
|
||||
window.stopwatch.timerStopped();
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
@@ -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) %>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
hideModal();
|
||||
window.stopwatch.highlightRunningTimer(
|
||||
window.stopwatch.timerStarted(
|
||||
<%= raw Stopwatch::Timer.new(User.current).to_json %>
|
||||
);
|
||||
|
||||
|
||||
@@ -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 %>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user