[% USE raw %]
[% USE Asset %]
[% USE Koha %]
[% USE KohaDates %]
[% USE AdditionalContents %]
[% USE KohaPlugins %]
[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %]
[% SET LoginEnabled = ( Koha.Preference('opacuserlogin') == 1 ) %]
[% IF ( Koha.Preference('TagsEnabled') ) %]
 [% SET TagsShowEnabled = ( ( Koha.Preference('TagsEnabled') == 1 ) && ( Koha.Preference('TagsShowOnList') > 0 ) ) %]
 [% SET TagsInputEnabled = LoginEnabled && TagsShowEnabled && ( Koha.Preference('TagsInputOnList') > 0 ) %]
[% END %]
[% SET CartEnabled = ( Koha.Preference('opacbookbag') == 1 ) %]
[% SET ListsEnabled = ( Koha.Preference('virtualshelves') == 1 ) && LoginEnabled %]
[% SET HoldsEnabled = ( Koha.Preference('OPACHoldRequests') == 1 ) && LoginEnabled %]
[% SET RecallsEnabled = ( Koha.Preference('UseRecalls') == 1 ) && LoginEnabled %]
[% SET ArticleRequestsEnabled = ( Koha.Preference('ArticleRequests') == 1 ) && LoginEnabled %]
[% SET MultiHolds = ( Koha.Preference('DisplayMultiPlaceHold') == 1 ) && HoldsEnabled %]
[% SET CoverImagePlugins = KohaPlugins.get_plugins_opac_cover_images %]
[% SET OPACLocalCoverImages = Koha.Preference('OPACLocalCoverImages') %]
[% SET OPACAmazonCoverImages = Koha.Preference('OPACAmazonCoverImages') %]
[% SET SyndeticsCoverImages = ( Koha.Preference('SyndeticsEnabled') && Koha.Preference('SyndeticsCoverImages') ) %]
[% SET GoogleJackets = Koha.Preference('GoogleJackets') %]
[% SET OpenLibraryCovers = Koha.Preference('OpenLibraryCovers') %]
[% SET BakerTaylorEnabled = Koha.Preference('BakerTaylorEnabled') %]
[% SET OPACCoce = ( Koha.Preference('OPACCoce') && Koha.Preference('CoceProviders') ) %]
[% IF ( CoverImagePlugins || OPACLocalCoverImages || OPACAmazonCoverImages || SyndeticsCoverImages || GoogleJackets || OpenLibraryCovers || BakerTaylorEnabled || OPACCoce || OPACCustomCoverImages ) %]
 [% SET CoverImages = 1 %]
 [% SET OPACCustomCoverImages = ( Koha.Preference('OPACCustomCoverImages') && Koha.Preference('CustomCoverImagesURL') ) %]
 [% SET OverDriveEnabled = Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') %]
[% END %]
[% SET OverDriveEnabled = ( Koha.Preference( "OPACOverDrive" ) && Koha.Preference('OverDriveLibraryID') && Koha.Preference('OverDriveClientKey') && Koha.Preference('OverDriveClientSecret') ) %]

[% BLOCK delete_shelf %]
 <form action="/cgi-bin/koha/opac-shelves.pl" method="post" id="deleteshelf[% shelf.shelfnumber | html %]" class="d-inline">
 [% INCLUDE 'csrf-token.inc' %]
 <input type="hidden" name="op" value="cud-delete" />
 <input type="hidden" name="referer" value="list" />
 <input type="hidden" name="public" value="[% public | html %]" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 <button
            type="submit"
            class="btn btn-link remove deleteshelf"
            data-shelfnumber="[% shelf.shelfnumber | html %]"
            data-shelfname="[% shelf.shelfname | html %]"
            data-shared="[% shelf.is_shared | html %]"
            data-count="[% contents.count | html %]"
        >
 <i class="fa fa-times" aria-hidden="true"></i>
 [% IF ( context == "list" ) %] Eliminar [% ELSE %] Eliminar lista [% END %] </button>
 </form>
[% END %]

[% INCLUDE 'doc-head-open.inc' %]
<title>[% IF op == 'view' %]Contenidos de [% shelf.shelfname | html %][% ELSE %]Tus listas[% END %] &rsaquo; [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha en línea[% END %] catálogo</title>
[% INCLUDE 'doc-head-close.inc' %]
[% BLOCK cssinclude %]
[% END %]
[% Asset.css("lib/Chocolat/css/chocolat.css") | $raw %]
</head>
[% IF ( loggedinusername ) %]
 [% INCLUDE 'bodytag.inc' bodyid='opac-userlists' bodyclass='scrollto' %]
[% ELSE %]
 [% INCLUDE 'bodytag.inc' bodyid='opac-lists' bodyclass='scrollto' %]
[% END %]

[% BLOCK list_permissions %]
 <li>
 <label for="allow_changes_from">Permitir cambios a los contenidos de: </label>
 <select name="allow_changes_from" id="allow_changes_from">
 [% IF shelf.allow_change_from_owner %]<option value="0">Nadie</option>[% ELSE %]<option value="0" selected="selected">Nadie</option>[% END %]

 [% IF shelf.allow_change_from_owner && (( !shelf.is_public && !shelf.is_shared ) || !shelf.allow_change_from_others ) %]
 <option value="1" selected="selected">Solo propietario</option>
 [% ELSE %]
 <option value="1">Solo propietario</option>
 [% END %]

 [% IF permitteduser == 1 %][% IF shelf.allow_change_from_permitted_staff %]<option value="4" selected="selected">Solo para personal habilitado</option>[% ELSE %]<option value="4">Solo para personal habilitado</option>[% END %][% END %]

 [% IF staffuser == 1 %][% IF shelf.allow_change_from_staff %]<option value="3" selected="selected">Solo para personal</option>[% ELSE %]<option value="3">Solo para personal</option>[% END %][% END %]

 [% IF shelf.allow_change_from_others %]<option value="2" selected="selected">Cualquiera que vea esta lista</option>[% ELSE %]<option value="2">Cualquiera que vea esta lista</option>[% END %]
 </select>
 &emsp; <span id="permitted_staff_remark" style="display:none;color:red;">El permiso "Solo para personal habilitado" no tiene ningún efecto real mientras que esta lista sea estrictamente privada.</span> &emsp;
 <span id="staff_remark" style="display:none;color:red;">El permiso "Solo para personal" no tiene ningún efecto real mientras que esta lista sea estrictamente privada.</span> &emsp;
 <span id="anyone_remark" style="display:none;color:red;">El permiso "Cualquiera" no tiene ningún efecto real, mientras que esta lista es estrictamente privada.</span>
 </li>
[% END %]

[% INCLUDE 'masthead.inc' %]
<main class="main">
 [% WRAPPER breadcrumbs %]
 [% IF ( loggedinusername ) %]
 [% WRAPPER breadcrumb_item %]
 <a href="/cgi-bin/koha/opac-user.pl">[% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a>
 [% END %]
 [% END %]

 [% IF op != 'list' %]
 [% WRAPPER breadcrumb_item %]
 <a href="/cgi-bin/koha/opac-shelves.pl">Listas</a>
 [% END %]
 [% ELSE %]
 [% WRAPPER breadcrumb_item bc_active= 1 %]
 <span>Listas</span>
 [% END %]
 [% END %]

 [% IF shelf and shelf.is_private %]
 [% IF op == 'view' OR op == 'edit_form' %]
 [% WRAPPER breadcrumb_item %]
 <a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;public=0">Sus listas</a>
 [% END %]
 [% ELSE %]
 [% WRAPPER breadcrumb_item bc_active= 1 %]
 <span>Sus listas</span>
 [% END %]
 [% END %]
 [% ELSIF shelf AND shelf.is_public %]
 [% IF op == 'view' %]
 [% WRAPPER breadcrumb_item %]
 <a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;public=1">Listas públicas</a>
 [% END %]
 [% ELSE %]
 [% WRAPPER breadcrumb_item bc_active= 1 %]
 <span>Listas públicas</span>
 [% END %]
 [% END %]
 [% END %]

 [% IF op == 'view' %]
 [% WRAPPER breadcrumb_item bc_active= 1 %]
 <span>Contenidos de <em>[% shelf.shelfname | html %]</em></span>
 [% END %]
 [% END %]

 [% IF op == 'add_form' %]
 [% WRAPPER breadcrumb_item bc_active= 1 %]
 <span>Crear nueva lista</span>
 [% END %]
 [% END %]

 [% IF op == 'edit_form' %]
 [% WRAPPER breadcrumb_item bc_active= 1 %]
 <span>Editar lista <em>[% shelf.shelfname | html %]</em></span>
 [% END %]
 [% END %]
 [% END #/ WRAPPER breadcrumbs %]

 <div class="container-fluid">
 <div class="row">
 [% SET column_class = "col order-first order-md-first order-lg-2" %]
 [% IF ( OpacNav || OpacNavBottom || loggedinusername ) %]
 [% column_class = "col-md-12 col-lg-10 order-1" %]
 <div class="col col-lg-2 order-2 order-lg-1">
 <div id="navigation"> [% INCLUDE 'navigation.inc' IsPatronPage=1 %] </div>
 </div>
 [% END %]

 <div class="[% column_class | html %]">
 <div id="usershelves" class="maincontent">
 [% FOR m IN messages %]
 [% SET alert_class = "alert alert-success" %]
 [% SWITCH m.type %]
 [% CASE 'message' %]
 [% alert_class = "alert alert-success" %]
 [% CASE 'error' %]
 [% alert_class = "alert alert-danger" %]
 [% END %]
 <div class="[% alert_class | html %]" role="alert">
 [% SWITCH m.code %]
 [% CASE 'error_on_update' %]
 <span>Se ha producido un error en la actualización de esta lista.</span>
 [% CASE 'error_on_insert' %]
 <span>Se ha producido un error en la creación de esta lista.</span>
 [% CASE 'error_on_delete' %]
 <span>Se ha producido un error en la eliminación de esta lista.</span>
 [% CASE 'error_on_add_biblio' %]
 <span>El ejemplar no ha sido agregado a la lista. Por favor, verifique que el ejemplar no se encuentre ya en la lista.</span>
 [% CASE 'error_on_remove_share' %]
 <span>El valor no ha sido removido.</span>
 [% CASE 'no_email_found' %]
 <span>No se encontró email para los usuarios que aceptaron compartir</span>
 [% CASE 'success_on_update' %]
 <span>Lista actualizada.</span>
 [% CASE 'success_on_insert' %]
 <span>Lista creada.</span>
 [% CASE 'success_on_delete' %]
 <span>Lista borrada.</span>
 [% CASE 'success_on_add_biblio' %]
 <span>El ejemplar ha sido agregado a la lista.</span>
 [% CASE 'success_on_remove_biblios' %]
 <span>El ítem ha sido eliminado de la lista.</span>
 [% CASE 'success_on_remove_share' %]
 <span>El valor ha sido removido.</span>
 [% CASE 'does_not_exist' %]
 <span>Esta lista no existe.</span>
 [% CASE 'item_does_not_exist' %]
 <span>Este ejemplar no existe.</span>
 [% CASE 'unauthorized_on_view' %]
 <span>Usted no tiene permiso para ver esta lista.</span>
 [% CASE 'unauthorized_on_insert' %]
 <span>No tiene permiso para crear una nueva lista.</span>
 [% CASE 'unauthorized_on_update' %]
 <span>Usted no tiene permiso para actualizar esta lista.</span>
 [% CASE 'unauthorized_on_delete' %]
 <span>No tiene permisos para eliminar esta lista.</span>
 [% CASE 'unauthorized_on_add_biblio' %]
 <span>Usted no tiene permiso para agregar un registro a esta lista.</span>
 [% CASE 'unauthorized_transfer' %]
 <span>Transferencia no permitida: usted o el usuario seleccionado no tienen los permisos requeridos.</span>
 [% CASE 'no_biblio_removed' %]
 <span>Ningún registro fue removido.</span>
 [% CASE 'new_owner_not_found' %]
 <span>El nuevo propietario no pudo ser encontrado.</span>
 [% CASE 'new_owner_has_no_share' %]
 <span>El nuevo propietario no ha compartido esta lista.</span>
 [% CASE 'Koha::Exceptions::Virtualshelf::DuplicateObject' %]
 <span>Se ha producido un error al crear la lista. El nombre [% shelfname | html %] ya existe.</span>
 [% CASE 'DBIx::Class::Exception' %]
 [% m.msg | html %]
 [% CASE %]
 [% m.code | html %]
 [% m.msg | html %]
 [% END %]
 </div>
 [% END %]

 [% IF shelf AND op == 'view' %]
 <h1>
 [% shelf.shelfname | html %]
 [% IF ( public ) %]
 <a aria-label="Suscribirse a la lista" class="rss-list-link noprint" href="[% OPACBaseURL | url %]/cgi-bin/koha/opac-shelves.pl?rss=1&op=view&shelfnumber=[% shelf.shelfnumber | uri %]">
 <i aria-hidden="true" class="fa fa-fw fa-rss rsssearchicon" title="Suscribirse a la lista"></i>
 </a>
 [% END %]
 </h1>

 [% IF ( itemsloop ) %]
 [% SET contents = shelf.get_contents %]
 [% IF ( contents.count ) %]<p>Esta lista contiene [% contents.count | html %] títulos</p>[% END %]
 <div id="floating" class="sticky">
 <div id="toolbar" class="toolbar clearfix">
 <div class="list-actions">
 <a class="btn btn-link newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form"><i class="fa fa-fw fa-plus" aria-hidden="true"></i> Nueva lista</a> <span class="sep">|</span>

 <div id="download-list" class="btn-group dropdown">
 <a aria-haspopup="menu" aria-label="Seleccione un formato y descargue la lista" class="btn btn-link dropdown-toggle" data-bs-toggle="dropdown" href="/cgi-bin/koha/opac-downloadshelf.pl?shelfnumber=[% shelf.shelfnumber | html %]" id="format"><i class="fa fa-fw fa-download" aria-hidden="true"></i> Descargar <b class="caret"></b
                                            ></a>
 <div class="dropdown-menu pull-left" role="menu" aria-labelledby="format">
 <a role="menuitem" class="dropdown-item download-list" data-format="bibtex" href="#">BibTex</a>
 [% IF Koha.Preference('OPACISBD') %]<a role="menuitem" class="dropdown-item download-list" data-format="isbd" href="#">ISBD</a>[% END %]
 <a role="menuitem" class="dropdown-item download-list" data-format="iso2709" href="#">MARC</a>
 <a role="menuitem" class="dropdown-item download-list" data-format="ris" href="#">Formato RIS (Zotero, EndNote, others)</a>
 [% FOREACH csv_profile IN csv_profiles %]
 <a role="menuitem" class="dropdown-item download-list" data-format="[% csv_profile.export_format_id | html %]" href="#">CSV - [% csv_profile.profile | html %]</a>
 [% END %]
 </div>
 </div>

 [% IF ( Koha.Preference( 'opacuserlogin' ) == 1 ) && ( ! Koha.Preference('OPACDisableSendList') ) %]
 <span class="sendlist"
                                                ><a href="/cgi-bin/koha/opac-sendshelf.pl?shelfid=[% shelf.shelfnumber | uri %]" class="btn btn-link send"><i class="fa fa-fw fa-envelope" aria-hidden="true"></i> Enviar lista</a></span
                                            >
 [% END %]

 <a
                                            class="btn btn-link print-small"
                                            target="_blank"
                                            href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | html %]&sortfield=[% sortfield | html %]&direction=[% direction | uri %]&print=1"
                                            ><i class="fa fa-fw fa-print" aria-hidden="true"></i> Imprimir lista</a
                                        >

 [% IF can_manage_shelf %]
 <span class="sep">|</span>
 <form method="get" action="/cgi-bin/koha/opac-shelves.pl" class="d-inline">
 <input type="hidden" name="op" value="edit_form" />
 <input type="hidden" name="referer" value="view" />
 <input type="hidden" name="public" value="[% shelf.public | html %]" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 <button type="submit" class="btn btn-link editshelf"><i class="fa-fw fa-solid fa-pencil" aria-hidden="true"></i> Editar lista</button>
 </form>

 [% PROCESS delete_shelf context = "details" %]

 [% IF !public && Koha.Preference('OpacAllowSharingPrivateLists') %]
 <a href="/cgi-bin/koha/opac-shareshelf.pl?op=show&shelfnumber=[% shelf.shelfnumber | uri %]" class="btn btn-link sharelist"><i class="fa fa-fw fa-share" aria-hidden="true"></i> Compartir lista</a>
 [% END %]
 [% ELSIF !public # not manageshelf and private means shared %]
 <form action="/cgi-bin/koha/opac-shelves.pl" method="post" id="unshare[% shelf.shelfnumber | html %]" class="d-inline">
 [% INCLUDE 'csrf-token.inc' %]
 <input type="hidden" name="op" value="cud-remove_share" />
 <input type="hidden" name="referer" value="list" />
 <input type="hidden" name="public" value="[% public | html %]" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 <button type="submit" class="btn btn-link remove remove_share" data-shelfname="[% shelf.shelfname | html %]" data-shelfnumber="[% shelf.shelfnumber | html %]">
 <i class="fa fa-times" aria-hidden="true"></i> Retirar compartir </button>
 </form>
 [% END # /IF can_manage_shelf %]
 </div>
 <!-- /.list-actions -->

 <form method="get" action="/cgi-bin/koha/opac-shelves.pl" id="sorting-form" class="d-inline sort_by">
 <input type="hidden" name="op" value="view" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />

 <label for="sortfield">Ordenar por : </label>
 <select name="sortfield" id="sortfield" class="resort">
 <option value="">Orden predeterminado</option>
 <optgroup label="Autor">
 [% IF sortfield == 'author' && direction == 'asc' %]
 <option value="author" data-direction="asc" selected="selected">Autor (A-Z)</option>
 [% ELSE %]
 <option value="author" data-direction="asc">Autor (A-Z)</option>
 [% END %]
 [% IF sortfield == 'author' && direction == 'desc' %]
 <option value="author" data-direction="desc" selected="selected">Autor (Z-A)</option>
 [% ELSE %]
 <option value="author" data-direction="desc">Autor (Z-A)</option>
 [% END %]
 </optgroup>
 <optgroup label="Título">
 [% IF sortfield == 'title' && direction == 'asc' %]
 <option value="title" data-direction="asc" selected="selected">Título (A-Z)</option>
 [% ELSE %]
 <option value="title" data-direction="asc">Título (A-Z)</option>
 [% END %]
 [% IF sortfield == 'title' && direction == 'desc' %]
 <option value="title" data-direction="desc" selected="selected">Título (Z-A)</option>
 [% ELSE %]
 <option value="title" data-direction="desc">Título (Z-A)</option>
 [% END %]
 </optgroup>
 <optgroup label="Signatura topográfica">
 [% IF sortfield == 'itemcallnumber' && direction == 'asc' %]
 <option value="itemcallnumber" data-direction="asc" selected="selected">Signatura topográfica (A-Z)</option>
 [% ELSE %]
 <option value="itemcallnumber" data-direction="asc">Signatura topográfica (A-Z)</option>
 [% END %]
 [% IF sortfield == 'itemcallnumber' && direction == 'desc' %]
 <option value="itemcallnumber" data-direction="desc" selected="selected">Signatura topográfica (Z-A)</option>
 [% ELSE %]
 <option value="itemcallnumber" data-direction="desc">Signatura topográfica (Z-A)</option>
 [% END %]
 </optgroup>
 <optgroup label="Fecha de copyright">
 [% IF sortfield == 'copyrightdate' && direction == 'asc' %]
 <option value="copyrightdate" data-direction="desc" selected="selected">Fecha de copyright (nuevos a viejos)</option>
 [% ELSE %]
 <option value="copyrightdate" data-direction="desc">Fecha de copyright (nuevos a viejos)</option>
 [% END %]
 [% IF sortfield == 'copyrightdate' && direction == 'desc' %]
 <option value="copyrightdate" data-direction="asc" selected="selected">Fecha de copyright (viejos a nuevos)</option>
 [% ELSE %]
 <option value="copyrightdate" data-direction="asc">Fecha de copyright (viejos a nuevos)</option>
 [% END %]
 </optgroup>
 <optgroup label="Fecha de agregado">
 [% IF sortfield == "dateadded" && direction == 'asc' %]
 <option value="dateadded" data-direction="desc" selected="selected">Fecha de ingreso (nuevos a viejos)</option>
 [% ELSE %]
 <option value="dateadded" data-direction="desc">Fecha de ingreso (nuevos a viejos)</option>
 [% END %]
 [% IF sortfield == "dateadded" && direction == 'desc' %]
 <option value="dateadded" data-direction="asc" selected="selected">Fecha de ingreso (viejos a nuevos)</option>
 [% ELSE %]
 <option value="dateadded" data-direction="asc">Fecha de ingreso (viejos a nuevos)</option>
 [% END %]
 </optgroup>
 </select>

 <input class="btn btn-primary btn-sm" id="sort-submit" type="submit" value="Reordenar lista" />
 </form>
 <!-- /#sorting-form -->
 </div>
 <!-- / #toolbar -->
 [% INCLUDE 'result-batch-controls.inc' %]
 </div>
 <!-- /#floating -->

 <form action="/cgi-bin/koha/opac-shelves.pl" method="post" id="myform" name="bookbag_form">
 [% INCLUDE 'csrf-token.inc' %]
 [% IF can_manage_shelf %]
 <input type="hidden" name="op" value="cud-remove_biblios" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 [% END %]
 <div class="searchresults">
 <table id="listcontents" class="table">
 <tbody>
 [% FOREACH itemsloo IN itemsloop %]
 <tr>
 [% IF ( itemsloo.title ) %]
 [% check_title = itemsloo.title %]
 [% ELSE %]
 [% check_title = itemsloo.biblionumber %]
 [% END %]
 <td class="select selectcol"
                                                        ><input type="checkbox" class="cb" name="biblionumber" value="[% itemsloo.biblionumber | html %]" data-title="[% itemsloo.title | html %]" aria-label="[% check_title | html %]"
                                                    /></td>
 [% UNLESS ( item_level_itypes ) %]
 <td>
 [% UNLESS ( Koha.Preference('OpacNoItemTypeImages') ) %]
 <img class="itemtype-image" src="[% itemsloo.imageurl | html %]" alt="" />
 [% END %]
 <span class="itypetext">[% itemsloo.description | html %]</span>
 </td>
 [% END %]
 <td>
 <div class="coverimages"> [% INCLUDE 'cover-images.inc' SEARCH_RESULT=itemsloo %] </div>

 [% itemsloo.XSLTBloc | $raw %]

 [% IF itemsloo.shelves.count %]
 <div class="results_summary shelves">
 <span class="label">Listas:</span>
 <ul>
 [% FOREACH item_shelf IN itemsloo.shelves %]
 <li>
 <a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% item_shelf.shelfnumber | uri %]">[% item_shelf.shelfname | html %]</a>
 [%~ UNLESS loop.last %],[% ELSE %].[% END ~%]
 </li>
 [% END %]
 </ul>
 </div>
 [% END %]

 [% IF ( TagsShowEnabled && itemsloo.TagLoop.size ) %]
 <div class="results_summary tags">
 <span class="label">Etiquetas:</span>
 <ul>
 [% FOREACH TagLoo IN itemsloo.TagLoop %]
 <li
                                                                            ><a href="/cgi-bin/koha/opac-search.pl?tag=[% TagLoo.term | uri %]&amp;q=[% TagLoo.term | uri %]">[% TagLoo.term | html %]</a>
 <span class="weight">([% TagLoo.weight_total | html %])</span></li
                                                                        >
 [% END %]
 </ul>
 </div>
 [% END %]

 [% INCLUDE 'title-actions-menu.inc' items=itemsloo %]

 [% INCLUDE "openlibrary-readapi.inc" bib = itemsloo %]
 <!-- COinS / Openurl -->
 <span class="Z3988" title="[% itemsloo.coins | html %]"></span>
 </td>
 </tr>
 [% END # / FOREACH itemsloop %]
 </tbody>
 </table>
 <!-- / #listcontents --> </div
                                ><!-- / .searchresults -->

 [% IF ( pagination_bar ) %]
 <div class="pages">[% pagination_bar | $raw %]</div>
 [% END %]

 [% IF can_remove_biblios %]
 <input type="hidden" name="op" value="cud-remove_biblios" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 <input type="hidden" name="modifyshelfcontents" value="1" />
 <input class="btn btn-danger removeitems" id="remove-selected" type="submit" value="Eliminar ítems seleccionados" />
 [% END %]
 </form>
 <!-- /myform -->
 [% IF can_manage_shelf %]
 <form action="/cgi-bin/koha/opac-shelves.pl" method="post" id="shelf_delete_title">
 [% INCLUDE 'csrf-token.inc' %]
 <input type="hidden" name="op" value="cud-remove_biblios" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 <input type="hidden" name="biblionumber" id="shelf_delete_biblionumber" value="" />
 <input type="hidden" name="modifyshelfcontents" value="1" />
 </form>
 [% END %]
 <form id="hold_form" name="hold_form" method="get" action="/cgi-bin/koha/opac-reserve.pl">
 <!-- The value will be set by holdBiblioNums() in basket.js -->
 <input id="hold_form_biblios" type="hidden" name="biblionumbers" value="" />
 </form>
 [% ELSE %]
 <div id="toolbar" class="toolbar clearfix">
 <div class="list-actions">
 <a class="btn btn-link newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form"><i class="fa fa-fw fa-plus" aria-hidden="true"></i> Nueva lista</a>
 [% IF can_manage_shelf %]
 <span class="sep">|</span>
 <form method="get" action="/cgi-bin/koha/opac-shelves.pl" class="d-inline">
 <input type="hidden" name="op" value="edit_form" />
 <input type="hidden" name="referer" value="view" />
 <input type="hidden" name="public" value="[% shelf.public | html %]" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 <button type="submit" class="btn btn-link editshelf"><i class="fa-fw fa-solid fa-pencil" aria-hidden="true"></i> Editar lista</button>
 </form>

 [% PROCESS delete_shelf context = "details" %]
 [% END %]
 </div>
 <!-- / .list-actions -->
 </div>
 <!-- / #toolbar -->

 <div class="alert alert-info">
 <span>Esta lista esta vacía.</span>
 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
 <span>Puede agregar a sus listas desde los resultados de cualquier <a href="opac-main.pl">buscar</a>.</span>
 [% END %]
 </div>
 [% END # / IF itemsloop %]
 [% END # /IF shelf AND op == 'view' %]

 [% IF op == 'add_form' OR op == 'edit_form' %]
 <form method="post" action="/cgi-bin/koha/opac-shelves.pl">
 [% INCLUDE 'csrf-token.inc' %]
 <fieldset class="rows">
 [% IF op == 'add_form' %]
 <div id="addshelf">
 <legend><h1>Crear nueva lista</h1></legend>
 <input type="hidden" name="op" value="cud-add" />
 </div>
 [% ELSE %]
 <legend
                                        ><h1>Revisión <em>[% shelf.shelfname | html %]</em></h1></legend
                                    >
 <input type="hidden" name="op" value="cud-edit" />
 <input type="hidden" name="referer" value="[% referer | html %]" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 [% END %]
 <input type="hidden" name="owner" id="owner" value="[% loggedinusernumber | html %]" />
 <ol>
 <li>
 <label class="required" for="shelfname">Nombre de la lista: </label>
 <input type="text" id="shelfname" name="shelfname" maxlength="255" value="[% shelf.shelfname | html %]" required="required" class="focus required" />
 <span class="required">Requerido</span></li
                                    >
 <li>
 <label for="sortfield">Ordenar esta lista por: </label>
 <select name="sortfield" id="sortfield">
 [% IF shelf.sortfield == "title" %]
 <option value="title" selected="selected">Título</option>
 [% ELSE %]
 <option value="title">Título</option>
 [% END %]
 [% IF shelf.sortfield == "author" %]
 <option value="author" selected="selected">Autor</option>
 [% ELSE %]
 <option value="author">Autor</option>
 [% END %]
 [% IF shelf.sortfield == "copyrightdate" %]
 <option value="copyrightdate" selected="selected">Año</option>
 [% ELSE %]
 <option value="copyrightdate">Año</option>
 [% END %]
 [% IF shelf.sortfield == "itemcallnumber" %]
 <option value="itemcallnumber" selected="selected">Signatura topográfica</option>
 [% ELSE %]
 <option value="itemcallnumber">Signatura topográfica</option>
 [% END %]
 [% IF shelf.sortfield == "dateadded" %]
 <option value="dateadded" selected="selected">Fecha de agregado</option>
 [% ELSE %]
 <option value="dateadded">Fecha de agregado</option>
 [% END %]
 </select>
 </li>
 [% IF Koha.Preference('OpacAllowPublicListCreation') OR public == 1 %]
 <li>
 <label for="public">Categoría:</label>
 <select name="public" id="public">
 [% IF shelf.is_private %]
 <option value="0" selected="selected">Privada</option>
 [% ELSE %]
 <option value="0">Privada</option>
 [% END %]
 [% IF shelf.is_public %]
 <option value="1" selected="selected">Pública</option>
 [% ELSE %]
 <option value="1">Pública</option>
 [% END %]
 </select>
 [% IF shelf.is_public AND NOT Koha.Preference('OpacAllowPublicListCreation') %]
 <span class="hint alert alert-info"
                                                    >La biblioteca ha deshabilitado la capacidad de sus usuarios para crear nuevas listas públicas. Si usted hace su lista privada, usted no será capaz de hacerla pública de nuevo.</span
                                                >
 [% END %]
 </li>
 [% END %]
 [% INCLUDE list_permissions %]
 </ol>
 [% UNLESS Koha.Preference('OpacAllowPublicListCreation') OR public == 1 %]
 <input type="hidden" name="public" value="0" />
 [% END %]
 </fieldset>
 <!-- /.rows -->

 <fieldset class="action">
 <input class="btn btn-primary" type="submit" value="Guardar" />
 [% IF referer == 'view' %]
 <a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% shelf.shelfnumber | uri %]" class="cancel">Cancelar</a>
 [% ELSE %]
 <a href="/cgi-bin/koha/opac-shelves.pl?op=list" class="cancel">Cancelar</a>
 [% END %]
 </fieldset>
 </form>
 [% ELSIF op == 'transfer' %]
 <h1>Transferir a otro propietario la lista compartida '[% shelf.shelfname | html %]'</h1>
 <br />
 <form action="/cgi-bin/koha/opac-shelves.pl" id="transferform" method="post">
 [% INCLUDE 'csrf-token.inc' %]
 <fieldset>
 <input type="hidden" name="op" value="cud-transfer" />
 <input type="hidden" name="public" value="0" />
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 <div>
 <label for="find_patron">Nuevo propietario: </label>
 <select name="new_owner" id="new_owner">
 [% FOREACH sharee IN shared_users %]
 <option value="[% sharee.borrowernumber | html %]" selected="">[% sharee.email | html %]</option>
 [% END %]
 </select>
 </div>
 <br />
 <fieldset class="action">
 <input class="submit" type="submit" value="Transferir" />
 <a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;public=0" class="cancel">Cancelar</a>
 </fieldset>
 </fieldset>
 </form>
 [% ELSIF op == 'list' %]
 <h1>Listas</h1>
 <div class="toptabs">
 <ul class="nav nav-tabs" id="list-tabs" role="tablist">
 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
 <li id="privateshelves_tab" class="nav-item" role="presentation">
 <a
                                            class="[% !public ? 'nav-link active' : 'nav-link' %]"
                                            id="your_lists"
                                            href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;public=0"
                                            data-tabname="your_lists"
                                            aria-controls="privateshelves"
                                            role="tab"
                                            aria-selected="[% !public ? 'true' : 'false' | html %]"
                                            >Sus listas</a
                                        >
 </li>
 <li id="publicshelves_tab" class="nav-item" role="presentation">
 <a
                                            class="[% public ? 'nav-link active' : 'nav-link' %]"
                                            id="public_lists"
                                            href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;public=1"
                                            data-tabname="public_lists"
                                            aria-controls="publicshelves"
                                            role="tab"
                                            aria-selected="[% public ? 'true' : 'false' | html %]"
                                            >Listas públicas</a
                                        >
 </li>
 [% END %]
 </ul>

 <div class="tab-content">
 [% IF !public %]
 <div id="privateshelves" class="tab-pane active" role="tabpanel" aria-labelledby="your_lists"> </div>
 [% ELSE %]
 <div id="publicshelves" class="tab-pane active" role="tabpanel" aria-labelledby="public_lists"> </div>
 [% END %]

 [% SET show_new_list = 0 %]
 [% IF !public || Koha.Preference('OpacAllowPublicListCreation') %]
 [% IF loggedinusername %]
 [% show_new_list = 1 %]
 [% ELSE %]
 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
 <div class="alert alert-info"><a href="/cgi-bin/koha/opac-shelves.pl?op=add_form">Ingrese para crear una nueva lista</a></div>
 [% END %]
 [% END %]
 [% END %]

 [% IF shelves.count %]
 <div id="toolbar" class="toolbar">
 [% IF ( show_new_list ) %]
 <a class="btn btn-link newshelf" href="/cgi-bin/koha/opac-shelves.pl?op=add_form"><i class="fa fa-plus" aria-hidden="true"></i> Nueva lista</a> <span class="sep">|</span>
 [% END %]
 <div class="btn-group dropdown">
 <button type="button" class="btn btn-link dropdown-toggle" data-bs-toggle="dropdown" id="sortmenu" aria-haspopup="true" aria-expanded="false"
                                                ><i class="fa fa-sort" aria-hidden="true"></i> Ordenar</button
                                            >
 <div class="dropdown-menu dropdown-menu-end" aria-labelledby="sortmenu">
 <a class="dropdown-item" href="/cgi-bin/koha/opac-shelves.pl?op=list&public=[% public | html %]&sortfield=">Orden predeterminado</a>
 <span class="dropdown-header">Nombre de lista</span>
 <a class="dropdown-item" href="/cgi-bin/koha/opac-shelves.pl?op=list&public=[% public | html %]&sortfield=shelfname&direction=asc">Nombre de la lista (A-Z)</a>
 <a class="dropdown-item" href="/cgi-bin/koha/opac-shelves.pl?op=list&public=[% public | html %]&sortfield=shelfname&direction=desc">Nombre de la lista (Z-A)</a>
 <span class="dropdown-header">Fecha de modificación</span>
 <a class="dropdown-item" href="/cgi-bin/koha/opac-shelves.pl?op=list&public=[% public | html %]&sortfield=lastmodified&direction=desc">Fecha de modificación (nuevos a viejos)</a>
 <a class="dropdown-item" href="/cgi-bin/koha/opac-shelves.pl?op=list&public=[% public | html %]&sortfield=lastmodified&direction=asc">Fecha de modificación (viejos a nuevos)</a>
 </div>
 </div>
 </div>
 <table class="table">
 [% IF !public %]
 <caption class="sr-only">Sus listas</caption>
 [% ELSIF public %]
 <caption class="sr-only">Listas públicas</caption>
 [% END %]
 <thead>
 <tr>
 <th>Nombre de lista</th>
 <th>Contenidos</th>
 <th>Tipo</th>
 <th>Fecha de modificación</th>
 <th>&nbsp;</th>
 </tr>
 </thead>
 <tbody>
 [% FOREACH s IN shelves %]
 [% SET contents = s.get_contents %]
 <tr>
 <td><a href="/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=[% s.shelfnumber | uri %]">[% s.shelfname | html %]</a></td>
 <td>[% IF contents.count %][% contents.count | html %] [% IF contents.count == 1 %]<span>ejemplar</span>[% ELSE %]<span>ítems</span>[% END %][% ELSE %]<span>Vacío</span>[% END %]</td>
 <td>
 [% IF s.is_private %]
 [% IF s.is_shared %]<span>Compartida</span>[% ELSE %]<span>Privada</span>[% END %]
 [% ELSE %]
 <span>Pública</span>
 [% END %]
 </td>
 <td>[% s.lastmodified | $KohaDates %]</td>
 <td class="d-print-none">
 [% IF s.can_be_managed( loggedinusernumber ) %]
 <form action="/cgi-bin/koha/opac-shelves.pl" method="get" class="d-inline">
 <input type="hidden" name="shelfnumber" value="[% s.shelfnumber | html %]" />
 <input type="hidden" name="public" value="[% s.public | html %]" />
 <input type="hidden" name="op" value="edit_form" />
 <input type="hidden" name="referer" value="list" />
 <button type="submit" class="btn btn-link editshelf"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Editar</button>
 </form>
 [% END %]
 [% IF s.can_be_deleted( loggedinusernumber ) %]
 [% PROCESS delete_shelf shelf = s context = "list" %]
 [% END %]
 [% IF s.is_private AND s.can_be_managed( loggedinusernumber ) AND Koha.Preference('OpacAllowSharingPrivateLists') %]
 <a href="/cgi-bin/koha/opac-shareshelf.pl?op=show&shelfnumber=[% s.shelfnumber | uri %]" class="sharelist btn btn-link"><i class="fa fa-share" aria-hidden="true"></i> Compartir</a>
 [% END %]
 [% IF s.is_shared AND s.can_be_managed( loggedinusernumber ) %]
 <form action="/cgi-bin/koha/opac-shelves.pl" method="get" class="d-inline">
 <input type="hidden" name="shelfnumber" value="[% s.shelfnumber | html %]" />
 <input type="hidden" name="public" value="0" />
 <input type="hidden" name="op" value="cud-transfer" />
 <input type="hidden" name="referer" value="list" />
 <button type="submit" class="btn btn-link transfershelf"> Transferir</button>
 </form>
 [% END %]
 [% IF s.is_shared_with( loggedinusernumber ) %]
 <form action="opac-shelves.pl" method="post" id="unshare[% s.shelfnumber | html %]" class="d-inline">
 [% INCLUDE 'csrf-token.inc' %]
 <input type="hidden" name="op" value="cud-remove_share" />
 <input type="hidden" name="referer" value="list" />
 <input type="hidden" name="public" value="[% public | html %]" />
 <input type="hidden" name="shelfnumber" value="[% s.shelfnumber | html %]" />
 <button type="submit" class="btn btn-link remove remove_share" data-shelfname="[% s.shelfname | html %]" data-shelfnumber="[% s.shelfnumber | html %]"
                                                                    ><i class="fa fa-remove" aria-hidden="true"></i> Retirar compartir</button
                                                                >
 </form>
 [% END %]&nbsp;
 </td>
 </tr>
 [% END %]
 </tbody>
 </table>
 <!-- /.table -->
 <div class="pages" id="pagination_bottom"> [% pagination_bar | $raw %] </div>
 [% ELSE %]
 [% IF public %]
 <p>No hay listas públicas.</p>
 [% ELSIF loggedinusernumber %]
 <p>Ninguna lista privada.</p>
 [% END %]
 [% END # /IF shelves.count %]
 </div>
 <!-- /.tab-content -->
 </div>
 <!-- /.toptabs -->
 [% ELSIF NOT loggedinusernumber %]
 [% IF Koha.Preference( 'opacuserlogin' ) == 1 %]
 <div class="alert alert-info"><a href="/cgi-bin/koha/opac-shelves.pl?op=add_form">Ingrese para crear una nueva lista</a></div>
 [% END %]
 [% END  # IF op == 'add_form' OR op == 'edit_form' %]
 </div>
 <!-- / #usershelves -->
 </div>
 <!-- / .col-lg-10/12 -->
 </div>
 <!-- / .row -->
 </div>
 <!-- / .container-fluid -->
</main>
<!-- / .main -->

<form method="get" id="download_list" action="/cgi-bin/koha/opac-downloadshelf.pl">
 <input type="hidden" name="shelfnumber" value="[% shelf.shelfnumber | html %]" />
 <input type="hidden" name="format" id="download_format" value="" />
</form>

[% INCLUDE 'opac-bottom.inc' %]
[% BLOCK jsinclude %]
 [% Asset.js("lib/Chocolat/js/chocolat.js") | $raw %]
 [% CoverImagePlugins | $raw %]
 [% IF OpenLibraryCovers || OpenLibrarySearch %]
 [% Asset.js("js/openlibrary.js") | $raw %]
 [% END %]
 <script>
        const loggedinusername = [% ( loggedinusername ) ? 1 : 0 | html %];
        const opacbookbag = [% ( opacbookbag ) ? 1 : 0 | html %];
        const virtualshelves = [% ( virtualshelves ) ? 1 : 0 | html %];
    </script>
 [% Asset.js("js/results-list.js") | $raw %]
 [% Asset.js("js/cover_images.js") | $raw %]
 <script>
        let counter_wait = 0;
        function wait_for_images(cb){

            var loaded = 1;
            counter_wait++;

            [% IF GoogleJackets %]
                if ( loaded ) {
                    loaded = KOHA.Google.done;
                }
            [% END %]

            [% IF OpenLibraryCovers %]
                if ( loaded ) {
                    loaded = KOHA.OpenLibrary.done;
                }
            [% END %]

            [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
                if ( loaded ) {
                    loaded = KOHA.coce.done;
                }
            [% END %]

            if (!loaded && counter_wait < 50) {// Do not wait more than 5 seconds
                window.setTimeout(function(){wait_for_images(cb);}, 100);
            } else {
                if (counter_wait >= 50 ) {
                }
                cb();
            }
        }

        $(window).load(function() {
            wait_for_images(verify_cover_images);
        });


        [% IF ( TagsInputEnabled && loggedinusername ) %]
            function tagSelected() {
                var checkedBoxes = $("input:checkbox:checked");
                if ($(checkedBoxes).size()) {
                    $("#tagsel_tag").hide();
                    $(".tag_hides").hide();
                    $("#tagsel_form").show();
                } else {
                    alert( _("Ningún ítem seleccionado") );
                }
            }

            function tagCanceled() {
                $("#tagsel_form").hide();
                $("#tagsel_tag").show();
                $(".tag_hides").show();
                $("#tagsel_new").val("");
                $(".tagstatus").empty().hide();
            }

            function tagAdded() {
                var checkedBoxes = $("input:checkbox:checked");
                if (!$(checkedBoxes).size()) {
                    alert( _("Ningún ítem seleccionado") );
                    return false;
                }

                var tag = $("#tagsel_new").val();
                if (!tag || (tag == "")) {
                    alert( _("No se especificó etiqueta.") );
                    return false;
                }

                var bibs = [];
                for (var i = 0; i < $(checkedBoxes).size(); i++) {
                    var box = $(checkedBoxes).get(i);
                    bibs[i] = $(box).val();
                }

                KOHA.Tags.add_multitags_button(bibs, tag);
                return false;
            }
        [% END %]

        $(function() {
            $("a.print").show();

            [% IF ( TagsInputEnabled && loggedinusername ) %]
                var tagAdd = $(".tag_add");
                tagAdd.removeClass("hidden");
                $("#tagsel_tag").click(function(){
                    tagSelected();
                    return false;
                });
                $("#tagsel_cancel").click(function(){
                    tagCanceled();
                    return false;
                });
                $("#tagsel_button").click(function(){
                    tagAdded();
                    return false;
                });

                tagAdd.click(function(){
                    var thisid = $(this).attr("id");
                    thisid = thisid.replace("tag_add","");
                    $(this).hide();
                    $("#tagform"+thisid).show();
                    $("#newtag"+thisid).focus();
                    $("#newtag"+thisid+"_status").empty().hide();
                    return false;
                });
                $(".cancel_tag_add").click(function(){
                    var thisid = $(this).attr("id");
                    thisid = thisid.replace("cancel","");
                    $("#tagform"+thisid).hide();
                    $("#tag_add"+thisid).show();
                    $("#newtag"+thisid).val("");
                    $("#newtag"+thisid+"_status").empty().hide();
                    return false;
                });
                $(".tagbutton").click(function(){
                  var thisid = $(this).attr("title");
                  var tag = $("#newtag"+thisid).val();
                  if (!tag || (tag == "")) {
                      alert( _("No se especificó etiqueta.") );
                      return false;
                  }
                  KOHA.Tags.add_tag_button(thisid, tag);
                  return false;
                });
            [% END %]

            [% IF loggedinusername && can_remove_biblios %]
                $("body").on("click", ".removeitems", function(e){
                    e.preventDefault();
                    var title;
                    var yes_label;
                    var no_label;
                    var message = "";
                    var biblionumber;
                    /* Single "Remove from list" link has a biblionumber data-attribute */
                    if( $(this).data("biblionumber") ){
                        /* Use the checkbox with that value to preview the title in the confirmation */
                        var selected_titles = $(".cb[value='" + $(this).data("biblionumber") + "'");
                        biblionumber = $(this).data("biblionumber");
                    } else {
                        var selected_titles = $(".cb:checked");
                    }
                    if ( selected_titles.size() < 1 ) {
                        alert( _("Ningún ítem seleccionado") );
                    } else {
                        if( selected_titles.size() > 1 ){
                            message = $("<ul></ul>");
                            title = _("¿Está seguro que desea eliminar estos ítems de la lista?");
                            yes_label = _("Si, eliminar de la lista");
                            no_label = _("No, no eliminar de la lista");
                            selected_titles.each(function(){
                                message.append( "<li>" +  $(this).data("title") + "</li>" );
                            });
                        } else {
                            title = _("¿Está seguro de querer remover este ejemplar de la lista?");
                            yes_label = _("Si, eliminar de la lista");
                            no_label = _("No, no eliminar de la lista");
                            selected_titles.each(function(){
                                message += $(this).data("title");
                            });
                        }
                        confirmModal( message, title, yes_label, no_label, function( result ){
                            if( result ){
                                if( biblionumber ){
                                    $("#shelf_delete_biblionumber").val( biblionumber );
                                    $("#shelf_delete_title").submit();
                                } else {
                                    $("#myform").submit();
                                }
                            }
                        });
                    }
                });
            [% END %]

            [% IF OpenLibraryCovers %]KOHA.OpenLibrary.GetCoverFromIsbn();[% END %]
            [% IF OPACLocalCoverImages %]KOHA.LocalCover.GetCoverFromBibnumber(false);[% END %]
            [% IF ( GoogleJackets ) %]KOHA.Google.GetCoverFromIsbn();[% END %]
            [% IF ( Koha.Preference('OpacCoce') && Koha.Preference('CoceProviders') ) %]
                KOHA.coce.getURL('[% Koha.Preference('CoceHost') | html %]', '[% Koha.Preference('CoceProviders') | html %]');
            [% END %]

            [% IF print %]
                window.print();
                window.onafterprint = function () {
                    window.close();
                }
                setTimeout('window.close()', 1000); // Hack for Chrome < 63
            [% END %]

            AdjustRemark();

            [% IF itemsloop %]
                sortMenu( $("#sorting-form") );

                $("#sortfield").on("change", function(){
                    $('#sorting-form').submit();
                });
            [% END %]

            $(".deleteshelf").on("click", function(e){
                e.preventDefault();
                var shelf_name = $(this).data("shelfname");
                var shelf_number = $(this).data("shelfnumber");
                var is_shared = $(this).data("shared");
                var count = $(this).data("count");
                var message = "<p><em>" + shelf_name + "</em></p>";
                if( count ){
                    message += "<p>" + _("Ítems en esta lista:") + " <strong>" + count + "</strong></p>";
                }
                if( is_shared ){
                    message += "<p>" + _("Esta lista es compartida. Otros usuarios perderán el acceso a ella.") + "</p>";
                }
                confirmModal( message, _("¿Está seguro de querer eliminar esta lista?"), _("Sí, eliminar"), _("No, no eliminar"), function( result ){
                        if( result ){
                            $("#deleteshelf" + shelf_number ).submit();
                        }
                    }
                );
            });

            $(".remove_share").on("click", function(e){
                e.preventDefault();
                var shelf_name = $(this).data("shelfname");
                var shelf_number = $(this).data("shelfnumber");
                confirmModal( shelf_name, _("¿Está seguro que quiere eliminar el uso compartido? Ya no tendrá acceso a la lista."), _("Sí, eliminar el acceso compartido"), _("No, no eliminar acceso compartido"), function( result ){
                        if( result ){
                            $("#unshare" + shelf_number ).submit();
                        }
                    }
                );
            });

            $(".download-list").on("click", function(e){
                e.preventDefault();
                var format = $(this).data("format");
                $("#download_format").val( format );
                $("#download_list").submit();
            });

            $("#allow_changes_from, #public").on("change", function(){
                AdjustRemark();
            });

            $(".send").on("click", function(e){
                e.preventDefault();
                let link = this.href;
                Dopop( link );
            });

        }); // document.ready

        function sortMenu( sorting_form ){
            var shelfnumber = sorting_form.find("input[name='shelfnumber']").val();
            var sort_link = "/cgi-bin/koha/opac-shelves.pl?op=view&amp;shelfnumber=" + shelfnumber + "&sortfield=";
            var menu = "<div class=\"btn-group dropdown\"><button type=\"button\" class=\"btn btn-link dropdown-toggle\" data-bs-toggle=\"dropdown\" id=\"sortmenu\" aria-haspopup=\"true\" aria-expanded=\"false\"><i class=\"fa fa-sort\" aria-hidden=\"true\"></i> " + _("Ordenar") + "</span></button><div class=\"dropdown-menu dropdown-menu-end\" aria-labelledby=\"sortmenu\">";
            $("#sortfield").children().each(function(){
                if( $(this)[0].tagName.toUpperCase() == "OPTION" ){
                    menu += "<a class=\"dropdown-item\" href=\"" + sort_link + $(this).val() + "\">" + $(this).text() + "</a>";
                } else if( $(this)[0].tagName.toUpperCase() == "OPTGROUP" ){
                    menu += "<span class=\"dropdown-header\">" + $(this).attr("label") + "</span>";
                    $(this).children().each(function(){
                        if( $(this)[0].tagName.toUpperCase() == "OPTION" ){
                            menu += "<a class=\"dropdown-item\" href=\"" + sort_link + $(this).val() + "&direction=" + $(this).data('direction') + "\">" + $(this).text() + "</a>";
                        }
                    });
                }
            });
            menu += "</div>";
            $(".list-actions").append( menu );
            sorting_form.remove();
        }

        function AdjustRemark() {
            var public;
            if( $("#public").length > 0 ) {
                public = $("#public").val();
            } else {
                public = "[% public | html %]";
            }
            var perms = $("#allow_changes_from").val();

            if( perms < 2 ) {
                $("#anyone_remark").hide();
                $("#staff_remark").hide();
                $("#permitted_staff_remark").hide();
            } else if( public==0 ) {
                // If we move to Private (without shares), show Anyone remark
                // Note: the number of shares is not tested real-time
                [% IF !shelf.is_shared %]
                    if ( perms==2 ) {
                        $("#anyone_remark").show();
                        $("#staff_remark").hide();
                        $("#permitted_staff_remark").hide();
                    } else if ( perms==3 ) {
                        $("#anyone_remark").hide();
                        $("#staff_remark").show();
                        $("#permitted_staff_remark").hide();
                    } else if ( perms==4 ) {
                        $("#anyone_remark").hide();
                        $("#staff_remark").hide();
                        $("#permitted_staff_remark").show();
                    }
                [% ELSE %]
                    $("#anyone_remark").hide();
                    $("#staff_remark").hide();
                    $("#permitted_staff_remark").hide();
                [% END %]
            } else { // public==1
                $("#anyone_remark").hide();
                $("#staff_remark").hide();
                $("#permitted_staff_remark").hide();
            }
        }
    </script>
[% END %]
