You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

_form.html.erb 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <%= error_messages_for 'time_entry' %>
  2. <%= back_url_hidden_field_tag %>
  3. <div class="box tabular">
  4. <% if @time_entry.new_record? && params[:project_id] %>
  5. <%= hidden_field_tag 'project_id', params[:project_id] %>
  6. <% elsif @time_entry.new_record? && params[:issue_id] %>
  7. <%= hidden_field_tag 'issue_id', params[:issue_id] %>
  8. <% else %>
  9. <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>
  10. <% end %>
  11. <p>
  12. <%= f.text_field :issue_id, :size => 6, :required => Setting.timelog_required_fields.include?('issue_id') %>
  13. <span id="time_entry_issue">
  14. <%= link_to_issue(@time_entry.issue) if @time_entry.issue.try(:visible?) %>
  15. </span>
  16. </p>
  17. <% if User.current.allowed_to?(:log_time_for_other_users, @project) %>
  18. <p><%= f.select :user_id, user_collection_for_select_options(@time_entry), :required => true %></p>
  19. <% end %>
  20. <p><%= f.date_field :spent_on, :size => 10, :required => true %><%= calendar_for('time_entry_spent_on') %></p>
  21. <p><%= f.hours_field :hours, :size => 6, :required => true %></p>
  22. <p><%= f.text_field :comments, :size => 100, :maxlength => 1024, :required => Setting.timelog_required_fields.include?('comments') %></p>
  23. <p><%= f.select :activity_id, activity_collection_for_select_options(@time_entry), :required => true %></p>
  24. <% @time_entry.custom_field_values.each do |value| %>
  25. <p><%= custom_field_tag_with_label :time_entry, value %></p>
  26. <% end %>
  27. <%= call_hook(:view_timelog_edit_form_bottom, { :time_entry => @time_entry, :form => f }) %>
  28. </div>
  29. <%= javascript_tag do %>
  30. $(document).ready(function(){
  31. $('#time_entry_project_id').change(function(){
  32. $('#time_entry_issue_id').val('');
  33. });
  34. $('#time_entry_project_id, #time_entry_issue_id').change(function(){
  35. $.ajax({
  36. url: '<%= escape_javascript(@time_entry.new_record? ? new_time_entry_path(:format => 'js') : edit_time_entry_path(:format => 'js')) %>',
  37. type: 'post',
  38. data: $(this).closest('form').serialize()
  39. });
  40. });
  41. });
  42. observeAutocompleteField('time_entry_issue_id',
  43. function(request, callback) {
  44. var url = '<%= j auto_complete_issues_path %>';
  45. var data = {
  46. term: request.term
  47. };
  48. var project_id;
  49. <% if @time_entry.new_record? && @project %>
  50. project_id = '<%= @project.id %>';
  51. <% else %>
  52. project_id = $('#time_entry_project_id').val();
  53. <% end %>
  54. if(project_id){
  55. data['project_id'] = project_id;
  56. } else {
  57. data['scope'] = 'all';
  58. }
  59. $.get(url, data, null, 'json')
  60. .done(function(data){
  61. callback(data);
  62. })
  63. .fail(function(jqXHR, status, error){
  64. callback([]);
  65. });
  66. },
  67. {
  68. select: function(event, ui) {
  69. $('#time_entry_issue').text('');
  70. $('#time_entry_issue_id').val(ui.item.value).change();
  71. }
  72. }
  73. );
  74. <% end %>