Lines 10-21
require.config( {
Link Here
|
10 |
themelang: '[% themelang %]', |
10 |
themelang: '[% themelang %]', |
11 |
}, |
11 |
}, |
12 |
}, |
12 |
}, |
13 |
paths: { |
|
|
14 |
pz2: '../../pz2', |
15 |
}, |
16 |
shim: { |
17 |
pz2: { exports: 'pz2' }, |
18 |
}, |
19 |
} ); |
13 |
} ); |
20 |
</script> |
14 |
</script> |
21 |
|
15 |
|
Lines 27-56
require.config( {
Link Here
|
27 |
|
21 |
|
28 |
<script> |
22 |
<script> |
29 |
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'preferences', 'resources', 'text-marc', 'widget' ], function( KohaBackend, Search, Macros, MARCEditor, MARC, Preferences, Resources, TextMARC, Widget ) { |
23 |
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'preferences', 'resources', 'text-marc', 'widget' ], function( KohaBackend, Search, Macros, MARCEditor, MARC, Preferences, Resources, TextMARC, Widget ) { |
30 |
var z3950Targets = { |
24 |
var z3950Servers = { |
31 |
[% FOREACH target = z3950_targets %] |
25 |
[% FOREACH server = z3950_servers %] |
32 |
'[% target.host %]:[% target.port %]/[% target.db %]': { |
26 |
[% server.id %]: { |
33 |
'name': '[% target.name %]', |
27 |
'name': '[% server.name %]', |
34 |
'authentication': '[% target.userid %]:[% target.password %]', |
28 |
'kohasyntax': '[% server.syntax == 'USMARC' ? 'MARC21' : server.syntax %]', |
35 |
'syntax': '[% target.syntax %]', |
29 |
'checked': [% server.checked ? 'true' : 'false' %], |
36 |
'kohasyntax': '[% target.syntax == 'USMARC' ? 'MARC21' : target.syntax %]', |
|
|
37 |
'encoding': '[% target.encoding %]', |
38 |
'checked': [% target.checked ? 'true' : 'false' %], |
39 |
}, |
30 |
}, |
40 |
[% END %] |
31 |
[% END %] |
41 |
}; |
32 |
}; |
42 |
|
33 |
|
43 |
// The columns that should show up in a search, in order, and keyed by the corresponding <metadata> tag in the XSL and Pazpar2 config |
34 |
// The columns that should show up in a search, in order, and keyed by the corresponding <metadata> tag in the XSL and Pazpar2 config |
44 |
var z3950Labels = [ |
35 |
var z3950Labels = [ |
45 |
[ "md-work-title", _("Title") ], |
36 |
[ "title", _("Title") ], |
46 |
[ "md-series-title", _("Series Title") ], |
37 |
[ "series", _("Series Title") ], |
47 |
[ "md-work-author", _("Author") ], |
38 |
[ "author", _("Author") ], |
48 |
[ "md-lccn", _("LCCN") ], |
39 |
[ "lccn", _("LCCN") ], |
49 |
[ "md-isbn", _("ISBN") ], |
40 |
[ "isbn", _("ISBN") ], |
50 |
[ "md-issn", _("ISSN") ], |
41 |
[ "issn", _("ISSN") ], |
51 |
[ "md-medium", _("Medium") ], |
42 |
[ "medium", _("Medium") ], |
52 |
[ "md-edition", _("Edition") ], |
43 |
[ "edition", _("Edition") ], |
53 |
[ "md-description", _("Description") ], |
44 |
[ "notes", _("Notes") ], |
54 |
]; |
45 |
]; |
55 |
|
46 |
|
56 |
var state = { |
47 |
var state = { |
Lines 132-141
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
132 |
|
123 |
|
133 |
$('#quicksearch .search-box').each( function() { |
124 |
$('#quicksearch .search-box').each( function() { |
134 |
shortcut.add( 'enter', $.proxy( function() { |
125 |
shortcut.add( 'enter', $.proxy( function() { |
135 |
var q = this.value; |
126 |
var terms = []; |
136 |
if (!q) return false; |
127 |
|
|
|
128 |
$('#quicksearch .search-box').each( function() { |
129 |
if ( !this.value ) return; |
130 |
|
131 |
terms.push( [ $(this).data('qualifier'), this.value ] ); |
132 |
} ); |
133 |
|
134 |
if ( !terms.length ) return; |
137 |
|
135 |
|
138 |
if ( Search.Start( z3950Targets, $(this).data('qualifier') + q, 20 ) ) { |
136 |
if ( Search.Run( z3950Servers, Search.JoinTerms(terms) ) ) { |
|
|
137 |
$("#search-overlay").show(); |
139 |
showResultsBox(); |
138 |
showResultsBox(); |
140 |
} |
139 |
} |
141 |
|
140 |
|
Lines 166-172
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
166 |
}, |
165 |
}, |
167 |
'catalog': { |
166 |
'catalog': { |
168 |
titleForRecord: _("Editing catalog record #{ID}"), |
167 |
titleForRecord: _("Editing catalog record #{ID}"), |
169 |
href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber={ID}", |
168 |
links: [ |
|
|
169 |
{ title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber={ID}" }, |
170 |
{ title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber={ID}" }, |
171 |
], |
170 |
saveLabel: _("Save to catalog"), |
172 |
saveLabel: _("Save to catalog"), |
171 |
get: function( id, callback ) { |
173 |
get: function( id, callback ) { |
172 |
if ( !id ) return false; |
174 |
if ( !id ) return false; |
Lines 206-213
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
206 |
get: function( id, callback ) { |
208 |
get: function( id, callback ) { |
207 |
if ( !id ) return false; |
209 |
if ( !id ) return false; |
208 |
|
210 |
|
209 |
Search.GetDetailedRecord( decodeURIComponent(id), callback ); |
211 |
callback( backends.search.records[ id ] ); |
210 |
}, |
212 |
}, |
|
|
213 |
records: {}, |
211 |
}, |
214 |
}, |
212 |
}; |
215 |
}; |
213 |
|
216 |
|
Lines 221-233
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
221 |
|
224 |
|
222 |
document.location.hash = '#' + parts[0] + ':' + parts[1]; |
225 |
document.location.hash = '#' + parts[0] + ':' + parts[1]; |
223 |
|
226 |
|
224 |
if ( backend.href ) { |
227 |
$('#title').text( backend.titleForRecord.replace( '{ID}', parts[1] ) ); |
225 |
$( '#title' ).html( backend.titleForRecord.replace( '{ID}', parts[1] ) + ' <a target="_blank" href="' + backend.href.replace( '{ID}', parts[1] ) + '">' + _("(view)") + '</a>' ); |
228 |
|
226 |
} else { |
229 |
$.each( backend.links || [], function( i, link ) { |
227 |
$( '#title' ).text( backend.titleForRecord.replace( '{ID}', parts[1] ) ); |
230 |
$('#title').append(' <a target="_blank" href="' + link.href.replace( '{ID}', parts[1] ) + '">(' + link.title + ')</a>' ); |
228 |
} |
231 |
} ); |
229 |
$( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.replace( '{ID}', parts[1] ) ); |
232 |
$( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.replace( '{ID}', parts[1] ) ); |
230 |
$( '#save-record span' ).text( backends[ state.saveBackend ].saveLabel ); |
233 |
$('#save-record span').text( backends[ state.saveBackend ].saveLabel ); |
231 |
} |
234 |
} |
232 |
|
235 |
|
233 |
function saveRecord( recid, editor, callback ) { |
236 |
function saveRecord( recid, editor, callback ) { |
Lines 313-345
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
313 |
|
316 |
|
314 |
$('#advanced-search-ui').modal('hide'); |
317 |
$('#advanced-search-ui').modal('hide'); |
315 |
|
318 |
|
316 |
if ( Search.Start( z3950Targets, search, 20 ) ) { |
319 |
if ( Search.Run( z3950Servers, search, 20 ) ) { |
|
|
320 |
$("#search-overlay").show(); |
317 |
showResultsBox(); |
321 |
showResultsBox(); |
318 |
} |
322 |
} |
319 |
} |
323 |
} |
320 |
|
324 |
|
321 |
function showResultsBox(data) { |
325 |
function showResultsBox(data) { |
|
|
326 |
$('#search-top-pages, #search-bottom-pages').find('.pagination').empty(); |
322 |
$('#searchresults thead tr').empty(); |
327 |
$('#searchresults thead tr').empty(); |
323 |
$('#searchresults tbody').empty(); |
328 |
$('#searchresults tbody').empty(); |
324 |
$('#search-targetsinfo').empty().append('<li>' + _("Loading...") + '</li>'); |
329 |
$('#search-serversinfo').empty().append('<li>' + _("Loading...") + '</li>'); |
325 |
$('#search-results-ui').modal('show'); |
330 |
$('#search-results-ui').modal('show'); |
326 |
} |
331 |
} |
327 |
|
332 |
|
328 |
function showSearchResults( editor, data ) { |
333 |
function showSearchResults( editor, data ) { |
|
|
334 |
backends.search.records = {}; |
335 |
|
329 |
$('#searchresults thead tr').empty(); |
336 |
$('#searchresults thead tr').empty(); |
330 |
$('#searchresults tbody').empty(); |
337 |
$('#searchresults tbody').empty(); |
|
|
338 |
$('#search-serversinfo').empty(); |
339 |
|
340 |
$.each( data.num_fetched, function( server_id, num_fetched ) { |
341 |
if ( num_fetched < data.num_hits[server_id] ) { |
342 |
num_fetched += '+'; |
343 |
} |
344 |
|
345 |
$('#search-serversinfo').append( '<li>' + z3950Servers[server_id].name + ' (' + num_fetched + ')' + '</li>' ); |
346 |
} ); |
331 |
|
347 |
|
332 |
var seenColumns = {}; |
348 |
var seenColumns = {}; |
333 |
|
349 |
|
334 |
$.each( data.hits, function( undef, hit ) { |
350 |
$.each( data.hits, function( undef, hit ) { |
335 |
for ( key in hit ) { |
351 |
$.each( hit.metadata, function(key) { |
336 |
if ( /^md-/.test(key) ) seenColumns[key] = true; |
352 |
seenColumns[key] = true; |
337 |
} |
|
|
338 |
|
339 |
$.each( hit.location, function( undef, location ) { |
340 |
for ( key in location ) { |
341 |
if ( /^md-/.test(key) ) seenColumns[key] = true; |
342 |
} |
343 |
} ); |
353 |
} ); |
344 |
} ); |
354 |
} ); |
345 |
|
355 |
|
Lines 354-369
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
354 |
$('#searchresults thead tr').append('<th>' + _("Tools") + '</th>'); |
364 |
$('#searchresults thead tr').append('<th>' + _("Tools") + '</th>'); |
355 |
|
365 |
|
356 |
$.each( data.hits, function( undef, hit ) { |
366 |
$.each( data.hits, function( undef, hit ) { |
|
|
367 |
backends.search.records[ hit.server + '-' + hit.index ] = hit.record; |
368 |
hit.id = 'search:' + hit.server + '-' + hit.index; |
369 |
|
357 |
var result = '<tr>'; |
370 |
var result = '<tr>'; |
358 |
result += '<td class="sourcecol">' + hit.location[0]['@name'] + '</td>'; |
371 |
result += '<td class="sourcecol">' + z3950Servers[ hit.server ].name + '</td>'; |
359 |
|
372 |
|
360 |
$.each( z3950Labels, function( undef, label ) { |
373 |
$.each( z3950Labels, function( undef, label ) { |
361 |
if ( !seenColumns[ label[0] ] ) return; |
374 |
if ( !seenColumns[ label[0] ] ) return; |
362 |
|
375 |
|
363 |
if ( hit[ label[0] ] ) { |
376 |
if ( hit.metadata[ label[0] ] ) { |
364 |
result += '<td class="infocol">' + hit[ label[0] ].join('<br/>') + '</td>'; |
377 |
result += '<td class="infocol">' + hit.metadata[ label[0] ] + '</td>'; |
365 |
} else if ( hit.location[0][ label[0] ] ) { |
|
|
366 |
result += '<td class="infocol">' + hit.location[0][ label[0] ].join('<br/>') + '</td>'; |
367 |
} else { |
378 |
} else { |
368 |
result += '<td class="infocol"> </td>'; |
379 |
result += '<td class="infocol"> </td>'; |
369 |
} |
380 |
} |
Lines 376-385
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
376 |
|
387 |
|
377 |
var $tr = $( result ); |
388 |
var $tr = $( result ); |
378 |
$tr.find( '.marc-link' ).click( function() { |
389 |
$tr.find( '.marc-link' ).click( function() { |
379 |
Search.GetDetailedRecord( hit.recid, function( record ) { |
390 |
var $info_columns = $tr.find( '.infocol' ); |
380 |
var $columns = $tr.find( '.infocol' ); |
391 |
var $marc_column = $tr.find( '.marccol' ); |
381 |
CodeMirror.runMode( TextMARC.RecordToText( record ), 'marc', $( '<td class="infocol results-marc" colspan="' + $columns.length + '"></td>' ).replaceAll( $columns.slice(1).remove().end()[0] )[0] ); |
392 |
|
382 |
} ); |
393 |
if ( !$marc_column.length ) { |
|
|
394 |
$marc_column = $( '<td class="marccol" colspan="' + $info_columns.length + '"></td>' ).insertAfter( $info_columns.eq(-1) ).hide(); |
395 |
CodeMirror.runMode( TextMARC.RecordToText( hit.record ), 'marc', $marc_column[0] ); |
396 |
} |
397 |
|
398 |
if ( $marc_column.is(':visible') ) { |
399 |
$tr.find('.marc-link').text( _("View MARC") ); |
400 |
$info_columns.show(); |
401 |
$marc_column.hide(); |
402 |
} else { |
403 |
$tr.find('.marc-link').text( _("Hide MARC") ); |
404 |
$marc_column.show(); |
405 |
$info_columns.hide(); |
406 |
} |
383 |
|
407 |
|
384 |
return false; |
408 |
return false; |
385 |
} ); |
409 |
} ); |
Lines 398-409
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
398 |
$('#searchresults tbody').append( $tr ); |
422 |
$('#searchresults tbody').append( $tr ); |
399 |
} ); |
423 |
} ); |
400 |
|
424 |
|
|
|
425 |
var pages = []; |
426 |
var cur_page = data.offset / data.page_size; |
427 |
var max_page = Math.ceil( data.total_fetched / data.page_size ) - 1; |
428 |
|
429 |
if ( cur_page != 0 ) { |
430 |
pages.push( '<li><a class="search-nav" href="#" data-offset="' + (data.offset - data.page_size) + '">« ' + _("Previous") + '</a></li>' ); |
431 |
} |
432 |
|
433 |
for ( var page = Math.max( 0, cur_page - 9 ); page <= Math.min( max_page, cur_page + 9 ); page++ ) { |
434 |
if ( page == cur_page ) { |
435 |
pages.push( ' <li class="active"><a href="#">' + ( page + 1 ) + '</a></li>' ); |
436 |
} else { |
437 |
pages.push( ' <li><a class="search-nav" href="#" data-offset="' + ( page * data.page_size ) + '">' + ( page + 1 ) + '</a></li>' ); |
438 |
} |
439 |
} |
440 |
|
441 |
if ( cur_page < max_page ) { |
442 |
pages.push( ' <li><a class="search-nav" href="#" data-offset="' + (data.offset + data.page_size) + '">' + _("Next") + ' »</a></li>' ); |
443 |
} |
444 |
|
445 |
if ( pages.length > 1 ) $( '#search-top-pages, #search-bottom-pages' ).find( '.pagination' ).html( '<ul>' + pages.join( '' ) + '</ul>'); |
446 |
|
401 |
var $overlay = $('#search-overlay'); |
447 |
var $overlay = $('#search-overlay'); |
402 |
$overlay.find('span').text(_("Loading")); |
448 |
$overlay.find('span').text(_("Loading")); |
403 |
$overlay.find('.bar').css( { display: 'block', width: 100 * ( 1 - data.activeclients / Search.includedTargets.length ) + '%' } ); |
449 |
$overlay.find('.bar').css( { display: 'block', width: 100 * ( 1 - data.activeclients / Search.includedServers.length ) + '%' } ); |
404 |
|
450 |
|
405 |
if ( data.activeclients ) { |
451 |
if ( data.activeclients ) { |
406 |
$overlay.find('.bar').css( { display: 'block', width: 100 * ( 1 - data.activeclients / Search.includedTargets.length ) + '%' } ); |
452 |
$overlay.find('.bar').css( { display: 'block', width: 100 * ( 1 - data.activeclients / Search.includedServers.length ) + '%' } ); |
407 |
$overlay.show(); |
453 |
$overlay.show(); |
408 |
} else { |
454 |
} else { |
409 |
$overlay.find('.bar').css( { display: 'block', width: '100%' } ); |
455 |
$overlay.find('.bar').css( { display: 'block', width: '100%' } ); |
Lines 418-431
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
418 |
$overlay.show(); |
464 |
$overlay.show(); |
419 |
} |
465 |
} |
420 |
|
466 |
|
421 |
function showSearchTargets(data) { |
|
|
422 |
$('#search-targetsinfo').empty(); |
423 |
|
424 |
$.each( data, function( undef, target ) { |
425 |
$('#search-targetsinfo').append( '<li>' + target.name + ' (' + target.hits + ')' + '</li>' ); |
426 |
} ); |
427 |
} |
428 |
|
429 |
function handleSearchError(error) { |
467 |
function handleSearchError(error) { |
430 |
if (error.code == 1) { |
468 |
if (error.code == 1) { |
431 |
invalidateSearchResults(); |
469 |
invalidateSearchResults(); |
Lines 768-773
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
768 |
return false; |
806 |
return false; |
769 |
} ); |
807 |
} ); |
770 |
|
808 |
|
|
|
809 |
$( document ).on( 'click', 'a.search-nav', function() { |
810 |
$("#search-overlay").show(); |
811 |
Search.Fetch( $( this ).data( 'offset' ) ); |
812 |
return false; |
813 |
}); |
814 |
|
771 |
// Key bindings |
815 |
// Key bindings |
772 |
bindGlobalKeys(); |
816 |
bindGlobalKeys(); |
773 |
|
817 |
|
Lines 805-818
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
805 |
}); |
849 |
}); |
806 |
|
850 |
|
807 |
// Start editor |
851 |
// Start editor |
808 |
Preferences.Load( [% USER_INFO.0.borrowernumber %] ); |
852 |
Preferences.Load( [% USER_INFO.0.borrowernumber || 0 %] ); |
809 |
displayPreferences(editor); |
853 |
displayPreferences(editor); |
810 |
makeAuthorisedValueWidgets( '' ); |
854 |
makeAuthorisedValueWidgets( '' ); |
811 |
Search.Init( z3950Targets, { |
855 |
Search.Init( { |
|
|
856 |
page_size: 20, |
812 |
onresults: function(data) { showSearchResults( editor, data ) }, |
857 |
onresults: function(data) { showSearchResults( editor, data ) }, |
813 |
onbytarget: showSearchTargets, |
|
|
814 |
onerror: handleSearchError, |
858 |
onerror: handleSearchError, |
815 |
oniniterror: handleSearchInitError, |
|
|
816 |
} ); |
859 |
} ); |
817 |
|
860 |
|
818 |
function finishCb() { |
861 |
function finishCb() { |