From 0f0386b6c18e6a715199f0c29b5209fe2f496872 Mon Sep 17 00:00:00 2001 From: Mark Conroy Date: Mon, 13 Oct 2025 12:19:14 +0100 Subject: [PATCH 1/7] adds strict type and return for method --- .../src/Form/LocalgovServiceContactForm.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/localgov_workflows_notifications/src/Form/LocalgovServiceContactForm.php b/modules/localgov_workflows_notifications/src/Form/LocalgovServiceContactForm.php index 41eecdc..aa5e0c3 100644 --- a/modules/localgov_workflows_notifications/src/Form/LocalgovServiceContactForm.php +++ b/modules/localgov_workflows_notifications/src/Form/LocalgovServiceContactForm.php @@ -1,5 +1,6 @@ getValue('user')[0]['target_id']; From 9fc4f65d91018604cf7682723d9a33dd57700306 Mon Sep 17 00:00:00 2001 From: Mark Conroy Date: Mon, 13 Oct 2025 12:19:34 +0100 Subject: [PATCH 2/7] avoids variable name collision --- .../src/WorkflowNotification.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/localgov_workflows_notifications/src/WorkflowNotification.php b/modules/localgov_workflows_notifications/src/WorkflowNotification.php index f3f9624..523b27d 100644 --- a/modules/localgov_workflows_notifications/src/WorkflowNotification.php +++ b/modules/localgov_workflows_notifications/src/WorkflowNotification.php @@ -65,8 +65,8 @@ public function enqueue(ContentEntityInterface $entity, string $type): void { } if ($claimed_items) { - foreach ($claimed_items as $queue_item) { - $queue->releaseItem($queue_item); + foreach ($claimed_items as $claimed_item) { + $queue->releaseItem($claimed_item); } } From f0420accc3b41365c5f44a3cbf5356726841d4aa Mon Sep 17 00:00:00 2001 From: Mark Conroy Date: Mon, 13 Oct 2025 12:26:13 +0100 Subject: [PATCH 3/7] coding standards fix --- .../src/Form/LocalgovServiceContactForm.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/localgov_workflows_notifications/src/Form/LocalgovServiceContactForm.php b/modules/localgov_workflows_notifications/src/Form/LocalgovServiceContactForm.php index aa5e0c3..5edcb29 100644 --- a/modules/localgov_workflows_notifications/src/Form/LocalgovServiceContactForm.php +++ b/modules/localgov_workflows_notifications/src/Form/LocalgovServiceContactForm.php @@ -1,6 +1,7 @@ Date: Mon, 13 Oct 2025 13:21:37 +0100 Subject: [PATCH 4/7] fix eslint issues, remove jQuery, use modern JS --- .../localgov_review_date/js/review-date.js | 101 ++++++++++++------ .../localgov_review_date.libraries.yml | 4 +- 2 files changed, 69 insertions(+), 36 deletions(-) diff --git a/modules/localgov_review_date/js/review-date.js b/modules/localgov_review_date/js/review-date.js index ad28817..a86b3c2 100644 --- a/modules/localgov_review_date/js/review-date.js +++ b/modules/localgov_review_date/js/review-date.js @@ -2,60 +2,93 @@ * @file * Defines JavaScript behaviors for the review date widget. */ -(function ($, Drupal, drupalSettings) { - +(function reviewDatesScript(Drupal) { /** * Show review date summary on node edit form. */ Drupal.behaviors.ReviewDateSummary = { - attach: function attach(context) { - const $context = $(context); - $context.find('.review-date-form').drupalSetSummary(function (context) { - const lastReview = $('.review-date-last-review').val(); - const nextReview = $('.review-date-next-review').val(); - - if (lastReview && nextReview) { - return Drupal.t('Last reviewed on @last
Next review on @next', { + attach: (context) => { + const reviewDateForms = once( + 'allReviewDateForms', + '.review-date-form', + context, + ); + + reviewDateForms.forEach((form) => { + form.drupalSetSummary(() => { + const lastReview = form.querySelector( + '.review-date-last-review', + )?.value; + const nextReview = form.querySelector( + '.review-date-next-review', + )?.value; + + if (lastReview && nextReview) { + return Drupal.t('Last reviewed on @last
Next review on @next', { '@last': lastReview, '@next': nextReview, - } - ); - } + }); + } - return Drupal.t('Not reviewed yet'); + return Drupal.t('Not reviewed yet'); + }); }); - } + }, }; /** * Update review date when next review date select changes. */ Drupal.behaviors.ReviewDateNextReviewSelect = { - attach: function attach(context) { - $('.review-date-review-in').change(function() { - const reviewIn = parseInt($('.review-date-review-in').val()); - let today = new Date(); - const reviewDate = new Date(today.setMonth(today.getMonth() + reviewIn)); + attach: (context) => { + const reviewInSelects = context.querySelectorAll( + '.review-date-review-in', + ); + + reviewInSelects.forEach((select) => { + select.addEventListener('change', () => { + const reviewIn = parseInt(select.value, 10); + const today = new Date(); + const reviewDate = new Date( + today.setMonth(today.getMonth() + reviewIn), + ); - $('.review-date-review-date').val(reviewDate.toISOString().slice(0, 10)); + const reviewDateField = context.querySelector( + '.review-date-review-date', + ); + if (reviewDateField) { + reviewDateField.value = reviewDate.toISOString().slice(0, 10); + } + }); }); - } + }, }; /** * Set content reviewed if content moderation state set to published. */ Drupal.behaviors.ReviewDateSetReviewed = { - attach: function attach(context) { - $('#edit-moderation-state-0-state').change(function() { - const moderation_state = $('#edit-moderation-state-0-state').val(); - if (moderation_state === 'published') { - const reviewed = $('.review-date-reviewed'); - reviewed.prop('checked', true); - reviewed.trigger('change'); - } - }); - } - }; + attach: (context) => { + const moderationStateField = context.querySelector( + '#edit-moderation-state-0-state', + ); -})(jQuery, Drupal, drupalSettings); + if (moderationStateField) { + moderationStateField.addEventListener('change', () => { + const moderationState = moderationStateField.value; + if (moderationState === 'published') { + const reviewedField = context.querySelector( + '.review-date-reviewed', + ); + if (reviewedField) { + reviewedField.checked = true; + reviewedField.dispatchEvent( + new Event('change', { bubbles: true }), + ); + } + } + }); + } + }, + }; +})(Drupal); diff --git a/modules/localgov_review_date/localgov_review_date.libraries.yml b/modules/localgov_review_date/localgov_review_date.libraries.yml index 4e7bb45..3731408 100644 --- a/modules/localgov_review_date/localgov_review_date.libraries.yml +++ b/modules/localgov_review_date/localgov_review_date.libraries.yml @@ -2,5 +2,5 @@ localgov_review_date.review_date: js: js/review-date.js: {} dependencies: - - core/drupal.entity-form - - core/drupalSettings + - core/drupal + - core/once \ No newline at end of file From dd98c1dabb99a4dd125f1132f220d3967d6968d5 Mon Sep 17 00:00:00 2001 From: Mark Conroy Date: Mon, 13 Oct 2025 13:28:54 +0100 Subject: [PATCH 5/7] coding standards fix --- modules/localgov_review_date/localgov_review_date.libraries.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/localgov_review_date/localgov_review_date.libraries.yml b/modules/localgov_review_date/localgov_review_date.libraries.yml index 3731408..fd30e3b 100644 --- a/modules/localgov_review_date/localgov_review_date.libraries.yml +++ b/modules/localgov_review_date/localgov_review_date.libraries.yml @@ -3,4 +3,4 @@ localgov_review_date.review_date: js/review-date.js: {} dependencies: - core/drupal - - core/once \ No newline at end of file + - core/once From e5baf58e98bb3e3b586a5c50d99c44d2baa6eeba Mon Sep 17 00:00:00 2001 From: Mark Conroy Date: Mon, 13 Oct 2025 15:45:28 +0100 Subject: [PATCH 6/7] adds needed js library --- modules/localgov_review_date/localgov_review_date.libraries.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/localgov_review_date/localgov_review_date.libraries.yml b/modules/localgov_review_date/localgov_review_date.libraries.yml index fd30e3b..64310df 100644 --- a/modules/localgov_review_date/localgov_review_date.libraries.yml +++ b/modules/localgov_review_date/localgov_review_date.libraries.yml @@ -4,3 +4,4 @@ localgov_review_date.review_date: dependencies: - core/drupal - core/once + - core/drupal.entity-form From 6e9803df137d7b3b24a3335a517dce790918167a Mon Sep 17 00:00:00 2001 From: Mark Conroy Date: Mon, 13 Oct 2025 16:03:22 +0100 Subject: [PATCH 7/7] fix for drupalSetSummary not being available --- .../localgov_review_date/js/review-date.js | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/modules/localgov_review_date/js/review-date.js b/modules/localgov_review_date/js/review-date.js index a86b3c2..107ec9e 100644 --- a/modules/localgov_review_date/js/review-date.js +++ b/modules/localgov_review_date/js/review-date.js @@ -15,23 +15,25 @@ ); reviewDateForms.forEach((form) => { - form.drupalSetSummary(() => { - const lastReview = form.querySelector( - '.review-date-last-review', - )?.value; - const nextReview = form.querySelector( - '.review-date-next-review', - )?.value; + const summary = form.querySelector('summary .claro-details__summary-summary'); + const lastReview = form.querySelector( + '.review-date-last-review', + )?.value; + const nextReview = form.querySelector( + '.review-date-next-review', + )?.value; - if (lastReview && nextReview) { - return Drupal.t('Last reviewed on @last
Next review on @next', { + if (lastReview && nextReview) { + summary.innerHTML = Drupal.t( + 'Last reviewed on @last
Next review on @next', + { '@last': lastReview, '@next': nextReview, - }); - } - - return Drupal.t('Not reviewed yet'); - }); + }, + ); + } else { + summary.innerHTML = Drupal.t('Not reviewed yet'); + } }); }, };