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