Fix pagination controls, move mixin to common app, fix pagination invocation on all views, and other random bug fixes

This commit is contained in:
badblocks 2025-04-01 23:01:05 -07:00
parent 7edefe23c3
commit 6a61b79bbe
425 changed files with 51656 additions and 243 deletions

View file

@ -0,0 +1,46 @@
'use strict';
{
const $ = django.jQuery;
const init = function ($element, options) {
options["width"] = "100%"
const settings = $.extend({
ajax: {
data: function (params) {
return {
term: params.term,
page: params.page,
filter_term: options.filter_term,
app_label: $element.data('app-label'),
model_name: $element.data('model-name'),
field_name: $element.data('field-name')
};
}
},
escapeMarkup: function (m) {
return m;
}
}, 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;
};
$(function () {
// Initialize all autocomplete widgets except the one in the template
// form used when a new formset is added.
$('.admin-autocomplete').not('[name*=__prefix__]').djangoAdminSelect2();
});
$(document).on('formset:added', (function () {
return function (event, $newFormset) {
return $newFormset.find('.admin-autocomplete').djangoAdminSelect2();
};
})(this));
}