From a860c5621be10502226dd3c6eb58f0f70e77dcb5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 8 May 2024 17:05:26 +0100 Subject: [PATCH] Bug 36815: WIP - Expose to the UI This patch begins to expose the sample notices to the UI in the notices editor. It doesn't look pretty yet, we need to treat the output as code as aposed to rendering it as html.. and we want to add the 'copy to content' functoinality to allow resetting from it. --- .../prog/en/modules/tools/letter.tt | 42 +++++++++++++++++++ tools/letter.pl | 4 ++ 2 files changed, 46 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..fad17b6d273 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,26 @@ + + + [% IF add_form or copy_form %]
@@ -673,6 +693,12 @@ Preview [% END %] + [% IF letter.sample %] +
  • + + +
  • + [% END %] [% END %] @@ -761,6 +787,22 @@ '}'; }); }); + + $(".notice-sample").on("click", function(e){ + e.preventDefault(); + var title = $(this).text(); + var noticeid = $(this).data("noticeid"); + var body = $("#notice" + noticeid ).attr("srcdoc"); + $("#noticeSampleModalLabel").text( title ); + $("#noticeSampleModal .modal-body").html( body ); + $("#noticeSampleModal").modal("show"); + }); + + $("#noticeSampleModal").on("hide.bs.modal", function(){ + $("#noticeSampleModalLabel").text(""); + $("#noticeSampleModal .modal-body").html(""); + }); + }); [% 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