mirror of
https://github.com/rickbarrette/stopwatch.git
synced 2026-04-02 09:51:57 -04:00
works, basically
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
<h3 class="title"><%= l(:label_spent_time) %></h3>
|
||||
<h3 class="title"><%= l(:button_log_time) %> - <%= format_date User.current.today %></h3>
|
||||
|
||||
<%= labelled_form_for @time_entry, url: stopwatch_path, remote: true do |f| %>
|
||||
<% @time_entry.hours ||= 0 %>
|
||||
<%= render partial: 'timelog/form', locals: { f: f } %>
|
||||
<%= render partial: 'entries_list', locals: { entries: @entries } %>
|
||||
|
||||
<%= labelled_form_for @time_entry, url: stopwatch_timer_path(@time_entry), method: :put, remote: true do |f| %>
|
||||
<%= hidden_field_tag :time_entry_id, @time_entry.id %>
|
||||
<%= render partial: 'entry_form', locals: { f: f } %>
|
||||
|
||||
<p class="buttons">
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= submit_tag l(:button_cancel), name: nil, onclick: "hideModal(this);", type: 'button' %>
|
||||
<%= submit_tag l(:button_save) %>
|
||||
<%= submit_tag t('.button_save_and_continue'), name: 'continue' %>
|
||||
<%#= submit_tag l(:button_cancel), name: nil, onclick: "hideModal(this);", type: 'button' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
31
app/views/stopwatch_timers/_entries_list.html.erb
Normal file
31
app/views/stopwatch_timers/_entries_list.html.erb
Normal file
@@ -0,0 +1,31 @@
|
||||
<% if entries.any? %>
|
||||
<table class="list time-entries odd-even">
|
||||
<thead><tr>
|
||||
<th><%= l(:label_activity) %></th>
|
||||
<th><%= l(:label_project) %></th>
|
||||
<th><%= l(:field_comments) %></th>
|
||||
<th><%= l(:field_hours) %></th>
|
||||
<th></th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% for entry in entries %>
|
||||
<tr id="time-entry-<%= entry.id %>" class="time-entry <%= cycle "odd", "even" %>">
|
||||
<td class="activity"><%= entry.activity %></td>
|
||||
<td class="subject"><%= entry.project %> <%= h(' - ') + link_to_issue(entry.issue, truncate: 50) if entry.issue %></td>
|
||||
<td class="comments"><%= entry.comments %></td>
|
||||
<td class="hours"><%= html_hours(format_hours(entry.hours)) %></td>
|
||||
<td class="buttons">
|
||||
<% if User.current.is_running_timer?(entry) %>
|
||||
<%= link_to t(:label_stopwatch_stop), stop_stopwatch_timer_path(entry), remote: true, class: "icon-only icon-time", method: :put %>
|
||||
<% else %>
|
||||
<%= link_to t(:label_stopwatch_start), start_stopwatch_timer_path(entry), remote: true, class: "icon-only icon-time", method: :put %>
|
||||
<% end %>
|
||||
<%= link_to l(:button_edit), edit_stopwatch_timer_path(entry), remote: true, class: "icon-only icon-edit" if entry.editable_by? User.current %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end -%>
|
||||
</tbody>
|
||||
</table>
|
||||
<% end %>
|
||||
|
||||
|
||||
74
app/views/stopwatch_timers/_entry_form.html.erb
Normal file
74
app/views/stopwatch_timers/_entry_form.html.erb
Normal file
@@ -0,0 +1,74 @@
|
||||
<%= error_messages_for 'time_entry' %>
|
||||
|
||||
<fieldset class="box tabular">
|
||||
<legend><%= t @time_entry.new_record? ? '.legend_new' : '.legend_edit' %></legend>
|
||||
<p><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %></p>
|
||||
|
||||
<p><%= f.select :project_id, project_tree_options_for_select(Project.allowed_to(:log_time).to_a, :selected => @time_entry.project, :include_blank => true), :required => true %></p>
|
||||
|
||||
<p>
|
||||
<%= f.text_field :issue_id, :size => 6, :required => Setting.timelog_required_fields.include?('issue_id') %>
|
||||
<span id="time_entry_issue">
|
||||
<%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>
|
||||
</span>
|
||||
</p>
|
||||
<!--
|
||||
<p><%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
|
||||
-->
|
||||
<p><%= f.text_field :comments, :size => 100, :maxlength => 1024, :required => Setting.timelog_required_fields.include?('comments') %></p>
|
||||
<p><%= f.hours_field :hours, :size => 6, :required => true %></p>
|
||||
<% @time_entry.custom_field_values.each do |value| %>
|
||||
<p><%= custom_field_tag_with_label :time_entry, value %></p>
|
||||
<% end %>
|
||||
<%= call_hook(:view_timelog_edit_form_bottom, { :time_entry => @time_entry, :form => f }) %>
|
||||
</fieldset>
|
||||
|
||||
<%= javascript_tag do %>
|
||||
$(document).ready(function(){
|
||||
$('#time_entry_project_id').change(function(){
|
||||
$('#time_entry_issue_id').val('');
|
||||
});
|
||||
$('#time_entry_project_id, #time_entry_issue_id').change(function(){
|
||||
$.ajax({
|
||||
url: '<%= escape_javascript(@time_entry.new_record? ? new_time_entry_path(format: 'js') : edit_time_entry_path(@time_entry, format: 'js')) %>',
|
||||
type: 'post',
|
||||
data: $(this).closest('form').serialize()
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
observeAutocompleteField('time_entry_issue_id',
|
||||
function(request, callback) {
|
||||
var url = '<%= j auto_complete_issues_path %>';
|
||||
var data = {
|
||||
term: request.term
|
||||
};
|
||||
var project_id;
|
||||
<% if @time_entry.new_record? && @project %>
|
||||
project_id = '<%= @project.id %>';
|
||||
<% else %>
|
||||
project_id = $('#time_entry_project_id').val();
|
||||
<% end %>
|
||||
if(project_id){
|
||||
data['project_id'] = project_id;
|
||||
} else {
|
||||
data['scope'] = 'all';
|
||||
}
|
||||
|
||||
$.get(url, data, null, 'json')
|
||||
.done(function(data){
|
||||
callback(data);
|
||||
})
|
||||
.fail(function(jqXHR, status, error){
|
||||
callback([]);
|
||||
});
|
||||
},
|
||||
{
|
||||
select: function(event, ui) {
|
||||
$('#time_entry_issue').text('');
|
||||
$('#time_entry_issue_id').val(ui.item.value).change();
|
||||
}
|
||||
}
|
||||
);
|
||||
<% end %>
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
<h3 class="title"><%= l(:button_log_time) %></h3>
|
||||
<h3 class="title"><%= l(:button_log_time) %> - <%= format_date User.current.today %></h3>
|
||||
|
||||
<%= labelled_form_for @time_entry, url: stopwatch_timer_path, method: :post, remote: true do |f| %>
|
||||
<%= render partial: 'entries_list', locals: { entries: @entries } %>
|
||||
|
||||
<%= labelled_form_for @time_entry, url: stopwatch_timers_path, method: :post, remote: true do |f| %>
|
||||
<% @time_entry.hours ||= 0 %>
|
||||
<%= render partial: 'timelog/form', locals: { f: f } %>
|
||||
<%= render partial: 'entry_form', locals: { f: f } %>
|
||||
|
||||
<p class="buttons">
|
||||
<%= submit_tag l(:button_create) %>
|
||||
<%= submit_tag l(:button_cancel), name: nil, onclick: "hideModal(this);", type: 'button' %>
|
||||
<%#= submit_tag l(:button_cancel), name: nil, onclick: "hideModal(this);", type: 'button' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
|
||||
1
app/views/stopwatch_timers/create.js.erb
Normal file
1
app/views/stopwatch_timers/create.js.erb
Normal file
@@ -0,0 +1 @@
|
||||
hideModal();
|
||||
4
app/views/stopwatch_timers/edit.js.erb
Normal file
4
app/views/stopwatch_timers/edit.js.erb
Normal file
@@ -0,0 +1,4 @@
|
||||
hideModal();
|
||||
$('#ajax-modal').html('<%= j render partial: 'stopwatch_timers/edit' %>');
|
||||
showModal('ajax-modal', '700px');
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
$('#ajax-modal').html('<%= j render partial: 'stopwatch_timers/new' %>');
|
||||
showModal('ajax-modal', '600px');
|
||||
showModal('ajax-modal', '700px');
|
||||
|
||||
9
app/views/stopwatch_timers/start.js.erb
Normal file
9
app/views/stopwatch_timers/start.js.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<% if params[:context] %>
|
||||
contextMenuHide();
|
||||
<% else %>
|
||||
hideModal();
|
||||
$('#ajax-modal').html('<%= j render partial: 'new' %>');
|
||||
showModal('ajax-modal', '700px');
|
||||
<% end %>
|
||||
Stopwatch.highlightTimer('<%= @started_time_entry.id if @started_time_entry %>');
|
||||
|
||||
5
app/views/stopwatch_timers/update.js.erb
Normal file
5
app/views/stopwatch_timers/update.js.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
hideModal();
|
||||
<% if params[:continue] %>
|
||||
$('#ajax-modal').html('<%= j render partial: 'stopwatch_timers/new' %>');
|
||||
showModal('ajax-modal', '600px');
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user