From 74d4d86a14cd683de9a70ffcae6db79344cdef2d Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Sun, 25 Oct 2020 00:01:14 +0000 Subject: Store inline autocomplete data sources in a JS variable (#34122). Patch by Marius BALTEANU. git-svn-id: http://svn.redmine.org/redmine/trunk@20191 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/helpers/application_helper.rb | 16 ++++++++++++++++ app/helpers/custom_fields_helper.rb | 8 +++----- 2 files changed, 19 insertions(+), 5 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5a0868c2e..dd4a4f195 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1741,6 +1741,22 @@ module ApplicationHelper 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 diff --git a/app/helpers/custom_fields_helper.rb b/app/helpers/custom_fields_helper.rb index 1e0c1b07e..41b20c46a 100644 --- a/app/helpers/custom_fields_helper.rb +++ b/app/helpers/custom_fields_helper.rb @@ -84,9 +84,8 @@ module CustomFieldsHelper 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, @@ -133,8 +132,7 @@ module CustomFieldsHelper 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( -- cgit v1.2.3