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