Skip to content

Commit c802d38

Browse files
authored
Merge pull request #305 from crucialfelix/feature/misc-fixes
feature/misc fixes
2 parents 06a199d + 748fd62 commit c802d38

File tree

5 files changed

+43
-42
lines changed

5 files changed

+43
-42
lines changed

.github/workflows/publish.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Build and publish python package
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
publish-service-client-package:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- name: Build and publish to pypi
14+
uses: JRubics/[email protected]
15+
with:
16+
pypi_token: ${{ secrets.PYPI_TOKEN }}

ajax_select/__init__.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""JQuery-Ajax Autocomplete fields for Django Forms."""
2-
__version__ = "1.7.0"
2+
__version__ = "2.2.0"
33
__author__ = "crucialfelix"
44
__contact__ = "[email protected]"
55
__homepage__ = "https://github.com/crucialfelix/django-ajax-selects/"
@@ -8,14 +8,9 @@
88
from ajax_select.helpers import make_ajax_form, make_ajax_field # noqa
99
from ajax_select.lookup_channel import LookupChannel # noqa
1010

11-
# django 1.7+ will use the new AppConfig api
1211
# It will load all your lookups.py modules
1312
# and any specified in settings.AJAX_LOOKUP_CHANNELS
1413
# It will do this after all apps are imported.
1514
from django.apps import AppConfig # noqa
1615

17-
# Django 3.2+ does not need default_app_config set.
18-
# Remove this once django <3.2 support is removed
19-
import django
20-
if django.VERSION < (3, 2):
21-
default_app_config = 'ajax_select.apps.AjaxSelectConfig'
16+
default_app_config = "ajax_select.apps.AjaxSelectConfig"

ajax_select/static/ajax_select/css/ajax_select.css

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.results_on_deck .ui-icon-trash {
2-
float: left;
32
cursor: pointer;
43
}
54

@@ -20,19 +19,19 @@ html[data-theme="dark"] {
2019
.results_on_deck {
2120
padding: 0.25em 0;
2221
}
23-
.results_on_deck > div {
22+
.results_on_deck .item_on_deck {
2423
display: grid;
2524
grid-template-columns: auto 1fr;
2625
align-items: center;
2726
}
27+
.results_on_deck .item_on_deck > div {
28+
margin: 0.5em 0;
29+
}
2830

2931
form .aligned .results_on_deck {
3032
padding-left: 14px;
3133
margin-left: 160px;
3234
}
33-
.results_on_deck > div {
34-
margin: 0.5em 0;
35-
}
3635
.ui-autocomplete-loading {
3736
background: url("../images/loading-indicator.gif") no-repeat;
3837
background-origin: content-box;

ajax_select/static/ajax_select/js/ajax_select.js

Lines changed: 20 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,33 @@
88

99
function receiveResult(event, ui) {
1010
if ($this.val()) {
11-
kill();
11+
removeItem();
1212
}
1313
$this.val(ui.item.pk);
1414
$text.val("");
15-
addKiller(ui.item.repr, ui.item.pk);
15+
addItemOnDeck(ui.item.repr, ui.item.pk);
1616
$deck.trigger("added", [ui.item.pk, ui.item]);
1717
$this.trigger("change");
1818

1919
return false;
2020
}
2121

22-
function addKiller(repr, pk) {
23-
var killId = "kill_" + pk + id,
24-
killButton =
25-
'<span class="ui-icon ui-icon-trash" id="' + killId + '">X</span> ';
22+
function addItemOnDeck(repr, pk) {
23+
var trashId = "trash_" + pk + id,
24+
killButton = `<span class="ui-icon ui-icon-trash" id="${trashId}">X</span>`;
2625
if (repr) {
2726
$deck.empty();
28-
$deck.append("<div>" + killButton + repr + "</div>");
27+
$deck.append(`<div>${killButton}${repr}</div>`);
2928
} else {
30-
$("#" + id + "_on_deck > div").prepend(killButton);
29+
$(`#${id}_on_deck > div`).prepend(killButton);
3130
}
32-
$("#" + killId).click(function () {
33-
kill();
31+
$("#" + trashId).click(function () {
32+
removeItem();
3433
$deck.trigger("killed", [pk]);
3534
});
3635
}
3736

38-
function kill() {
37+
function removeItem() {
3938
$this.val("");
4039
$deck.children().fadeOut(1.0).remove();
4140
}
@@ -45,10 +44,10 @@
4544

4645
function reset() {
4746
if (options.initial) {
48-
addKiller(options.initial[0], options.initial[1]);
47+
addItemOnDeck(options.initial[0], options.initial[1]);
4948
$this.val(options.initial[1]);
5049
} else {
51-
kill();
50+
removeItem();
5251
}
5352
}
5453

@@ -69,8 +68,8 @@
6968
return this.each(function () {
7069
var id = this.id,
7170
$this = $(this),
72-
$text = $("#" + id + "_text"),
73-
$deck = $("#" + id + "_on_deck");
71+
$text = $(`#${id}_text`),
72+
$deck = $(`#${id}_on_deck`);
7473

7574
function receiveResult(event, ui) {
7675
var pk = ui.item.pk,
@@ -87,18 +86,12 @@
8786
}
8887

8988
function addKiller(repr, pk) {
90-
var killId = "kill_" + pk + id,
91-
killButton =
92-
'<span class="ui-icon ui-icon-trash" id="' + killId + '">X</span> ';
89+
var killId = "kill_" + pk + id;
9390
$deck.append(
94-
'<div id="' +
95-
id +
96-
"_on_deck_" +
97-
pk +
98-
'">' +
99-
killButton +
100-
repr +
101-
" </div>"
91+
`<div id="${id}_on_deck_${pk}" class="item_on_deck">
92+
<span class="ui-icon ui-icon-trash" id="${killId}">X</span>
93+
<div class="repr">${repr}</div>
94+
</div>`
10295
);
10396

10497
$("#" + killId).click(function () {
@@ -109,9 +102,7 @@
109102

110103
function kill(pk) {
111104
$this.val($this.val().replace("|" + pk + "|", "|"));
112-
$("#" + id + "_on_deck_" + pk)
113-
.fadeOut()
114-
.remove();
105+
$(`#${id}_on_deck_${pk}`).fadeOut().remove();
115106
}
116107

117108
options.select = receiveResult;

docs/source/Install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Include the urls in your project::
3030
# place it at whatever base url you like
3131
url(r'^ajax_select/', include(ajax_select_urls)),
3232

33-
url(r'^admin/', include(admin.site.urls)),
33+
url(r'^admin/', admin.site.urls),
3434
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
3535

3636

0 commit comments

Comments
 (0)