diff --git a/client/src/entrypoints/admin/page-chooser-modal.js b/client/src/entrypoints/admin/page-chooser-modal.js index 1159ddde9e..50fea2480a 100644 --- a/client/src/entrypoints/admin/page-chooser-modal.js +++ b/client/src/entrypoints/admin/page-chooser-modal.js @@ -102,6 +102,16 @@ const PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { }); } + function updateMultipleChoiceSubmitEnabledState() { + // update the enabled state of the multiple choice submit button depending on whether + // any items have been selected + if ($('[data-multiple-choice-select]:checked', modal.body).length) { + $('[data-multiple-choice-submit]', modal.body).removeAttr('disabled'); + } else { + $('[data-multiple-choice-submit]', modal.body).attr('disabled', true); + } + } + function ajaxifyBrowseResults() { /* Set up page navigation links to open in the modal */ $( @@ -133,6 +143,11 @@ const PAGE_CHOOSER_MODAL_ONLOAD_HANDLERS = { }); wagtail.ui.initDropDowns(); + + updateMultipleChoiceSubmitEnabledState(); + $('[data-multiple-choice-select]', modal.body).on('change', () => { + updateMultipleChoiceSubmitEnabledState(); + }); } ajaxifyBrowseResults(); initTooltips(); diff --git a/client/src/includes/chooserModal.js b/client/src/includes/chooserModal.js index e9d58d51ad..95be30c6aa 100644 --- a/client/src/includes/chooserModal.js +++ b/client/src/includes/chooserModal.js @@ -228,6 +228,21 @@ class ChooserModalOnloadHandlerFactory { // Reinitialise any tooltips initTooltips(); + + this.updateMultipleChoiceSubmitEnabledState(modal); + $('[data-multiple-choice-select]', containerElement).on('change', () => { + this.updateMultipleChoiceSubmitEnabledState(modal); + }); + } + + updateMultipleChoiceSubmitEnabledState(modal) { + // update the enabled state of the multiple choice submit button depending on whether + // any items have been selected + if ($('[data-multiple-choice-select]:checked', modal.body).length) { + $('[data-multiple-choice-submit]', modal.body).removeAttr('disabled'); + } else { + $('[data-multiple-choice-submit]', modal.body).attr('disabled', true); + } } modalHasTabs(modal) { diff --git a/wagtail/admin/templates/wagtailadmin/chooser/browse.html b/wagtail/admin/templates/wagtailadmin/chooser/browse.html index 8d81e08a99..b2cd014d96 100644 --- a/wagtail/admin/templates/wagtailadmin/chooser/browse.html +++ b/wagtail/admin/templates/wagtailadmin/chooser/browse.html @@ -28,7 +28,7 @@ {% include 'wagtailadmin/chooser/_browse_results.html' %} - + {% else %}
diff --git a/wagtail/admin/templates/wagtailadmin/chooser/tables/page_checkbox_select_cell.html b/wagtail/admin/templates/wagtailadmin/chooser/tables/page_checkbox_select_cell.html index 3f226bf415..b42fb3f7d0 100644 --- a/wagtail/admin/templates/wagtailadmin/chooser/tables/page_checkbox_select_cell.html +++ b/wagtail/admin/templates/wagtailadmin/chooser/tables/page_checkbox_select_cell.html @@ -1,4 +1,4 @@ {% load i18n %} - + diff --git a/wagtail/admin/templates/wagtailadmin/generic/chooser/checkbox_select_cell.html b/wagtail/admin/templates/wagtailadmin/generic/chooser/checkbox_select_cell.html index 79340071c0..033ba828e3 100644 --- a/wagtail/admin/templates/wagtailadmin/generic/chooser/checkbox_select_cell.html +++ b/wagtail/admin/templates/wagtailadmin/generic/chooser/checkbox_select_cell.html @@ -1,4 +1,4 @@ {% load i18n %} - + diff --git a/wagtail/admin/templates/wagtailadmin/generic/chooser/chooser.html b/wagtail/admin/templates/wagtailadmin/generic/chooser/chooser.html index 78a63abb09..7b9b42dceb 100644 --- a/wagtail/admin/templates/wagtailadmin/generic/chooser/chooser.html +++ b/wagtail/admin/templates/wagtailadmin/generic/chooser/chooser.html @@ -51,7 +51,7 @@ {% include view.results_template_name %}
- + {% else %}
diff --git a/wagtail/images/templates/wagtailimages/chooser/results.html b/wagtail/images/templates/wagtailimages/chooser/results.html index fb0bc093bb..314ed75cb3 100644 --- a/wagtail/images/templates/wagtailimages/chooser/results.html +++ b/wagtail/images/templates/wagtailimages/chooser/results.html @@ -12,7 +12,7 @@
{% image image max-165x165 class="show-transparency" %}

- + {{ image.title|ellipsistrim:60 }}

{% else %}