Bugzilla – Attachment 166450 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), 4.94 KB, created by
Martin Renvoize
on 2024-05-09 09:44:33 UTC
(
hide
)
Description:
Bug 36815: Expose to the UI
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-05-09 09:44:33 UTC
Size:
4.94 KB
patch
obsolete
>From 74dca84b8df06d586a42753199b5de3ba95bff7c 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. >--- > .../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.45.0
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