end
end
+ def autocomplete_data_sources(project)
+ {
+ issues: auto_complete_issues_path(:project_id => project, :q => '')
+ }
+ end
+
+ def heads_for_auto_complete(project)
+ data_sources = autocomplete_data_sources(project)
+
+ javascript_tag(
+ "rm = window.rm || {};" +
+ "rm.AutoComplete = rm.AutoComplete || {};" +
+ "rm.AutoComplete.dataSources = '#{data_sources.to_json}';"
+ )
+ end
+
private
def wiki_helper
if custom_value.custom_field.full_text_formatting?
css += ' wiki-edit'
data = {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => custom_value.customized.project, :q => '')
- } if custom_value.customized&.try(:project)
+ :auto_complete => true
+ }
end
custom_value.custom_field.format.edit_tag(
self,
if custom_field.full_text_formatting?
css += ' wiki-edit'
data = {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:q => '')
+ :auto_complete => true
}
end
custom_field.format.bulk_edit_tag(
<p><%= f.text_field :title, :required => true, :size => 60 %></p>
<p><%= f.text_area :description, :cols => 60, :rows => 15, :class => 'wiki-edit',
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @project, :q => '')
+ :auto_complete => true
}
%></p>
<fieldset><legend><%= l(:field_notes) %></legend>
<%= f.text_area :notes, :cols => 60, :rows => 10, :class => 'wiki-edit',
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @issue.project, :q => '')
+ :auto_complete => true
},
:no_label => true %>
<%= wikitoolbar_for 'issue_notes', preview_issue_path(:project_id => @project, :issue_id => @issue) %>
:rows => [[10, @issue.description.to_s.length / 50].max, 20].min,
:data => {
:auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @issue.project, :q => '')
},
:no_label => true %>
<% end %>
<% end %>
<% heads_for_wiki_formatter %>
+<%= heads_for_auto_complete(@issue.project) %>
<%= javascript_tag do %>
$(document).ready(function(){
<legend><%= l(:field_notes) %></legend>
<%= text_area_tag 'notes', @notes, :cols => 60, :rows => 10, :class => 'wiki-edit',
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @project, :q => '')
+ :auto_complete => true
}
%>
<%= wikitoolbar_for 'notes' %>
<%= text_area_tag 'journal[notes]', @journal.notes, :id => "journal_#{@journal.id}_notes", :class => 'wiki-edit',
:rows => (@journal.notes.blank? ? 10 : [[10, @journal.notes.length / 50].max, 100].min),
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @project, :q => '')
+ :auto_complete => true
}
%>
<% if @journal.safe_attribute? 'private_notes' %>
<%= stylesheet_link_tag 'rtl', :media => 'all' if l(:direction) == 'rtl' %>
<%= javascript_heads %>
<%= heads_for_theme %>
+<%= heads_for_auto_complete(@project) %>
<%= call_hook :view_layouts_base_html_head %>
<!-- page specific tags -->
<%= yield :header_tags -%>
<div class="flyout-menu js-flyout-menu">
-
<% if User.current.logged? || !Setting.login_required? %>
<div class="flyout-menu__search">
<%= form_tag({:controller => 'search', :action => 'index', :id => @project}, :method => :get ) do %>
</label>
<%= text_field_tag 'q', @question, :size => 20, :class => 'small', :accesskey => accesskey(:quick_search),
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:q => '')
+ :auto_complete => true
} %>
<% end %>
<%= render_project_jump_box %>
<%= f.text_area :content, :cols => 80, :rows => 15, :class => 'wiki-edit', :id => 'message_content',
:accesskey => accesskey(:edit),
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @project, :q => '')
+ :auto_complete => true
}
%></p>
<%= wikitoolbar_for 'message_content', preview_board_message_path(:board_id => @board, :id => @message) %>
<p><%= f.text_area :summary, :cols => 60, :rows => 2 %></p>
<p><%= f.text_area :description, :required => true, :cols => 60, :rows => 15, :class => 'wiki-edit',
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @project, :q => '')
+ :auto_complete => true
}
%></p>
<p id="attachments_form"><label><%= l(:label_attachment_plural) %></label><%= render :partial => 'attachments/form', :locals => {:container => @news} %></p>
<div class="box">
<%= text_area 'comment', 'comments', :cols => 80, :rows => 15, :class => 'wiki-edit',
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @project, :q => '')
+ :auto_complete => true
}
%>
<%= wikitoolbar_for 'comment_comments', preview_news_path(:project_id => @project, :id => @news) %>
<%= label_tag "search-input", l(:description_search), :class => "hidden-for-sighted" %>
<p><%= text_field_tag 'q', @question, :size => 60, :id => 'search-input',
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:q => '')
+ :auto_complete => true
} %>
<%= project_select_tag %>
<%= hidden_field_tag 'all_words', '', :id => nil %>
<%= text_area_tag 'content[text]', @text, :cols => 100, :rows => 25, :accesskey => accesskey(:edit),
:class => 'wiki-edit',
:data => {
- :auto_complete => true,
- :issues_url => auto_complete_issues_path(:project_id => @project, :q => '')
+ :auto_complete => true
}
%>
function inlineAutoComplete(element) {
'use strict';
+
// do not attach if Tribute is already initialized
- if (element.dataset.tribute === 'true') {return;}
+ if (element.dataset.tribute === 'true') {return};
+
+ const getDataSource = function(entity) {
+ const dataSources = JSON.parse(rm.AutoComplete.dataSources);
- const issuesUrl = element.dataset.issuesUrl;
- const usersUrl = element.dataset.usersUrl;
+ return dataSources[entity];
+ }
const remoteSearch = function(url, cb) {
const xhr = new XMLHttpRequest();
if (event.target.type === 'text' && $(element).attr('autocomplete') != 'off') {
$(element).attr('autocomplete', 'off');
}
- remoteSearch(issuesUrl + text, function (issues) {
+ remoteSearch(getDataSource('issues') + text, function (issues) {
return cb(issues);
});
},