From 7acc578c73664419459296276126f0f61ac5f17f Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 8 May 2024 17:05:26 +0100 Subject: [PATCH] Bug 36815: Expose to the UI This patch adds a modal to preview the sample notices in the UI and allow replacing the template content with that content of that modal. Test plan 1) Apply patches and restart plack (Or just use a sandbox) 2) Login to the staff client and navigate to 'Tools > Notices and Slips' 3) 'Edit' a notice. 4) Note the new 'View default' button on some notices where we ship a default in the 'sample_notices' file. 5) Click the button to view the sample notice 6) Confirm 'Close' just closes the modal 7) Confirm 'Copy' copies the sample notice into the editor field Signed-off-by: Emily Lamancusa --- .../prog/en/modules/tools/letter.tt | 50 +++++++++++++++++++ tools/letter.pl | 4 ++ 2 files changed, 54 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt index 22379532e50..ead1d171b4d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/letter.tt @@ -132,6 +132,27 @@ + + + [% IF add_form or copy_form %]
@@ -673,6 +694,12 @@ Preview [% END %] + [% IF letter.sample %] +
  • + + +
  • + [% END %] [% END %] @@ -761,6 +788,29 @@ '}'; }); }); + + $(".notice-sample").on("click", function(e){ + e.preventDefault(); + var noticeid = $(this).data("noticeid"); + var replaceid = $(this).data("replace"); + var body = $("#notice" + noticeid ).val(); + $("#noticeSampleModal .template-body").text(body); + $("#noticeSampleModal").attr("data-replaceid", replaceid); + $("#noticeSampleModal").modal("show"); + }); + + $("#noticeSampleModal").on("hide.bs.modal", function(){ + $("#noticeSampleModalLabel").text(""); + $("#noticeSampleModal .template-body").text(""); + $("#noticeSampleModal").attr("data-replaceid", ''); + }); + + $("#noticeSampleModal").on("click", ".copy", function(){ + var content = $('#noticeSampleModal .template-body').text(); + var replaceid = $('#noticeSampleModal').data('replaceid'); + $('#'+replaceid).val(content); + $('#noticeSampleModal').modal('hide'); + }); }); [% Asset.js("js/letter.js") | $raw %] diff --git a/tools/letter.pl b/tools/letter.pl index 9e9b9e386fa..dbe84aa26cb 100755 --- a/tools/letter.pl +++ b/tools/letter.pl @@ -227,6 +227,10 @@ sub add_form { tt_error => $letter->{tt_error}, }; $letters{ $lang }{params} = $letter; + + my $object = Koha::Notice::Templates->find( { id => $letter->{id} } ); + $letters{ $lang }{templates}{$mtt}{sample} = $object->get_default; + $letters{ $lang }{templates}{$mtt}{id} = $letter->{id}; } } else { -- 2.45.0