diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 6c622b9635..4e77d79ab6 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -4,6 +4,7 @@ Changelog
1.9 (xx.xx.xxxx) - IN DEVELOPMENT
~~~~~~~~~~~~~~~~
+ * Form builder form submissions can now be bulk-deleted (Karl Hobley)
* `get_context` methods on StreamField blocks can now access variables from the parent context (Mikael Svensson, Peter Baumgartner)
* Added `before_copy_page` and `after_copy_page` hooks (Matheus Bratfisch)
* View live / draft links in the admin now consistently open in a new window (Marco Fucci)
diff --git a/docs/releases/1.9.rst b/docs/releases/1.9.rst
index 72e21b06d0..9c9802317c 100644
--- a/docs/releases/1.9.rst
+++ b/docs/releases/1.9.rst
@@ -10,6 +10,12 @@ Wagtail 1.9 release notes - IN DEVELOPMENT
What's new
==========
+Bulk-deletion of form submissions
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Form builder form submissions can now be deleted in bulk from the form submissions index page. This feature was sponsored by St John's College, Oxford and developed by Karl Hobley.
+
+
Accessing parent context from StreamField block ``get_context`` methods
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
diff --git a/wagtail/wagtailforms/templates/wagtailforms/confirm_delete.html b/wagtail/wagtailforms/templates/wagtailforms/confirm_delete.html
index e023f5f022..a1826a2b07 100644
--- a/wagtail/wagtailforms/templates/wagtailforms/confirm_delete.html
+++ b/wagtail/wagtailforms/templates/wagtailforms/confirm_delete.html
@@ -1,19 +1,23 @@
{% extends "wagtailadmin/base.html" %}
{% load i18n %}
-{% block titletag %}{% blocktrans with title=page.title %}Delete {{ title }}{% endblocktrans %}{% endblock %}
+{% block titletag %}{% blocktrans with title=page.title %}Delete form data {{ title }}{% endblocktrans %}{% endblock %}
{% block bodyclass %}menu-explorer{% endblock %}
{% block content %}
- {% trans "Delete" as del_str %}
+ {% trans "Delete form data" as del_str %}
{% include "wagtailadmin/shared/header.html" with title=del_str subtitle=page.title icon="doc-empty-inverse" %}
- {% trans 'Are you sure you want to delete this form submission?' %}
+ {% blocktrans count counter=submissions.count %}
+ Are you sure you want to delete this form submission?
+ {% plural %}
+ Are you sure you want to delete these form submissions?
+ {% endblocktrans %}
-
{% endblock %}
diff --git a/wagtail/wagtailforms/templates/wagtailforms/index_submissions.html b/wagtail/wagtailforms/templates/wagtailforms/index_submissions.html
index 1d13389ad8..08c297a7e1 100644
--- a/wagtail/wagtailforms/templates/wagtailforms/index_submissions.html
+++ b/wagtail/wagtailforms/templates/wagtailforms/index_submissions.html
@@ -23,6 +23,63 @@
},
lang: 'lang'
});
+
+ var selectAllCheckbox = document.getElementById('select-all');
+ var deleteButton = document.getElementById('delete-submissions');
+ var selectedSubmissions = {};
+
+ function updateActions() {
+ var submissionCheckboxes = $('input[type=checkbox].select-submission');
+ var someSubmissionsSelected = submissionCheckboxes.is(':checked');
+ var everySubmissionSelected = !submissionCheckboxes.is(':not(:checked)');
+
+ // Select all box state
+ if (everySubmissionSelected) {
+ // Every submission has been selected
+ selectAllCheckbox.checked = true;
+ selectAllCheckbox.indeterminate = false;
+ } else if (someSubmissionsSelected) {
+ // At least one, but not all submissions have been selected
+ selectAllCheckbox.checked = false;
+ selectAllCheckbox.indeterminate = true;
+ } else {
+ // No submissions have been selected
+ selectAllCheckbox.checked = false;
+ selectAllCheckbox.indeterminate = false;
+ }
+
+ // Delete button state
+ if (someSubmissionsSelected) {
+ deleteButton.classList.remove('disabled')
+ deleteButton.style.visibility = "visible";
+ } else {
+ deleteButton.classList.add('disabled')
+ deleteButton.style.visibility = "hidden";
+ }
+ }
+
+
+ // Event handlers
+
+ $(selectAllCheckbox).on('change', function() {
+ let checked = this.checked;
+
+ // Update checkbox states
+ $('input[type=checkbox].select-submission').each(function() {
+ this.checked = checked;
+ });
+
+ updateActions();
+ });
+
+ $('input[type=checkbox].select-submission').on('change', function() {
+ updateActions();
+ });
+
+ // initial call to updateActions to bring delete button state in sync with checkboxes
+ // in the case that some checkboxes are pre-checked (which will be the case in some
+ // browsers when using the back button)
+ updateActions();
});
{% endblock %}
@@ -55,10 +112,12 @@
{% if submissions %}
- {% include "wagtailforms/list_submissions.html" %}
+
{% else %}
{% blocktrans with title=form_page.title %}There have been no submissions of the '{{ title }}' form.{% endblocktrans %}