diff options
Diffstat (limited to 'app/helpers/application_helper.rb')
-rw-r--r-- | app/helpers/application_helper.rb | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0e3f56c2c..33798501a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1819,19 +1819,20 @@ module ApplicationHelper end end - def autocomplete_data_sources(project) - { - issues: auto_complete_issues_path(:project_id => project, :q => ''), - wiki_pages: auto_complete_wiki_pages_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}';" + "rm.AutoComplete.dataSources = JSON.parse('#{data_sources.to_json}');" + ) + end + + def update_data_sources_for_auto_complete(data_sources) + javascript_tag( + "const currentDataSources = rm.AutoComplete.dataSources;" \ + "const newDataSources = JSON.parse('#{data_sources.to_json}'); " \ + "rm.AutoComplete.dataSources = Object.assign(currentDataSources, newDataSources);" ) end @@ -1866,4 +1867,11 @@ module ApplicationHelper name = identifier.gsub(%r{^"(.*)"$}, "\\1") return CGI.unescapeHTML(name) end + + def autocomplete_data_sources(project) + { + issues: auto_complete_issues_path(project_id: project, q: ''), + wiki_pages: auto_complete_wiki_pages_path(project_id: project, q: ''), + } + end end |