diff --git a/CHANGELOG.md b/CHANGELOG.md index e0ff4d7a..0eedb5c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Changed - Updated the SendGrid webhook event names. +- Adding or removing test contacts no longer shows an unsaved changes notification ([#437](https://github.com/putyourlightson/craft-campaign/issues/437)). ## 2.9.4 - 2023-11-07 diff --git a/src/controllers/SendoutsController.php b/src/controllers/SendoutsController.php index fe0f6015..d118773b 100755 --- a/src/controllers/SendoutsController.php +++ b/src/controllers/SendoutsController.php @@ -211,6 +211,7 @@ public function actionPreview(int $sendoutId): Response 'schedule' => $sendout->getSchedule(), 'settings' => Campaign::$plugin->settings, 'contactElementType' => ContactElement::class, + 'testContactCriteria' => ['status' => ContactElement::STATUS_ACTIVE], 'testContacts' => $campaignType ? $campaignType->getTestContactsWithDefault() : [], 'actions' => [], 'system' => [ diff --git a/src/resources/js/SendTest.js b/src/resources/js/SendTest.js index 119c6250..48041710 100644 --- a/src/resources/js/SendTest.js +++ b/src/resources/js/SendTest.js @@ -5,10 +5,19 @@ * SendTest class */ Campaign.SendTest = Garnish.Base.extend({ + $elementSelect: null, + init: function() { + this.$elementSelect = $('.test-email .elementselect'); + this.preventUnsavedChanges(); + this.addListener(this.$elementSelect, 'change', 'preventUnsavedChanges'); this.addListener($('.send-test'), 'click', 'sendTest'); }, + preventUnsavedChanges: function() { + this.$elementSelect.find('input').attr('name', ''); + }, + sendTest: function(event) { event.preventDefault(); @@ -19,7 +28,7 @@ Campaign.SendTest = Garnish.Base.extend({ $('.send-test').addClass('disabled'); const contactIds = []; - $('.test-email .elementselect input').each(function() { + this.$elementSelect.find('input').each(function() { contactIds.push($(this).val()); }); diff --git a/src/templates/sendouts/_preview.twig b/src/templates/sendouts/_preview.twig index c26bbbeb..f56a73bb 100644 --- a/src/templates/sendouts/_preview.twig +++ b/src/templates/sendouts/_preview.twig @@ -197,6 +197,7 @@ name: 'testContacts', elementType: contactElementType, selectionLabel: "Add a contact"|t('campaign'), + criteria: testContactCriteria, elements: testContacts, }) }} {% set button %}