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
This commit is contained in:
Go MAEDA
2020-10-25 00:01:14 +00:00
parent d57674962a
commit 74d4d86a14
14 changed files with 40 additions and 32 deletions

View File

@@ -1045,11 +1045,15 @@ $(function () {
function inlineAutoComplete(element) {
'use strict';
// do not attach if Tribute is already initialized
if (element.dataset.tribute === 'true') {return;}
const issuesUrl = element.dataset.issuesUrl;
const usersUrl = element.dataset.usersUrl;
// do not attach if Tribute is already initialized
if (element.dataset.tribute === 'true') {return};
const getDataSource = function(entity) {
const dataSources = JSON.parse(rm.AutoComplete.dataSources);
return dataSources[entity];
}
const remoteSearch = function(url, cb) {
const xhr = new XMLHttpRequest();
@@ -1074,7 +1078,7 @@ function inlineAutoComplete(element) {
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);
});
},