diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000000..598bb76610 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,16 @@ +name: Build and publish python package + +on: + release: + types: [published] + +jobs: + publish-service-client-package: + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Build and publish to pypi + uses: JRubics/poetry-publish@v1.17 + with: + pypi_token: ${{ secrets.PYPI_TOKEN }} diff --git a/ajax_select/__init__.py b/ajax_select/__init__.py index 6ff72652e1..9b43c457f5 100644 --- a/ajax_select/__init__.py +++ b/ajax_select/__init__.py @@ -1,5 +1,5 @@ """JQuery-Ajax Autocomplete fields for Django Forms.""" -__version__ = "1.7.0" +__version__ = "2.2.0" __author__ = "crucialfelix" __contact__ = "crucialfelix@gmail.com" __homepage__ = "https://github.com/crucialfelix/django-ajax-selects/" @@ -8,14 +8,9 @@ from ajax_select.helpers import make_ajax_form, make_ajax_field # noqa from ajax_select.lookup_channel import LookupChannel # noqa -# django 1.7+ will use the new AppConfig api # It will load all your lookups.py modules # and any specified in settings.AJAX_LOOKUP_CHANNELS # It will do this after all apps are imported. from django.apps import AppConfig # noqa -# Django 3.2+ does not need default_app_config set. -# Remove this once django <3.2 support is removed -import django -if django.VERSION < (3, 2): - default_app_config = 'ajax_select.apps.AjaxSelectConfig' +default_app_config = "ajax_select.apps.AjaxSelectConfig" diff --git a/ajax_select/static/ajax_select/css/ajax_select.css b/ajax_select/static/ajax_select/css/ajax_select.css index ee23d4b006..f57d81fb6b 100644 --- a/ajax_select/static/ajax_select/css/ajax_select.css +++ b/ajax_select/static/ajax_select/css/ajax_select.css @@ -1,5 +1,4 @@ .results_on_deck .ui-icon-trash { - float: left; cursor: pointer; } @@ -20,19 +19,19 @@ html[data-theme="dark"] { .results_on_deck { padding: 0.25em 0; } -.results_on_deck > div { +.results_on_deck .item_on_deck { display: grid; grid-template-columns: auto 1fr; align-items: center; } +.results_on_deck .item_on_deck > div { + margin: 0.5em 0; +} form .aligned .results_on_deck { padding-left: 14px; margin-left: 160px; } -.results_on_deck > div { - margin: 0.5em 0; -} .ui-autocomplete-loading { background: url("../images/loading-indicator.gif") no-repeat; background-origin: content-box; diff --git a/ajax_select/static/ajax_select/js/ajax_select.js b/ajax_select/static/ajax_select/js/ajax_select.js index 4750ff68d6..1be7cd09eb 100644 --- a/ajax_select/static/ajax_select/js/ajax_select.js +++ b/ajax_select/static/ajax_select/js/ajax_select.js @@ -8,34 +8,33 @@ function receiveResult(event, ui) { if ($this.val()) { - kill(); + removeItem(); } $this.val(ui.item.pk); $text.val(""); - addKiller(ui.item.repr, ui.item.pk); + addItemOnDeck(ui.item.repr, ui.item.pk); $deck.trigger("added", [ui.item.pk, ui.item]); $this.trigger("change"); return false; } - function addKiller(repr, pk) { - var killId = "kill_" + pk + id, - killButton = - 'X '; + function addItemOnDeck(repr, pk) { + var trashId = "trash_" + pk + id, + killButton = `X`; if (repr) { $deck.empty(); - $deck.append("
" + killButton + repr + "
"); + $deck.append(`
${killButton}${repr}
`); } else { - $("#" + id + "_on_deck > div").prepend(killButton); + $(`#${id}_on_deck > div`).prepend(killButton); } - $("#" + killId).click(function () { - kill(); + $("#" + trashId).click(function () { + removeItem(); $deck.trigger("killed", [pk]); }); } - function kill() { + function removeItem() { $this.val(""); $deck.children().fadeOut(1.0).remove(); } @@ -45,10 +44,10 @@ function reset() { if (options.initial) { - addKiller(options.initial[0], options.initial[1]); + addItemOnDeck(options.initial[0], options.initial[1]); $this.val(options.initial[1]); } else { - kill(); + removeItem(); } } @@ -69,8 +68,8 @@ return this.each(function () { var id = this.id, $this = $(this), - $text = $("#" + id + "_text"), - $deck = $("#" + id + "_on_deck"); + $text = $(`#${id}_text`), + $deck = $(`#${id}_on_deck`); function receiveResult(event, ui) { var pk = ui.item.pk, @@ -87,18 +86,12 @@ } function addKiller(repr, pk) { - var killId = "kill_" + pk + id, - killButton = - 'X '; + var killId = "kill_" + pk + id; $deck.append( - '
' + - killButton + - repr + - "
" + `
+ X +
${repr}
+
` ); $("#" + killId).click(function () { @@ -109,9 +102,7 @@ function kill(pk) { $this.val($this.val().replace("|" + pk + "|", "|")); - $("#" + id + "_on_deck_" + pk) - .fadeOut() - .remove(); + $(`#${id}_on_deck_${pk}`).fadeOut().remove(); } options.select = receiveResult; diff --git a/docs/source/Install.rst b/docs/source/Install.rst index c3288256b5..e5bdcbd9ce 100644 --- a/docs/source/Install.rst +++ b/docs/source/Install.rst @@ -30,7 +30,7 @@ Include the urls in your project:: # place it at whatever base url you like url(r'^ajax_select/', include(ajax_select_urls)), - url(r'^admin/', include(admin.site.urls)), + url(r'^admin/', admin.site.urls), ] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)