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> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
5cb727bece
commit
73371635db
2 changed files with 54 additions and 0 deletions
|
@ -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 %]
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue