Project

General

Profile

Feature #5840 » live_look_up_similar_issues.patch

Takenori TAKAKI, 2019-10-03 10:28

View differences:

app/views/issues/_form.html.erb
27 27

  
28 28
<% if @issue.safe_attribute? 'subject' %>
29 29
<p><%= f.text_field :subject, :size => 80, :maxlength => 255, :required => true %></p>
30
<% if @issue.new_record? %>
31
<div class="notice">
32
  <div id="similar_issues">
33
  </div>
34
</div>
35
<% end %>
30 36
<% end %>
31 37

  
32 38
<% if @issue.safe_attribute? 'description' %>
......
56 62
<% heads_for_wiki_formatter %>
57 63

  
58 64
<%= javascript_tag do %>
65
<% if @issue.new_record? %>
66
options = {
67
  response: function(e,ui){
68
    if(ui.content.length>0){
69
      $('#similar_issues').html('<%= l(:text_following_issues_might_be_similar) %>  <%= link_to_function l(:button_hide), "$('#similar_issues').html('');" %><ul></ul>');
70
      $.each(ui.content, function(index,elm) { $('#similar_issues ul').append('<li><a href=\"/issues/' + elm.id + '\">' + elm.label + '</li>'); });
71
    }else{
72
      $('#similar_issues').html('');
73
    }
74
  },
75
  open: function(e,ui){ $(".ui-autocomplete").hide(); }
76
}
77
observeAutocompleteField('issue_subject', '<%= "#{escape_javascript auto_complete_issues_path(:project_id => @issue.project, :scope => Setting.cross_project_subtasks, :status => @issue.closed? ? 'c' : 'o', :issue_id => @issue.id)}" %>', options);
78
<% end %>
59 79
$(document).ready(function(){
60 80
  $("#issue_tracker_id, #issue_status_id").each(function(){
61 81
    $(this).val($(this).find("option[selected=selected]").val());
62 82
  });
83
  <% if @issue.new_record? %>
84
  $("#issue_subject").keyup(function(){if($(this).val().length<2){$('#similar_issues').html('');}});
85
  $("#issue_subject").removeClass("autocomplete");
86
  <% end %>
63 87
});
64 88
<% end %>
config/locales/en.yml
1231 1231
  text_select_apply_tracker: "Select tracker"
1232 1232
  text_avatar_server_config_html: The current avatar server is <a href="%{url}">%{url}</a>. You can configure it in config/configuration.yml.
1233 1233
  text_no_subject: no subject
1234
  text_following_issues_might_be_similar: The following issues might be similar.
1234 1235

  
1235 1236

  
1236 1237
  default_role_manager: Manager
public/stylesheets/application.css
775 775

  
776 776
.tabular input, .tabular select {max-width:95%}
777 777
.tabular textarea {width:95%; resize:vertical;}
778
.tabular div.notice {padding-left: 180px}
778 779

  
779 780
.tabular label{
780 781
  font-weight: bold;
public/stylesheets/responsive.css
749 749
    width: auto;
750 750
    max-width: 95%;
751 751
  }
752
  .tabular div.notice {
753
    padding-left: 0
754
  }
752 755

  
753 756
  /* new issue form */
754 757
  #all_attributes p:first-child {
(5-5/5)