##// END OF EJS Templates
repositories: allow updating repository settings for users without store-in-root permissions...
repositories: allow updating repository settings for users without store-in-root permissions in case repository name didn't change. - when an user owns repository in root location, and isn't allow to create repositories in root before we failed to allow this user to update such repository settings due to this validation. We'll now check if name didn't change and in this case allow to update since this doesn't store any new data in root location.

File last commit:

r3706:9aa2b595 new-ui
r4415:fc1f6c1b default
Show More
select2_widgets.js
75 lines | 2.0 KiB | application/javascript | JavascriptLexer
/* COMMON */
var select2RefFilterResults = function(queryTerm, data) {
var filteredData = {results: []};
//filter results
$.each(data.results, function() {
var section = this.text;
var children = [];
$.each(this.children, function() {
if (queryTerm.length === 0 || this.text.toUpperCase().indexOf(queryTerm.toUpperCase()) >= 0) {
children.push(this);
}
});
if (children.length > 0) {
filteredData.results.push({
'text': section,
'children': children
});
}
});
return filteredData
};
var select2RefBaseSwitcher = function(targetElement, loadUrl, initialData){
var formatResult = function(result, container, query) {
return formatSelect2SelectionRefs(result);
};
var formatSelection = function(data, container) {
return formatSelect2SelectionRefs(data);
};
$(targetElement).select2({
cachedDataSource: {},
dropdownAutoWidth: true,
width: "resolve",
containerCssClass: "drop-menu",
dropdownCssClass: "drop-menu-dropdown",
query: function(query) {
var self = this;
var cacheKey = '__ALLREFS__';
var cachedData = self.cachedDataSource[cacheKey];
if (cachedData) {
var data = select2RefFilterResults(query.term, cachedData);
query.callback({results: data.results});
} else {
$.ajax({
url: loadUrl,
data: {},
dataType: 'json',
type: 'GET',
success: function(data) {
self.cachedDataSource[cacheKey] = data;
query.callback({results: data.results});
}
});
}
},
initSelection: function(element, callback) {
callback(initialData);
},
formatResult: formatResult,
formatSelection: formatSelection
});
};
/* WIDGETS */
var select2RefSwitcher = function(targetElement, initialData) {
var loadUrl = pyroutes.url('repo_refs_data',
{'repo_name': templateContext.repo_name});
select2RefBaseSwitcher(targetElement, loadUrl, initialData);
};