Bugzilla – Attachment 166765 Details for
Bug 36815
Add the option to 'Reset to default' in the notices editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36815: Expose to the UI
Bug-36815-Expose-to-the-UI.patch (text/plain), 5.48 KB, created by
Kyle M Hall (khall)
on 2024-05-15 10:32:48 UTC
(
hide
)
Description:
Bug 36815: Expose to the UI
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2024-05-15 10:32:48 UTC
Size:
5.48 KB
patch
obsolete
>From 91fa85df71fa882b4d789058ba75c6b3187ab51f Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >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 <emily.lamancusa@montgomerycountymd.gov> > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > .../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 @@ > </div> <!-- /.modal-dialog --> > </div> <!-- /#preview_template --> > >+ <!-- Sample display modal --> >+ <div class="modal" id="noticeSampleModal" tabindex="-1" aria-labelledby="noticeSampleModalLabel" aria-hidden="true"> >+ <div class="modal-dialog modal-lg"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-label="Close"> >+ <span aria-hidden="true">×</span> >+ </button> >+ <h3 class="modal-title" id="noticeSampleModalLabel">Default template</h3> >+ </div> >+ <div class="modal-body"> >+ <pre class="template-body"></pre> >+ </div> >+ <div class="modal-footer"> >+ <button type="button" class="btn btn-primary copy">Copy to template</button> >+ <button type="button" class="btn btn-default deny cancel" data-dismiss="modal"><i class="fa fa-times"></i> Close</button> >+ </div> >+ </div> <!-- /.modal-content --> >+ </div> <!-- /.modal-dialog --> >+ </div> <!-- /.modal --> >+ > [% IF add_form or copy_form %] > <div class="main container-fluid"> > <div class="row"> >@@ -673,6 +694,12 @@ > <a href="/cgi-bin/koha/svc/letters/preview" class="preview_template btn btn-default btn-xs" title="Preview this notice template" data-mtt="[% letter.message_transport_type | html %]" data-lang="[% lang | html %]"><i class="fa-solid fa-eye"></i> Preview</a> > </li> > [% END %] >+ [% IF letter.sample %] >+ <li> >+ <button data-noticeid="[% letter.id | html %]" data-replace="content_[% letter.message_transport_type | html %]_[% lang | html %]" class="notice-sample btn btn-default btn-sm"><i class="fa-solid fa-eye"></i> View default</button> >+ <textarea class="hidden" id="notice[% letter.id | html %]">[% letter.sample | html %]</textarea> >+ </li> >+ [% END %] > </ol> > </fieldset> <!-- /.rows.mtt --> > [% 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'); >+ }); > }); > </script> > [% 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.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36815
:
166429
|
166430
|
166449
|
166450
|
166475
|
166476
|
166535
|
166678
|
166679
|
166680
|
166684
|
166685
|
166686
|
166689
|
166693
|
166694
|
166695
|
166696
|
166763
|
166764
|
166765
|
166766
|
168190
|
168191
|
168192
|
168193
|
168194