Removed options parameter from djangoAdminSelect2.
It seems this parameter has never been used internally, so to avoid exposing a large surface area in the admin, remove it. As discussed in: https://groups.google.com/g/django-developers/c/G-fDkNxhxsE/m/--RtGwmtAQAJ
This commit is contained in:
parent
bbb3965826
commit
d54059ebce
|
@ -1,28 +1,22 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
{
|
{
|
||||||
const $ = django.jQuery;
|
const $ = django.jQuery;
|
||||||
const init = function($element, options) {
|
|
||||||
const settings = $.extend({
|
$.fn.djangoAdminSelect2 = function() {
|
||||||
|
$.each(this, function(i, element) {
|
||||||
|
$(element).select2({
|
||||||
ajax: {
|
ajax: {
|
||||||
data: function(params) {
|
data: (params) => {
|
||||||
return {
|
return {
|
||||||
term: params.term,
|
term: params.term,
|
||||||
page: params.page,
|
page: params.page,
|
||||||
app_label: $element.data('app-label'),
|
app_label: element.dataset.appLabel,
|
||||||
model_name: $element.data('model-name'),
|
model_name: element.dataset.modelName,
|
||||||
field_name: $element.data('field-name')
|
field_name: element.dataset.fieldName
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, options);
|
});
|
||||||
$element.select2(settings);
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.djangoAdminSelect2 = function(options) {
|
|
||||||
const settings = $.extend({}, options);
|
|
||||||
$.each(this, function(i, element) {
|
|
||||||
const $element = $(element);
|
|
||||||
init($element, settings);
|
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue