Koha/koha-tmpl/opac-tmpl/bootstrap/en/modules/sci/sci-main.tt
Jonathan Druart 89ade834d6 Bug 24387: Rename "News" with "Additional contents"
One big patch for one big move.

The "News" feature (opac_news) has been hijacked to handle some system
preferences (bug 26050). The goal was to take profit of the UI (editor)
and the ability to translate the value.

Disclaimer: This patch is NOT offering the best implementation but, as
we still don't have bug 24975, it cannot be done now. And no, we don't
want to wait for it to move forward here. This patch is going into the
right direction anyway.

This enhancement is going to rename the "News" with a more genertic
"Additional contents". We have two different "categories" of content:
"news" and "html customizations".

What does it bring?
- A split on the UI for disambigate the two types of content (news and
syspref/html customizations)
- A simplification of the edit form: all languages will be translatable
on the same view (like the "notice templates")
- Ground will be prepared for different types of content (if needed later)
- Staff news can be translated

How was the "News" area working before this patch?
The opac_news DB table contained a (very inconsistent) 'lang' column.
The different values were:
- '' => news to display at the OPAC and staff interfaces
- 'koha' => news for staff only
- 'slip' => news for slip notices
- $lang => news for OPAC only, translated in $lang ('en', 'es-ES', etc.)
- "$location_$lang" => A syspref moved to this "news" area. The syspref
is $location, and is translated in $lang. Eg. OpacLoginInstructions_en,
OpacLoginInstructions_fr-FR, opacheader_es-ES

This patch is improving the DB structure with the following changes:
- renaming 'opac_news' with 'additional_contents'
- new 'category' column
 => 'news' or 'html_customizations'
- new 'location' column
 => For 'news': 'staff_and_opac', 'staff_only', 'slip'
 => For 'html_customizations': the old syspref name (eg. 'OpacLoginInstructions').
- new 'code' column (see later for more info)
- the 'lang' column will only contain the language code ('en', 'es-ES',
etc.). BUT a 'default' entry will ALWAYS exist for fallback behaviour.

We are getting closer to the 'notice template' table structure because
we want to match its UI. The 'code' column will bring us the ability to
group the different 'additional_contents' rows. The code for a given
news will be the same, but the (lang, title, content) will differ.
Examples:
  News 1 will have, for each of the translated versions
  (category, code,    location, branchcode)
  ('news',   'News1', $location, $branchcode||undef)
  And the 3 following columns will differ:
  (title,              content,               lang)
  ('title for news 1', 'content for news 1', 'default')
  ('titulo para 1',    'contenido para 1',   'es-ES')

Note that the "category" is not strictely necessary, but it seems better
to have the ability to split the different content by category/type
easily.

Additional changes:
- Syspref 'NewsToolEditor' is renamed 'AdditionalContentsEditor'
- Koha::NewItem => Koha::AdditionalContent
- Koha::News => Koha::AdditionalContents
- Script and template renamed from koha-news to additional-contents
- Foreign keys have been renamed
- Subpermission edit_news has been renamed edit_additional_contents
- The UI can now be accessed via a "News" or "HTML customizations" link
from the tools module. The related contents will then be displayed (both
categories are now split)

Changes not done here:
- Primary key 'idnew' could be renamed 'id'

Limitations of the upgrade:
News cannot be grouped by a unique code for existing translations.
=> A given news will be now displayed several times on the translated
interface
Any ideas to improve the upgrade behaviour?
We will have to add a warning in the release notes to tell libraries to
review their news.

Test plan:
0. Don't apply the patches
1. Translate the interfaces in some languages
. Create some news for staff and OPAC
. Create some content for different entry of HTML customizations
Note that you are forced to define a 'default'.
Also note that you are only forced to fill the title (not the content).
This is certainly problematic (see FIXME in the code) as sometime only
the content is displayed.
. Play with the interface (edit, delete, filter)
. Go to the different places the news are displayed, and confirm they
are displayed correctly (staff home, opac home, opac rss)
. Create 1+ news for 'slip', check an item out and 'print slip' (from
the circulation page). You must see the news.
. Go to the different places you are expecting the HTML customizations
to be present and confirm that you see them.
. Switch the lang of the interface and confirm that you now see the
content in the translated version
. Generate the templates in another language, don't translate the
content
. Use this language for the interface and confirm that the 'default'
version is displauyed.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2021-08-16 11:55:55 +02:00

268 lines
14 KiB
Text

[% USE raw %]
[% USE Asset %]
[%# Includes %]
[% USE Koha %]
[% USE KohaDates %]
[% USE AdditionalContents %]
[%# Helper template functions %]
[% BLOCK error_message %]
[% IF messages.BadBarcode %]
<span>(Barcode not found on the database, please see library staff for assistance)</span>
[% ELSIF messages.Wrongbranch %]
<span>(The item cannot be checked in at this library, please see library staff for assistance)</span>
[% ELSIF messages.withdrawn %]
<span>(Item is withdrawn and check-in blocked by policy, please see library staff for assistance)</span>
[% ELSIF messages.NotIssued %]
<span>(The book is not currently on loan, please see library staff for assistance)</span>
[% ELSIF messages.additional_materials %]
<span>(The item cannot be checked in at a self service terminal, please see library staff for assistance)</span>
[% ELSE %]
<span>(There was a problem checking in this item, please see library staff for assistance)</span>
[% END %]
[% END %]
[% INCLUDE 'doc-head-open.inc' %]
[% SET OpacLangSelectorMode = Koha.Preference('OpacLangSelectorMode') %]
<title>Self check-in &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha [% END %]</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Koha [% Version | html %]" /> <!-- leave this for stats -->
[% IF ( Koha.Preference('OpacFavicon') ) %]
<link rel="shortcut icon" href="[% Koha.Preference('OpacFavicon') | url %]" type="image/x-icon" />
[% ELSE %]
<link rel="shortcut icon" href="[% interface | html %]/[% theme | html %]/images/favicon.ico" type="image/x-icon" />
[% END %]
[% IF ( bidi ) %]
[% Asset.css("lib/jquery/jquery-ui-rtl-1.12.1.min.css") | $raw %]
[% Asset.css("css/sco-rtl.css") | $raw %]
[% ELSE %]
[% Asset.css("lib/jquery/jquery-ui-1.12.1.css") | $raw %]
[% Asset.css("css/sco.css") | $raw %]
[% END %]
[% IF ( Koha.Preference('OPACUserCSS') ) %]<style>[% Koha.Preference('OPACUserCSS') | $raw %]</style>[% END %]
[% IF ( Koha.Preference('SelfCheckInUserCSS') ) %]<style>[% Koha.Preference('SelfCheckInUserCSS') | $raw %]</style>[% END %]
<script>
function _(s) { return s } // dummy function for gettext
</script>
[% Asset.js("lib/modernizr.min.js") | $raw %]
</head>
<body id="sci_main" class="sci" onload="dofocus();" onunload="mungeHistory();">
[% INCLUDE 'masthead-sci.inc' %]
<div class="main">
<div class="container-fluid">
<div class="row">
<div class="col order-first order-md-first order-lg-2">
<div id="masthead">
<h1>[% LibraryName | html %] Self check-in</h1>
</div>
[% IF ( nopermission ) %]
[%# This is what is displayed if user doesn't have permission %]
<div class="alert alert-warning">
<h2>Access denied</h2>
<p>Sorry, this self check-in station has lost authentication. Please contact the administrator to resolve this problem.</p>
</div>
[% ELSIF ( different_ip ) %]
[%# This is what is displayed if user doesn't have permission %]
<div class="alert alert-warning">
<h2>Session lost</h2>
<p>You are accessing self check-in from a different IP address! Please log in again.</p>
</div>
[% ELSIF ( checkins ) %]
[%# We have results from a check-in attempt %]
<div id="checkins" class="sci_results_list">
[% IF ( success && success.size > 0 || errors && errors.size > 0 ) %]
<table id="sci_bcheckins_table" class="table table-bordered table-striped dataTable no-footer">
<caption><h2>Results</h2></caption>
<thead>
<th>Barcode</th>
<th>Status</th>
</thead>
<tbody>
[% FOREACH success_line IN success %]
<tr>
<td>[% success_line.barcode | html %]</td>
<td>Checked in</td>
</tr>
[% END %]
[% FOREACH error IN errors %]
<tr>
<td>[% error.barcode | html %]</td>
<td>Not checked in [% PROCESS error_message messages=error.messages %]</td>
</tr>
[% END %]
</tbody>
</table>
<div>
<form method="post" action="#" id="finish_form">
<legend class="sr-only">Finish</legend>
<button id="sci_finish_button" type="submit" class="btn btn-primary"><i class="fa fa-check" aria-hidden="true"></i> Finish</button>
</form>
</div>
[% ELSE %]
<div class="alert alert-warning">
<p>Your request included no check-ins.</p>
</div>
[% END %]
</div>
[% ELSE %]
[%# Prompt for barcodes %]
<div id="new_checkins" class="sci_entry">
<form id="scan_form" name="scan_form" method="post" action="/cgi-bin/koha/sci/sci-main.pl">
<legend class="sr-only">Scan</legend>
<div class="row">
<div class="col-auto">
<label for="barcode_input">Scan the item or enter its barcode:</label>
</div>
<div class="col-4">
<input id="barcode_input" name="barcode_input" size="20" type="text" class="focus form-control" autocomplete="off" />
</div>
<div class="col-auto">
<button id="sci_append_button" type="submit" class="btn btn-primary">
Submit
</button>
</div>
</div> <!-- /.row -->
<div class="row">
<div class="col">
<div class="sci_input_append">
<table id="sci_barcodes_table" class="table table-bordered table-striped dataTable no-footer" style="display: none;">
<caption class="sr-only">Barcodes</caption>
<thead>
<th class="barcodes_column">Barcode</th>
</thead>
<tbody>
</tbody>
</table> <!-- /#sci_barcodes_table -->
</div> <!-- .sci_input_append -->
<input type="hidden" name="op" value="check_in" />
<div id="button_bar">
<button id="sci_checkin_button" type="submit" class="btn btn-primary" style="display: none;">
<i class="fa fa-check-square-o" aria-hidden="true"></i> <span>Check in</span>
</button>
<a href="/cgi-bin/koha/sci/sci-main.pl" class="btn btn-danger" role="button" style="display: none;" id="sci_refresh_button">
<i class="fa fa-times" aria-hidden="true"></i> <span>Cancel</span>
</a>
</div> <!-- /#button_bar -->
</div> <!-- /.col -->
</div> <!-- /.row -->
</form> <!-- /#scan_form -->
</div> <!-- / #new_checkins -->
[% END # /IF ( nopermission ) %]
</div> <!-- / #masthead -->
</div> <!-- / .row -->
</div> <!-- / .container-fluid -->
[% IF ( Koha.Preference('SelfCheckInMainUserBlock') ) %]
<div id="SelfCheckInMainUserBlock">[% Koha.Preference('SelfCheckInMainUserBlock' ) | $raw %]</div>
[% END %]
</div> <!-- / .main -->
[% # Help modal %]
<div id="helpModal" class="modal" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h2 id="helpModalLabel">Self check-in help</h2>
<button type="button" class="closebtn" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div> <!-- /.modal-header -->
<div class="modal-body">
<ul>
<li>Scan each item or enter its barcode. A list with the entered barcodes will be displayed.</li>
<li>Click the 'Check in' button to confirm.</li>
<li>The operation results will be displayed for each entered barcode.</li>
<li>The 'Finish' button is presented to start over.</li>
<li>At any step, clicking the 'Cancel' button will erase the scanned barcodes and start over.</li>
</ul>
</div> <!-- /.modal-body -->
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">Close</button>
</div>
</div> <!-- /.modal-content -->
</div> <!-- /.modal-dialog -->
</div> <!-- /#helpModal -->
</body>
[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
<script>
function mungeHistory() {
// prevent back button from allowing form resubmission
if (history && history.pushState) {
history.replaceState(null, document.title, window.location.href);
}
}
function dofocus() {
$(".focus:last").select();
}
var barcodes = [];
$(document).ready(function() {
// Barcodes scanning table initially hidden
$("#sci_barcodes_table").hide();
// Control de 'append' button behaviour
$("#sci_append_button").on('click',function( e ){
// Make sure the form is not submitted by the button
e.preventDefault();
var barcode = $('#barcode_input').val();
//var result = validate_barcode( barcode );
$('#sci_barcodes_table tbody').append(
'<tr style="font-size: initial;"><td>' +
barcode +
'<input type="hidden" name="barcode" value="' + barcode + '" />' +
'</td></tr>' );
// Make sure the table is now displayed
$("#sci_barcodes_table").show();
$('#sci_checkin_button').show();
$('#sci_refresh_button').show();
barcodes.push(barcode);
// clean the input, reset the focus
$('#barcode_input').val('');
dofocus();
});
$(".helpModal-trigger").on("click",function(e){
e.preventDefault();
$("#helpModal").modal("show");
});
// set focus at the beginning
dofocus();
});
var idleTime = 0;
$(document).ready(function () {
//Increment the idle time counter every second
var idleInterval = setInterval(timerIncrement, 1000);
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
});
$(this).keypress(function (e) {
idleTime = 0;
});
});
function timerIncrement() {
if ( $("#sci_finish_button").is(":visible") || $("#sci_refresh_button").is(":visible") ) {
idleTime = idleTime + 1;
idleTimeout = [% refresh_timeout | html %];
if (idleTime >= idleTimeout ) {
location.href = '/cgi-bin/koha/sci/sci-main.pl';
}
}
}
</script>
[% IF ( Koha.Preference('SelfCheckInUserJS') ) %]
<script>[% Koha.Preference('SelfCheckInUserJS') | $raw %]</script>
[% END %]
[% END %]