Skip to content

Commit 79fa94f

Browse files
authored
Merge pull request #11 from aksharahegde/select2-event
Select2 - Trigger native change event.
2 parents 25568af + d298386 commit 79fa94f

19 files changed

+35
-17
lines changed

README.rst

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Maintained by Akshara Hegde (Full-stack Developer)
77

88
**Modern template for Django-4 admin interface with improved functionality**
99

10+
**Upgraded to latest jQuery and jQuery-UI**
11+
1012
Django JET has two kinds of licenses: open-source (AGPLv3) and commercial. Please note that using AGPLv3
1113
code in your programs make them AGPL compatible too. So if you don't want to comply with that we can provide you a commercial
1214
license (visit Home page). The commercial license is designed for using Django JET in commercial products
@@ -54,9 +56,9 @@ Installation
5456

5557
.. code:: python
5658
57-
pip install git+https://github.com/aksharahegde/django-jet-3-calm.git#5.0.0
59+
pip install git+https://github.com/aksharahegde/django-jet-3-calm.git#<version>
5860
# or
59-
pip install git+https://github.com/aksharahegde/django-jet-3-calm.git@<version>
61+
pip install git+https://github.com/aksharahegde/django-jet-3-calm.git@<branch_name>
6062
6163
* Add 'jet' application to the INSTALLED_APPS setting of your Django project settings.py file (note it should be before 'django.contrib.admin'):
6264

jet/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = '5.1.1'
1+
VERSION = '5.1.2'

jet/static/jet/css/themes/blowhorn/base.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

jet/static/jet/css/themes/blowhorn/jquery-ui.theme.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

jet/static/jet/css/themes/blowhorn/select2.theme.css.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

jet/static/jet/css/themes/primary/base.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jet/static/jet/css/themes/primary/jquery-ui.theme.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jet/static/jet/css/themes/primary/select2.theme.css.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jet/static/jet/js/build/bundle.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jet/static/jet/js/src/features/selects.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,20 @@ Select2.prototype = {
121121
'</span>'
122122
);
123123

124-
var $element = this.$element;
124+
function addNativeEventTrigger(e) {
125+
if (window.document.documentMode) {
126+
// (IE doesnt support Event() constructor)
127+
// https://caniuse.com/?search=Event()
128+
var evt = document.createEvent('HTMLEvents');
129+
evt.initEvent('change', false, true);
130+
e.currentTarget.dispatchEvent(evt);
131+
} else {
132+
const event = new Event('change');
133+
e.currentTarget.dispatchEvent(event);
134+
}
135+
$(e.currentTarget).one('change', this.addNativeEventTrigger);
136+
}
137+
this.$element.one("change", addNativeEventTrigger);
125138

126139
$dropdown.find('.select2-buttons-button-select-all').on('click', function (e) {
127140
e.preventDefault();
@@ -188,7 +201,6 @@ Select2.prototype = {
188201
}
189202
};
190203
}
191-
192204
$select.select2(settings);
193205
},
194206
initSelect2: function() {

jet/static/jet/js/src/layout-updaters/actions.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -216,14 +216,18 @@ ActionsUpdater.prototype = {
216216
});
217217
});
218218

219-
document.querySelector('#changelist-form button[name=index]').addEventListener('click', function(event) {
220-
if (listEditableChanged) {
221-
const confirmed = confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."));
222-
if (!confirmed) {
223-
event.preventDefault();
219+
220+
const btnIndex = document.querySelector('#changelist-form button[name=index]');
221+
if (btnIndex) {
222+
btnIndex.addEventListener('click', function(event) {
223+
if (listEditableChanged) {
224+
const confirmed = confirm(gettext("You have unsaved changes on individual editable fields. If you run an action, your unsaved changes will be lost."));
225+
if (!confirmed) {
226+
event.preventDefault();
227+
}
224228
}
225-
}
226-
});
229+
});
230+
}
227231

228232
const el = document.querySelector('#changelist-form input[name=_save]');
229233
// The button does not exist if no fields are editable.

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def get_install_requires():
2828

2929
setup(
3030
name='django-jet-calm',
31-
version='5.1.1',
31+
version='5.1.2',
3232
description='Modern template for Django-4 admin interface with improved functionality',
3333
long_description=read('README.rst'),
3434
author='Akshara Hegde',

0 commit comments

Comments
 (0)