|
Lines 46-51
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 46 |
recordtype: 'biblio', |
46 |
recordtype: 'biblio', |
| 47 |
checked: false, |
47 |
checked: false, |
| 48 |
}, |
48 |
}, |
|
|
49 |
[%- FOREACH batch = editable_batches -%] |
| 50 |
'batch:[% batch.import_batch_id %]': { |
| 51 |
name: _("Batch: ") + '[% batch.file_name %]', |
| 52 |
recordtype: 'biblio', |
| 53 |
checked: false, |
| 54 |
}, |
| 55 |
[%- END -%] |
| 49 |
[%- FOREACH server = z3950_servers -%] |
56 |
[%- FOREACH server = z3950_servers -%] |
| 50 |
[% server.id | html %]: { |
57 |
[% server.id | html %]: { |
| 51 |
name: '[% server.servername | html %]', |
58 |
name: '[% server.servername | html %]', |
|
Lines 71-78
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 71 |
|
78 |
|
| 72 |
var state = { |
79 |
var state = { |
| 73 |
backend: '', |
80 |
backend: '', |
| 74 |
saveBackend: 'catalog', |
81 |
recordID: undefined, |
| 75 |
recordID: undefined |
82 |
saveTargets: {}, |
| 76 |
}; |
83 |
}; |
| 77 |
|
84 |
|
| 78 |
var editor; |
85 |
var editor; |
|
Lines 258-273
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 258 |
} |
265 |
} |
| 259 |
}, |
266 |
}, |
| 260 |
'catalog': { |
267 |
'catalog': { |
| 261 |
titleForRecord: _("Editing catalog record #{ID}"), |
268 |
titleForRecord: _("Editing catalog record #%s"), |
| 262 |
links: [ |
269 |
links: [ |
| 263 |
{ title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber={ID}" }, |
270 |
{ title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber=%s" }, |
| 264 |
{ title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber={ID}" }, |
271 |
{ title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=%s" }, |
| 265 |
], |
272 |
], |
| 266 |
saveLabel: _("Save to catalog"), |
273 |
saveLabel: _("New catalog record"), |
|
|
274 |
saveExistingLabel: _("Catalog record #%s"), |
| 267 |
get: function( id, callback ) { |
275 |
get: function( id, callback ) { |
| 268 |
if ( !id ) return false; |
276 |
if ( !id ) return false; |
| 269 |
|
277 |
|
| 270 |
KohaBackend.GetRecord( id, callback ); |
278 |
KohaBackend.GetRecord( id, function( data ) { |
|
|
279 |
if ( !data.error ) { |
| 280 |
setSaveTargetChecked( 'catalog/', false ); |
| 281 |
addSaveTarget( { |
| 282 |
label: backends.catalog.saveExistingLabel.format( id ), |
| 283 |
id: 'catalog/' + id, |
| 284 |
description: '', |
| 285 |
checked: true |
| 286 |
} ); |
| 287 |
} |
| 288 |
|
| 289 |
callback(data); |
| 290 |
} ); |
| 271 |
}, |
291 |
}, |
| 272 |
save: function( id, record, done ) { |
292 |
save: function( id, record, done ) { |
| 273 |
function finishCb( data ) { |
293 |
function finishCb( data ) { |
|
Lines 290-296
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 290 |
} |
310 |
} |
| 291 |
}, |
311 |
}, |
| 292 |
'marcxml': { |
312 |
'marcxml': { |
| 293 |
saveLabel: _("Save as MARCXML (.xml) file"), |
313 |
saveLabel: _("New MARCXML (.xml) file"), |
| 294 |
save: function( id, record, done ) { |
314 |
save: function( id, record, done ) { |
| 295 |
saveAs( new Blob( [record.toXML()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.xml' ); |
315 |
saveAs( new Blob( [record.toXML()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.xml' ); |
| 296 |
|
316 |
|
|
Lines 312-317
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 312 |
}, |
332 |
}, |
| 313 |
}; |
333 |
}; |
| 314 |
|
334 |
|
|
|
335 |
var editable_batches = { |
| 336 |
[%- FOREACH batch = editable_batches -%] |
| 337 |
[% batch.import_batch_id %]: { |
| 338 |
'name': '[% batch.file_name %]', |
| 339 |
}, |
| 340 |
[%- END -%] |
| 341 |
}; |
| 342 |
|
| 343 |
function addSaveTarget( target ) { |
| 344 |
state.saveTargets[target.id] = target; |
| 345 |
if (target.enabled == null) target.enabled = true; |
| 346 |
|
| 347 |
// Have to check that Preferences has been initialized |
| 348 |
var saved_value = Preferences.user && Preferences.user.selected_save_targets[target.id]; |
| 349 |
if ( saved_value != null ) target.checked = saved_value; |
| 350 |
|
| 351 |
var target_list = $.map( state.saveTargets, function( target ) { |
| 352 |
return target; |
| 353 |
} ); |
| 354 |
|
| 355 |
target_list.sort( function( a, b ) { |
| 356 |
return a.label.localeCompare(b.label); |
| 357 |
} ); |
| 358 |
|
| 359 |
$('#save-targets ol').empty(); |
| 360 |
|
| 361 |
$.each( target_list, function( i, target ) { |
| 362 |
var $new_target = $( |
| 363 |
'<li><input type="checkbox" class="save-toggle-target" data-target-id="' + target.id + '" id="save-target-' + i + '"' + ( target.checked ? ' checked="checked"' : '' ) + '> <label for="save-target-' + i + '">' + target.label + '</label></li>' |
| 364 |
); |
| 365 |
|
| 366 |
$new_target.find('input').change( function() { |
| 367 |
target.checked = this.checked; |
| 368 |
} ); |
| 369 |
|
| 370 |
$('#save-targets ol').append($new_target); |
| 371 |
|
| 372 |
if (!target.enabled) $new_target.hide(); |
| 373 |
} ); |
| 374 |
} |
| 375 |
|
| 376 |
function setSaveTargetChecked( target_id, checked ) { |
| 377 |
if ( state.saveTargets[target_id] == null ) return; |
| 378 |
|
| 379 |
state.saveTargets[target_id].checked = checked; |
| 380 |
$( '#save-targets input[data-target-id="' + target_id + '"]' )[0].checked = checked; |
| 381 |
} |
| 382 |
|
| 383 |
function setSaveTargetEnabled( target_id, enabled ) { |
| 384 |
if ( !enabled ) { |
| 385 |
setSaveTargetChecked( target_id, false ); |
| 386 |
} |
| 387 |
|
| 388 |
state.saveTargets[target_id].enabled = enabled; |
| 389 |
$( '#save-targets input[data-target-id="' + target_id + '"]' ).closest('li').toggle(enabled); |
| 390 |
} |
| 391 |
|
| 315 |
function setSource(parts) { |
392 |
function setSource(parts) { |
| 316 |
state.backend = parts[0]; |
393 |
state.backend = parts[0]; |
| 317 |
state.recordID = parts[1]; |
394 |
state.recordID = parts[1]; |
|
Lines 322-334
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 322 |
|
399 |
|
| 323 |
document.location.hash = '#' + parts[0] + '/' + parts[1]; |
400 |
document.location.hash = '#' + parts[0] + '/' + parts[1]; |
| 324 |
|
401 |
|
| 325 |
$('#title').text( backend.titleForRecord.replace( '{ID}', parts[1] ) ); |
402 |
$('#title').text( backend.titleForRecord.format( parts[1] ) ); |
| 326 |
|
403 |
|
| 327 |
$.each( backend.links || [], function( i, link ) { |
404 |
$.each( backend.links || [], function( i, link ) { |
| 328 |
$('#title').append(' <a target="_blank" href="' + link.href.replace( '{ID}', parts[1] ) + '">(' + link.title + ')</a>' ); |
405 |
$('#title').append(' <a target="_blank" href="' + link.href.format( parts[1] ) + '">(' + link.title + ')</a>' ); |
| 329 |
} ); |
406 |
} ); |
| 330 |
$( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.replace( '{ID}', parts[1] ) ); |
407 |
$( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.format( parts[1] ) ); |
| 331 |
$('#save-record span').text( backends[ state.saveBackend ].saveLabel ); |
|
|
| 332 |
} |
408 |
} |
| 333 |
|
409 |
|
| 334 |
function saveRecord( recid, editor, callback ) { |
410 |
function saveRecord( recid, editor, callback ) { |
|
Lines 365-370
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 365 |
|
441 |
|
| 366 |
if (data.newId) { |
442 |
if (data.newId) { |
| 367 |
setSource(data.newId); |
443 |
setSource(data.newId); |
|
|
444 |
|
| 445 |
var backend = backends[ parts[0] ]; |
| 446 |
|
| 447 |
setSaveTargetChecked( recid, false ); |
| 448 |
addSaveTarget( { |
| 449 |
label: backend.saveExistingLabel.format( data.newId[1] ), |
| 450 |
id: data.newId.join('/'), |
| 451 |
description: '', |
| 452 |
checked: true |
| 453 |
} ); |
| 368 |
} else { |
454 |
} else { |
| 369 |
setSource( [ state.backend, state.recordID ] ); |
455 |
setSource( [ state.backend, state.recordID ] ); |
| 370 |
} |
456 |
} |
|
Lines 623-628
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 623 |
var value = Preferences.user[pref]; |
709 |
var value = Preferences.user[pref]; |
| 624 |
|
710 |
|
| 625 |
switch (pref) { |
711 |
switch (pref) { |
|
|
712 |
case 'enabledBatches': |
| 713 |
$.each( editable_batches, function( batch_id, batch ) { |
| 714 |
$( '#batches-list li[data-batch-id=' + batch_id + '] input' )[0].checked = Preferences.user.enabledBatches[batch_id]; |
| 715 |
setSaveTargetEnabled( 'batch:' + batch_id + '/', Preferences.user.enabledBatches[batch_id] || false ); |
| 716 |
} ); |
| 626 |
case 'fieldWidgets': |
717 |
case 'fieldWidgets': |
| 627 |
$( '#set-field-widgets' ).text( value ? _("Show fields verbatim") : _("Show helpers for fixed and coded fields") ); |
718 |
$( '#set-field-widgets' ).text( value ? _("Show fields verbatim") : _("Show helpers for fixed and coded fields") ); |
| 628 |
break; |
719 |
break; |
|
Lines 644-649
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 644 |
if ( saved_val != null ) server.checked = saved_val; |
735 |
if ( saved_val != null ) server.checked = saved_val; |
| 645 |
} ); |
736 |
} ); |
| 646 |
break; |
737 |
break; |
|
|
738 |
case 'selected_save_targets': |
| 739 |
$.each( state.saveTargets, function( target_id, target ) { |
| 740 |
var saved_val = Preferences.user.selected_save_targets[target_id]; |
| 741 |
|
| 742 |
if ( saved_val != null ) setSaveTargetChecked( target_id, saved_val ); |
| 743 |
} ); |
| 744 |
break; |
| 745 |
case 'selected_search_targets': |
| 746 |
$.each( z3950Servers, function( server_id, server ) { |
| 747 |
var saved_val = Preferences.user.selected_search_targets[server_id]; |
| 748 |
|
| 749 |
if ( saved_val != null ) server.checked = saved_val; |
| 750 |
} ); |
| 751 |
break; |
| 647 |
} |
752 |
} |
| 648 |
} |
753 |
} |
| 649 |
|
754 |
|
|
Lines 657-663
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 657 |
} ); |
762 |
} ); |
| 658 |
} |
763 |
} |
| 659 |
|
764 |
|
|
|
765 |
function _addLiveHandler( sel, event, handler ) { |
| 766 |
$( document ).on( event, sel, function (e) { |
| 767 |
e.preventDefault(); |
| 768 |
handler.call( this, e, Preferences.user[pref] ); |
| 769 |
Preferences.Save( [% USER_INFO.borrowernumber %] ); |
| 770 |
showPreference(pref); |
| 771 |
} ); |
| 772 |
} |
| 773 |
|
| 660 |
switch (pref) { |
774 |
switch (pref) { |
|
|
775 |
case 'enabledBatches': |
| 776 |
_addLiveHandler( '#batches-list input', 'change', function() { |
| 777 |
Preferences.user.enabledBatches[ $( this ).closest('li').data('batch-id') ] = this.checked; |
| 778 |
} ); |
| 779 |
break; |
| 661 |
case 'fieldWidgets': |
780 |
case 'fieldWidgets': |
| 662 |
_addHandler( '#set-field-widgets', 'click', function( e, oldValue ) { |
781 |
_addHandler( '#set-field-widgets', 'click', function( e, oldValue ) { |
| 663 |
editor.setUseWidgets( Preferences.user.fieldWidgets = !Preferences.user.fieldWidgets ); |
782 |
editor.setUseWidgets( Preferences.user.fieldWidgets = !Preferences.user.fieldWidgets ); |
|
Lines 673-678
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 673 |
Preferences.user.fontSize = $( e.target ).css( 'font-size' ); |
792 |
Preferences.user.fontSize = $( e.target ).css( 'font-size' ); |
| 674 |
} ); |
793 |
} ); |
| 675 |
break; |
794 |
break; |
|
|
795 |
case 'selected_save_targets': |
| 796 |
$( document ).on( 'change', 'input.save-toggle-target', function() { |
| 797 |
var target_id = $( this ).data('target-id'); |
| 798 |
Preferences.user.selected_save_targets[target_id] = this.checked; |
| 799 |
Preferences.Save( [% USER_INFO.borrowernumber %] ); |
| 800 |
} ); |
| 801 |
break; |
| 676 |
case 'selected_search_targets': |
802 |
case 'selected_search_targets': |
| 677 |
$( document ).on( 'change', 'input.search-toggle-server', function() { |
803 |
$( document ).on( 'change', 'input.search-toggle-server', function() { |
| 678 |
var server_id = $( this ).closest('li').data('server-id'); |
804 |
var server_id = $( this ).closest('li').data('server-id'); |
|
Lines 766-771
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 766 |
showSavedMacros(); |
892 |
showSavedMacros(); |
| 767 |
} |
893 |
} |
| 768 |
|
894 |
|
|
|
895 |
function addImportBatch(batch) { |
| 896 |
var backend_id = 'batch:' + batch.batch_id; |
| 897 |
backends[backend_id] = { |
| 898 |
titleForRecord: _("Editing record from batch: ") + batch.name, |
| 899 |
saveLabel: _("Batch: ") + batch.name, |
| 900 |
saveExistingLabel: batch.name + ": #%s", |
| 901 |
get: function( id, callback ) { |
| 902 |
KohaBackend.GetBatchRecord( batch.batch_id, id, function( data ) { |
| 903 |
if ( !data.error ) { |
| 904 |
setSaveTargetChecked( backend_id + '/', false ); |
| 905 |
addSaveTarget( { |
| 906 |
label: batch.name + ": #" + id, |
| 907 |
id: backend_id + '/' + id, |
| 908 |
description: '', |
| 909 |
checked: true |
| 910 |
} ); |
| 911 |
} |
| 912 |
|
| 913 |
callback(data); |
| 914 |
} ); |
| 915 |
}, |
| 916 |
save: function( id, record, done, options ) { |
| 917 |
function finishCb( data ) { |
| 918 |
done( { |
| 919 |
error: data.message || data.error, |
| 920 |
newRecord: data.updated_record, |
| 921 |
newId: data.import_record_id && [ backend_id, data.import_record_id ] |
| 922 |
} ); |
| 923 |
} |
| 924 |
|
| 925 |
if ( id ) { |
| 926 |
KohaBackend.SaveBatchRecord( batch.batch_id, id, record, finishCb, { allow_control_number_conflict: options.override_warnings } ); |
| 927 |
} else { |
| 928 |
KohaBackend.CreateBatchRecord( record, batch.batch_id, finishCb, { allow_control_number_conflict: options.override_warnings } ); |
| 929 |
} |
| 930 |
}, |
| 931 |
}; |
| 932 |
|
| 933 |
// Build batch UI |
| 934 |
var $batch_entry = $( '<li data-batch-id="' + batch.batch_id + '"><input type="checkbox" />' + batch.name + '</li>' ); |
| 935 |
|
| 936 |
var $batch_buttons = $('<span class="batch-buttons"></span>').appendTo($batch_entry); |
| 937 |
var $export_button = $( '<button>' + _("Export...") + '</button>' ).appendTo($batch_buttons).click( function() { |
| 938 |
$('#batches-list .batch-export').hide(); |
| 939 |
$export_screen.show(); |
| 940 |
} ); |
| 941 |
|
| 942 |
var $export_screen = $( |
| 943 |
'<form class="batch-export form-horizontal" style="display: none">' |
| 944 |
+ '<div class="control-group">' |
| 945 |
+ '<label class="control-label">' + _("Control number range:") + '</label>' |
| 946 |
+ '<div class="controls"><input class="batch-control-number-start" type="text"> - <input class="batch-control-number-end" type="text"></div>' |
| 947 |
+ '</div>' |
| 948 |
+ '<label class="control-label">' + _("Timestamp range (YYYYMMDD or YYYMMDDHHMMSS):") + '</label>' |
| 949 |
+ '<div class="controls"><input class="batch-timestamp-start" type="text"> - <input class="batch-timestamp-end" type="text"></div>' |
| 950 |
+ '</div>' |
| 951 |
+ '<div class="control-group">' |
| 952 |
+ '<div class="controls"><button class="batch-export-start">' + _("Start export") + '</div>' |
| 953 |
+ '</form>' |
| 954 |
).appendTo($batch_entry); |
| 955 |
|
| 956 |
$export_screen.find('.batch-export-start').click( function() { |
| 957 |
function getFormVal(name) { |
| 958 |
return $export_screen.find( '.batch-' + name ).val(); |
| 959 |
} |
| 960 |
|
| 961 |
var options = { |
| 962 |
start_control_number: getFormVal('control-number-start'), |
| 963 |
end_control_number: getFormVal('control-number-end'), |
| 964 |
start_timestamp: getFormVal('timestamp-start'), |
| 965 |
end_timestamp: getFormVal('timestamp-end'), |
| 966 |
}; |
| 967 |
|
| 968 |
KohaBackend.StartBatchExport( batch.batch_id, options ); |
| 969 |
} ); |
| 970 |
|
| 971 |
$('#batches-list').append( $batch_entry ); |
| 972 |
} |
| 973 |
|
| 769 |
$(document).ready( function() { |
974 |
$(document).ready( function() { |
| 770 |
// Editor setup |
975 |
// Editor setup |
| 771 |
editor = new MARCEditor( { |
976 |
editor = new MARCEditor( { |
|
Lines 815-820
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 815 |
$(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() ); |
1020 |
$(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() ); |
| 816 |
} ); |
1021 |
} ); |
| 817 |
}, 100); |
1022 |
}, 100); |
|
|
1023 |
|
| 818 |
} |
1024 |
} |
| 819 |
|
1025 |
|
| 820 |
$( '#macro-ui' ).on( 'shown.bs.modal', function() { |
1026 |
$( '#macro-ui' ).on( 'shown.bs.modal', function() { |
|
Lines 855-863
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 855 |
$.each( backends, function( id, backend ) { |
1061 |
$.each( backends, function( id, backend ) { |
| 856 |
if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] ); |
1062 |
if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] ); |
| 857 |
} ); |
1063 |
} ); |
| 858 |
saveableBackends.sort(); |
1064 |
|
| 859 |
$.each( saveableBackends, function( undef, backend ) { |
1065 |
var batch_list = []; |
| 860 |
$( '#save-dropdown' ).append( '<li><a href="#" data-backend="' + backend[1] + '">' + backend[0] + '</a></li>' ); |
1066 |
|
|
|
1067 |
$.each( editable_batches, function( batch_id, batch ) { |
| 1068 |
batch_list.push( $.extend( { batch_id: batch_id }, batch ) ); |
| 1069 |
} ); |
| 1070 |
batch_list.sort( function( a, b ) { |
| 1071 |
return a.name.localeCompare(b.name); |
| 1072 |
} ); |
| 1073 |
$.each( batch_list, function() { |
| 1074 |
addImportBatch( this ); |
| 861 |
} ); |
1075 |
} ); |
| 862 |
|
1076 |
|
| 863 |
var macro_format_list = $.map( Macros.formats, function( format, name ) { |
1077 |
var macro_format_list = $.map( Macros.formats, function( format, name ) { |
|
Lines 873-886
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 873 |
// Click bindings |
1087 |
// Click bindings |
| 874 |
$( '#save-record, #save-dropdown a' ).click( function() { |
1088 |
$( '#save-record, #save-dropdown a' ).click( function() { |
| 875 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") ); |
1089 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") ); |
|
|
1090 |
var enabledTargets = []; |
| 1091 |
var targetNames = []; |
| 1092 |
$.each( state.saveTargets, function() { |
| 1093 |
if ( this.checked ) { |
| 1094 |
enabledTargets.push(this); |
| 1095 |
targetNames.push(this.label); |
| 1096 |
} |
| 1097 |
} ); |
| 1098 |
if ( enabledTargets.length == 0 ) { |
| 1099 |
humanMsg.displayAlert( _("Please select a save target"), { className: 'humanError' } ); |
| 1100 |
return false; |
| 1101 |
} |
| 1102 |
|
| 1103 |
$( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") ); |
| 1104 |
|
| 1105 |
var targets_left = enabledTargets.length; |
| 1106 |
var errors = false; |
| 876 |
|
1107 |
|
| 877 |
function finishCb(result) { |
1108 |
function finishCb(result) { |
| 878 |
if ( result.error == 'syntax' ) { |
1109 |
targets_left--; |
| 879 |
humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } ); |
1110 |
if ( result.error ) { |
| 880 |
} else if ( result.error == 'invalid' ) { |
1111 |
if ( result.error == 'syntax' ) { |
| 881 |
humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } ); |
1112 |
humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } ); |
| 882 |
} else if ( !result.error ) { |
1113 |
} else if ( result.error == 'invalid' ) { |
| 883 |
humanMsg.displayAlert( _("Record saved "), { className: 'humanSuccess' } ); |
1114 |
humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } ); |
|
|
1115 |
} else if ( result.error.type == 'control_number_match' ) { |
| 1116 |
humanMsg.displayAlert( _("Control number conflict, cannot save"), { className: 'humanError' } ); |
| 1117 |
} else { |
| 1118 |
humanMsg.displayAlert( _("Unknown error, record not saved to one or more targets"), { className: 'humanError' } ); |
| 1119 |
} |
| 1120 |
errors = true; |
| 884 |
} |
1121 |
} |
| 885 |
|
1122 |
|
| 886 |
$.each( result.errors || [], function( undef, error ) { |
1123 |
$.each( result.errors || [], function( undef, error ) { |
|
Lines 916-935
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 916 |
} |
1153 |
} |
| 917 |
} ); |
1154 |
} ); |
| 918 |
|
1155 |
|
| 919 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-hdd-o' ); |
|
|
| 920 |
|
1156 |
|
| 921 |
if ( result.error ) { |
1157 |
if ( targets_left == 0 ) { |
| 922 |
// Reset backend info |
1158 |
if ( !errors ) { |
| 923 |
setSource( [ state.backend, state.recordID ] ); |
1159 |
humanMsg.displayMsg( "<h3>" + _("Record saved to:</h3>") + "</h3>" + '<ul><li>' + targetNames.join('</li><li>') + '</li></ul>', { className: 'humanSuccess' } ); |
|
|
1160 |
} |
| 1161 |
|
| 1162 |
$( '#save-record' ).find('i').attr( 'class', 'icon-hdd' ).end().find('span').text( _("Save") ); |
| 924 |
} |
1163 |
} |
| 925 |
} |
1164 |
} |
| 926 |
|
1165 |
|
| 927 |
var backend = $( this ).data( 'backend' ) || ( state.saveBackend ); |
1166 |
$.each( enabledTargets, function() { |
| 928 |
if ( state.backend == backend ) { |
1167 |
saveRecord( this.id, editor, finishCb, options ); |
| 929 |
saveRecord( backend + '/' + state.recordID, editor, finishCb ); |
1168 |
} ); |
| 930 |
} else { |
|
|
| 931 |
saveRecord( backend + '/', editor, finishCb ); |
| 932 |
} |
| 933 |
|
1169 |
|
| 934 |
return false; |
1170 |
return false; |
| 935 |
} ); |
1171 |
} ); |
|
Lines 1070-1080
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 1070 |
} |
1306 |
} |
| 1071 |
} ); |
1307 |
} ); |
| 1072 |
|
1308 |
|
|
|
1309 |
$('#open-batches').click( function() { |
| 1310 |
$('#batches-ui').modal(); |
| 1311 |
|
| 1312 |
return false; |
| 1313 |
} ); |
| 1314 |
|
| 1315 |
$('#create-batch').click( function() { |
| 1316 |
var batch_name = prompt( _("Name of new import batch:") ); |
| 1317 |
if (batch_name == null) return false; |
| 1318 |
|
| 1319 |
KohaBackend.CreateBatch( batch_name, function( data ) { |
| 1320 |
if ( data.error ) { |
| 1321 |
humanMsg.displayAlert( _("Could not create import batch"), { className: 'humanError' } ); |
| 1322 |
} else { |
| 1323 |
humanMsg.displayAlert( _("Import batch created"), { className: 'humanSuccess' } ); |
| 1324 |
|
| 1325 |
addImportBatch( editable_batches[data.batch_id] = { batch_id: data.batch_id, name: batch_name } ); |
| 1326 |
|
| 1327 |
var backend_id = 'batch:' + data.batch_id; |
| 1328 |
addSaveTarget( { |
| 1329 |
label: backends[backend_id].saveLabel, |
| 1330 |
id: backend_id + '/', |
| 1331 |
description: '', |
| 1332 |
enabled: false, |
| 1333 |
} ); |
| 1334 |
} |
| 1335 |
} ); |
| 1336 |
|
| 1337 |
return false; |
| 1338 |
} ); |
| 1339 |
|
| 1340 |
$('#manage-batches').click( function() { |
| 1341 |
window.open('/cgi-bin/koha/tools/manage-marc-import.pl'); |
| 1342 |
|
| 1343 |
return false; |
| 1344 |
} ); |
| 1345 |
|
| 1073 |
// Key bindings |
1346 |
// Key bindings |
| 1074 |
bindGlobalKeys(); |
1347 |
bindGlobalKeys(); |
| 1075 |
|
1348 |
|
| 1076 |
// Setup UI |
1349 |
// Setup UI |
| 1077 |
$("#advanced-search-ui, #search-results-ui, #macro-ui").each( function() { |
1350 |
$(".ui-modal").each( function() { |
| 1078 |
$(this).modal({ show: false }); |
1351 |
$(this).modal({ show: false }); |
| 1079 |
} ); |
1352 |
} ); |
| 1080 |
|
1353 |
|
|
Lines 1136-1141
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 1136 |
$('#loading').hide(); |
1409 |
$('#loading').hide(); |
| 1137 |
} |
1410 |
} |
| 1138 |
); |
1411 |
); |
|
|
1412 |
}; ); |
| 1413 |
|
| 1414 |
$.each( backends, function( name ) { |
| 1415 |
if ( !this.save ) return; // Not a saving backend |
| 1416 |
|
| 1417 |
addSaveTarget( { |
| 1418 |
label: this.saveLabel, |
| 1419 |
id: name + '/', |
| 1420 |
description: '', |
| 1421 |
} ); |
| 1139 |
} ); |
1422 |
} ); |
| 1140 |
|
1423 |
|
| 1141 |
// Start editor |
1424 |
// Start editor |