From b0123a82567ee7ffac9db79dbe7a437f2e7acd7e Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Fri, 6 May 2022 12:05:12 +0000
Subject: [PATCH] Bug 30709: 'Insert' button in notices editor not adding
 selected placeholders to notice

This patch updates letter.js so that it uses .prop("selected") to look
for selected <option>s instead of .attr("selected"). This is necessary
because of the jQuery upgrade.

To test, apply the patch and edit any notice. Test that you can select
one or more database columns and insert them into the body of a notice
by clicking "Insert." Confirm that your selections are inserted where
you left the cursor in the message textarea.

Test with multiple message transports and with multiple languages
installed (with TranslateNotices enabled).

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
---
 koha-tmpl/intranet-tmpl/prog/js/letter.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/js/letter.js b/koha-tmpl/intranet-tmpl/prog/js/letter.js
index 76b2d497fe..53ac7b120e 100644
--- a/koha-tmpl/intranet-tmpl/prog/js/letter.js
+++ b/koha-tmpl/intranet-tmpl/prog/js/letter.js
@@ -197,7 +197,7 @@ $(document).ready(function() {
 
         if($(myListBox).find('option').length > 0) {
             $(myListBox).find('option').each( function (){
-                if ( $(this).attr('selected') && $(this).val().length > 0 ) {
+                if ( $(this).prop('selected') && $(this).val().length > 0 ) {
                     $(myQuery).insertAtCaret("<<" + $(this).val() + ">>");
                 }
             });
-- 
2.20.1