Owen Leonard
640124829a
This patch revises the staff client list contents view to better match staff client search results, showing more information and offering more ways to interact with the contents than before. - List contents output has been modified so that the staff client can use XSLT-formatted data just as the OPAC can. As in the OPAC it depends on XSLTResultsDisplay being enabled. - A "toolbar" has been added which is similar to that in search results, offering the option to add items to a Cart, add them to a different list, place multiple holds, remove items from the list, or merge records. - This toolbar has been made to float on scroll like the one on the MARC edit page. - Library and shelving location have been added to the display of call numbers. Call numbers are linked to a search as they are in search results. - Edit links are included just as they are in search results. - Automatic focus on the add by barcode form has been removed so that the page doesn't jump to the bottom unnecessarily. - basket.js's "addMultiple" function has been modified so that it receives an array of checkboxes rather than looking for checkboxes in a specific form. This helps abstract its functionality for use on both search results and lists. results.tt is modified accordingly. - The page layout has been widened to make room for the increased amount of information on the page. - A new "merge" icon has been added to the default Bootstrap sprite. To test: - View both public and private lists in the staff client. - View lists with and without contents. - Test the functionality of options in the toolbar: Add to cart, add to lists, place multiple holds, remove items, merge items. - Test with users with and without cataloging privileges to confirm that catalog-related controls are correctly shown or hidden. - Test with XSLTResultsDisplay set both to "default" and empty. - Since the staff client and OPAC use some of the same code, test that lists in the OPAC have not broken. - Since JavaScript was modified which affects both lists and search results, confirm that adding items to the Cart and Lists from search results hasn't been broken by this patch. Revision corrects conditional display of hold link, hiding it in cases where there are no items or the record's itemtype is not for loan. Also corrected is the behavior of the Cart/List "save" button in order to prevent it from submitting the "remove items" action which is the default for the form. Signed-off-by: jmbroust <jean-manuel.broust@univ-lyon2.fr> Edit: Patch rebased against current master and hard-coded paths to /prog/ corrected. Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> Signed-off-by: Galen Charlton <gmc@esilibrary.com>
445 lines
12 KiB
JavaScript
445 lines
12 KiB
JavaScript
//////////////////////////////////////////////////////////////////////////////
|
|
// BASIC FUNCTIONS FOR COOKIE MANAGEMENT //
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
var CGIBIN = "/cgi-bin/koha/";
|
|
|
|
var nameCookie = "intranet_bib_list";
|
|
var nameParam = "bib_list";
|
|
var valCookie = readCookie(nameCookie);
|
|
|
|
if(valCookie){
|
|
var arrayRecords = valCookie.split("/");
|
|
if(arrayRecords.length > 0){
|
|
var basketcount = arrayRecords.length-1;
|
|
} else {
|
|
var basketcount = "";
|
|
}
|
|
} else {
|
|
var basketcount = "";
|
|
}
|
|
|
|
function writeCookie(name, val, wd) {
|
|
if (wd) {
|
|
parent.opener.document.cookie = name + "=" + val + "; path=/";
|
|
}
|
|
else {
|
|
parent.document.cookie = name + "=" + val + "; path=/";
|
|
}
|
|
}
|
|
|
|
function readCookieValue (str, val_beg) {
|
|
var val_end = str.indexOf(";", val_end);
|
|
if (val_end == -1)
|
|
val_end = str.length;
|
|
return str.substring(val_beg, val_end);
|
|
}
|
|
|
|
function readCookie(name, wd) {
|
|
var str_name = name + "=";
|
|
var str_len = str_name.length;
|
|
var str_cookie = "";
|
|
if (wd) {
|
|
str_cookie = parent.opener.document.cookie;
|
|
}
|
|
else {
|
|
str_cookie = parent.document.cookie;
|
|
}
|
|
// fixed - getting the part of the basket that is bib_list
|
|
var cookie_parts = str_cookie.split(";");
|
|
for(var i=0;i < cookie_parts.length;i++) {
|
|
var c = cookie_parts[i];
|
|
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
|
if(c.indexOf(str_name) == 0) return c.substring(str_name.length,c.length);
|
|
}
|
|
return null;
|
|
}
|
|
|
|
function delCookie(name) {
|
|
var exp = new Date();
|
|
exp.setTime(exp.getTime()-1);
|
|
if(parent.opener){
|
|
parent.opener.document.cookie = name + "=null; path=/; expires=" + exp.toGMTString();
|
|
} else {
|
|
document.cookie = name + "=null; path=/; expires=" + exp.toGMTString();
|
|
}
|
|
}
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
// SPECIFIC FUNCTIONS USING COOKIES //
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
function openBasket() {
|
|
var strCookie = "";
|
|
var valCookie = readCookie(nameCookie);
|
|
if ( valCookie ) {
|
|
strCookie = nameParam + "=" + valCookie;
|
|
}
|
|
|
|
if ( strCookie ) {
|
|
var iW = 820;
|
|
var iH = 450;
|
|
var optWin = "status=yes,scrollbars=yes,resizable=yes,toolbar=no,location=yes,height="+iH+",width="+iW;
|
|
var loc = CGIBIN + "basket/basket.pl?" + strCookie;
|
|
var basket = open(loc, "basket", optWin);
|
|
if (window.focus) {basket.focus()}
|
|
}
|
|
else {
|
|
showCartUpdate(MSG_BASKET_EMPTY);
|
|
}
|
|
}
|
|
|
|
function addRecord(val, selection,NoMsgAlert) {
|
|
var valCookie = readCookie(nameCookie);
|
|
var write = 0;
|
|
|
|
if ( ! valCookie ) { // empty basket
|
|
valCookie = val + '/';
|
|
write = 1;
|
|
updateBasket(1);
|
|
}
|
|
else {
|
|
// is this record already in the basket ?
|
|
var found = false;
|
|
var arrayRecords = valCookie.split("/");
|
|
for (var i = 0; i < valCookie.length - 1; i++) {
|
|
if (val == arrayRecords[i]) {
|
|
found = true;
|
|
break;
|
|
}
|
|
}
|
|
if ( found ) {
|
|
if (selection) {
|
|
return 0;
|
|
}
|
|
if (! NoMsgAlert ) {
|
|
showCartUpdate(MSG_RECORD_IN_BASKET);
|
|
}
|
|
}
|
|
else {
|
|
valCookie += val + '/';
|
|
write = 1;
|
|
updateBasket(arrayRecords.length);
|
|
}
|
|
}
|
|
|
|
if (write) {
|
|
writeCookie(nameCookie, valCookie);
|
|
if (selection) { // when adding a selection of records
|
|
return 1;
|
|
}
|
|
if (! NoMsgAlert ) {
|
|
showCartUpdate(MSG_RECORD_ADDED);
|
|
}
|
|
}
|
|
}
|
|
|
|
function AllAreChecked(s){
|
|
if (! s.length) { return false;}
|
|
var l = s.length;
|
|
for (var i=0; i < l; i++) {
|
|
if(! s[i].checked) { return false; }
|
|
}
|
|
return true;
|
|
}
|
|
|
|
function SelectAll(){
|
|
if(document.bookbag_form.biblionumber.length > 0) {
|
|
var checky = AllAreChecked(document.bookbag_form.biblionumber);
|
|
var l = document.bookbag_form.biblionumber.length;
|
|
for (var i=0; i < l; i++) {
|
|
document.bookbag_form.biblionumber[i].checked = (checky) ? false : true;
|
|
}
|
|
}
|
|
}
|
|
|
|
function addMultiple(biblist){
|
|
var c_value = "";
|
|
if(biblist.length > 0) {
|
|
for (var i=0; i < biblist.length; i++) {
|
|
if (biblist[i].checked) {
|
|
c_value = c_value + biblist[i].value + "/";
|
|
}
|
|
}
|
|
addSelRecords(c_value);
|
|
} else {
|
|
c_value = c_value + biblist.value + "/";
|
|
addSelRecords(c_value);
|
|
}
|
|
}
|
|
|
|
function addSelRecords(valSel) { // function for adding a selection of biblios to the basket
|
|
// from the results list
|
|
var arrayRecords = valSel.split("/");
|
|
var i = 0;
|
|
var nbAdd = 0;
|
|
for (i=0;i<arrayRecords.length;i++) {
|
|
if (arrayRecords[i]) {
|
|
nbAdd += addRecord(arrayRecords[i], 1);
|
|
}
|
|
else {
|
|
break;
|
|
}
|
|
}
|
|
var msg = "";
|
|
if (nbAdd) {
|
|
if (i > nbAdd) {
|
|
msg = nbAdd+" "+MSG_NRECORDS_ADDED+", "+(i-nbAdd)+" "+MSG_NRECORDS_IN_BASKET;
|
|
}
|
|
else {
|
|
msg = nbAdd+" "+MSG_NRECORDS_ADDED;
|
|
}
|
|
}
|
|
else {
|
|
if (i < 1) {
|
|
msg = MSG_NO_RECORD_SELECTED;
|
|
}
|
|
else {
|
|
msg = MSG_NO_RECORD_ADDED+" ("+MSG_NRECORDS_IN_BASKET+") !";
|
|
}
|
|
}
|
|
showCartUpdate(msg);
|
|
}
|
|
|
|
function showCartUpdate(msg){
|
|
// set body of popup window
|
|
$("#cartDetails").html(msg);
|
|
showCart();
|
|
setTimeout("hideCart()",2000);
|
|
}
|
|
|
|
function showListsUpdate(msg){
|
|
// set body of popup window
|
|
alert(msg);
|
|
}
|
|
|
|
function selRecord(num, status) {
|
|
var str = document.myform.records.value
|
|
if (status){
|
|
str += num+"/";
|
|
}
|
|
else {
|
|
str = delRecord(num, str);
|
|
}
|
|
|
|
document.myform.records.value = str;
|
|
}
|
|
|
|
function delSelRecords() {
|
|
var recordsSel = 0;
|
|
var end = 0;
|
|
var valCookie = readCookie(nameCookie, 1);
|
|
|
|
if (valCookie) {
|
|
var str = document.myform.records.value;
|
|
if (str.length > 0){
|
|
recordsSel = 1;
|
|
var str2 = valCookie;
|
|
while (!end){
|
|
s = str.indexOf("/");
|
|
if (s>0){
|
|
num = str.substring(0, s)
|
|
str = delRecord(num,str);
|
|
str2 = delRecord(num,str2);
|
|
} else {
|
|
end = 1;
|
|
}
|
|
}
|
|
|
|
if (str2.length == 0) { // equivalent to emptying the basket
|
|
var rep = false;
|
|
rep = confirm(MSG_CONFIRM_DEL_BASKET);
|
|
if (rep) {
|
|
delCookie(nameCookie);
|
|
document.location = "about:blank";
|
|
updateBasket(0,top.opener);
|
|
window.close();
|
|
} else {
|
|
return;
|
|
}
|
|
} else {
|
|
writeCookie(nameCookie, str2, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (recordsSel) {
|
|
var strCookie = "";
|
|
var valCookie = readCookie(nameCookie, 1);
|
|
strCookie = nameParam + "=" + valCookie;
|
|
var arrayRecords = valCookie.split("/");
|
|
updateBasket(arrayRecords.length-1,top.opener);
|
|
document.location = CGIBIN + "basket/basket.pl?" + strCookie;
|
|
}
|
|
else {
|
|
alert(MSG_NO_RECORD_SELECTED);
|
|
}
|
|
}
|
|
|
|
function delRecord (n, s) {
|
|
var re = /\d/;
|
|
var aux = s;
|
|
var found = 0;
|
|
var pos = -1;
|
|
|
|
while (!found) {
|
|
pos = aux.indexOf(n, pos+1);
|
|
var charAfter = aux.charAt(pos+n.length); // character right after the researched string
|
|
if (charAfter.match(re)) { // record number inside another one
|
|
continue;
|
|
}
|
|
else { // good record number
|
|
aux = s.substring(0, pos)+ s.substring(pos+n.length+1, s.length);
|
|
s = aux;
|
|
found = 1;
|
|
}
|
|
}
|
|
|
|
return s;
|
|
}
|
|
|
|
|
|
function delBasket(context,rep) {
|
|
if (rep == undefined){
|
|
rep = confirm(MSG_CONFIRM_DEL_BASKET);
|
|
}
|
|
if (rep) {
|
|
if(context == "popup"){
|
|
delCookie(nameCookie);
|
|
document.location = "about:blank";
|
|
updateBasket(0,top.opener);
|
|
window.close();
|
|
} else {
|
|
delCookie(nameCookie);
|
|
updateBasket(0,top.opener);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
function quit() {
|
|
if (document.myform.records.value) {
|
|
var rep = false;
|
|
rep = confirm(MSG_CONFIRM_DEL_RECORDS);
|
|
if (rep) {
|
|
delSelRecords();
|
|
}
|
|
}
|
|
updateBasket(arrayRecords.length-1,top.opener);
|
|
window.close();
|
|
}
|
|
|
|
function sendBasket() {
|
|
var valCookie = readCookie(nameCookie);
|
|
var strCookie = nameParam + "=" + valCookie;
|
|
|
|
var loc = CGIBIN + "basket/sendbasket.pl?" + strCookie;
|
|
|
|
var optWin="scrollbars=no,resizable=no,height=300,width=450,top=50,left=100";
|
|
var win_form = open(loc,"win_form",optWin);
|
|
}
|
|
|
|
function downloadBasket() {
|
|
var valCookie = readCookie(nameCookie);
|
|
var strCookie = nameParam + "=" + valCookie;
|
|
|
|
var loc = CGIBIN + "basket/downloadcart.pl?" + strCookie;
|
|
|
|
open(loc,"win_form",'scrollbars=no,resizable=no,height=300,width=450,top=50,left=100');
|
|
}
|
|
|
|
function printBasket() {
|
|
var loc = document.location + "&print=1";
|
|
document.location = loc;
|
|
}
|
|
|
|
function showMore() {
|
|
var strCookie = "";
|
|
|
|
var valCookie = readCookie(nameCookie);
|
|
if (valCookie) {
|
|
strCookie = nameParam + "=" + valCookie;
|
|
}
|
|
var loc = CGIBIN + "basket/basket.pl?" + strCookie + "&verbose=1";
|
|
document.location = loc;
|
|
}
|
|
|
|
function showLess() {
|
|
var strCookie = "";
|
|
|
|
var valCookie = readCookie(nameCookie);
|
|
if (valCookie) {
|
|
strCookie = nameParam + "=" + valCookie;
|
|
}
|
|
var loc = CGIBIN + "basket/basket.pl?" + strCookie + "&verbose=0";
|
|
document.location = loc;
|
|
}
|
|
|
|
function updateBasket(updated_value,target) {
|
|
if(target){
|
|
target.$('#basketcount').html(" <span>("+updated_value+")</span>");
|
|
target.$('#cartDetails').html(MSG_IN_YOUR_CART+updated_value);
|
|
} else {
|
|
$('#basketcount').html(" <span>("+updated_value+")</span>");
|
|
$('#cartDetails').html(MSG_IN_YOUR_CART+updated_value);
|
|
}
|
|
var basketcount = updated_value;
|
|
}
|
|
|
|
function openBiblio(dest,biblionumber) {
|
|
openerURL=dest+"?biblionumber="+biblionumber;
|
|
opener.document.location = openerURL;
|
|
opener.focus();
|
|
}
|
|
|
|
function addSelToShelf() {
|
|
var items = document.getElementById('records').value;
|
|
if(items){
|
|
document.location = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumber="+items;
|
|
} else {
|
|
alert(MSG_NO_RECORD_SELECTED);
|
|
}
|
|
}
|
|
|
|
/// vShelfAdd() builds url string for multiple-biblio adds.
|
|
|
|
function vShelfAdd(biblist) {
|
|
bibs = new Array();
|
|
if(biblist.length > 0) {
|
|
for (var i=0; i < biblist.length; i++) {
|
|
if (biblist[i].checked) {
|
|
bibs.push("biblionumber=" + biblist[i].value);
|
|
}
|
|
}
|
|
if (bibs.length == 0) { showListsUpdate(MSG_NO_RECORD_SELECTED); }
|
|
return bibs.join("&");
|
|
} else {
|
|
if (biblist.checked) {
|
|
return "biblionumber=" + biblist.value;
|
|
}
|
|
}
|
|
}
|
|
|
|
function showCart(){
|
|
var position = $("#cartmenulink").offset();
|
|
var scrolld = $(window).scrollTop();
|
|
var top = position.top + $("#cartmenulink").outerHeight();
|
|
if( scrolld > top ){
|
|
top = scrolld + 15;
|
|
}
|
|
var left = position.left
|
|
$("#cartDetails").css("position","absolute").css("top",top);
|
|
$("#cartDetails").css("position","absolute").css("left",left);
|
|
$("#cartDetails").fadeIn("fast");
|
|
}
|
|
|
|
function hideCart(){
|
|
$("#cartDetails").fadeOut("fast");
|
|
}
|
|
|
|
$(document).ready(function(){
|
|
$("#cartmenulink").click(function(){ openBasket(); return false; });
|
|
if(basketcount){ updateBasket(basketcount); }
|
|
});
|
|
|
|
|