0001-dynamically-build-the-autocomplete-url-294652.patch

Jens Krämer, 2016-10-28 10:06

Download (1.8 KB)

View differences:

app/views/timelog/_form.html.erb
40 40
  });
41 41
<% end %>
42 42

  
43
  observeAutocompleteField('time_entry_issue_id', '<%= escape_javascript auto_complete_issues_path(:project_id => @project, :scope => (@project ? nil : 'all'))%>', {
44
    select: function(event, ui) {
45
      $('#time_entry_issue').text(ui.item.label);
46
      $('#time_entry_issue_id').blur();
43
  observeAutocompleteField('time_entry_issue_id',
44
    function(request, callback) {
45
      var url = '<%= j auto_complete_issues_path %>';
46
      var data = {
47
        term: request.term
48
      };
49
      var project_id;
50
      <% if @project %>
51
        project_id = '<%= @project.id %>';
52
      <% else %>
53
        project_id = $('#time_entry_project_id').val();
54
      <% end %>
55
      if(project_id){
56
        data['project_id'] = project_id;
57
      } else {
58
        data['scope'] = 'all';
59
      }
60

  
61
      $.get(url, data, null, 'json')
62
        .done(function(data){
63
          callback(data);
64
        })
65
        .fail(function(jqXHR, status, error){
66
          callback([]);
67
        });
68
    },
69
    {
70
      select: function(event, ui) {
71
        $('#time_entry_issue').text(ui.item.label);
72
        $('#time_entry_issue_id').blur();
73
      }
47 74
    }
48
  });
75
  );
49 76
<% end %>
50
-