|
Lines 39-44
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 39 |
recordtype: 'biblio', |
39 |
recordtype: 'biblio', |
| 40 |
checked: false, |
40 |
checked: false, |
| 41 |
}, |
41 |
}, |
|
|
42 |
[%- FOREACH batch = editable_batches -%] |
| 43 |
'batch:[% batch.import_batch_id %]': { |
| 44 |
name: _("Batch: ") + '[% batch.file_name %]', |
| 45 |
recordtype: 'biblio', |
| 46 |
checked: false, |
| 47 |
}, |
| 48 |
[%- END -%] |
| 42 |
[%- FOREACH server = z3950_servers -%] |
49 |
[%- FOREACH server = z3950_servers -%] |
| 43 |
[% server.id | html %]: { |
50 |
[% server.id | html %]: { |
| 44 |
name: '[% server.servername | html %]', |
51 |
name: '[% server.servername | html %]', |
|
Lines 64-71
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 64 |
|
71 |
|
| 65 |
var state = { |
72 |
var state = { |
| 66 |
backend: '', |
73 |
backend: '', |
| 67 |
saveBackend: 'catalog', |
74 |
recordID: undefined, |
| 68 |
recordID: undefined |
75 |
saveTargets: {}, |
| 69 |
}; |
76 |
}; |
| 70 |
|
77 |
|
| 71 |
var editor; |
78 |
var editor; |
|
Lines 235-250
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 235 |
}, |
242 |
}, |
| 236 |
}, |
243 |
}, |
| 237 |
'catalog': { |
244 |
'catalog': { |
| 238 |
titleForRecord: _("Editing catalog record #{ID}"), |
245 |
titleForRecord: _("Editing catalog record #%s"), |
| 239 |
links: [ |
246 |
links: [ |
| 240 |
{ title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber={ID}" }, |
247 |
{ title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber=%s" }, |
| 241 |
{ title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber={ID}" }, |
248 |
{ title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=%s" }, |
| 242 |
], |
249 |
], |
| 243 |
saveLabel: _("Save to catalog"), |
250 |
saveLabel: _("New catalog record"), |
|
|
251 |
saveExistingLabel: _("Catalog record #%s"), |
| 244 |
get: function( id, callback ) { |
252 |
get: function( id, callback ) { |
| 245 |
if ( !id ) return false; |
253 |
if ( !id ) return false; |
| 246 |
|
254 |
|
| 247 |
KohaBackend.GetRecord( id, callback ); |
255 |
KohaBackend.GetRecord( id, function( data ) { |
|
|
256 |
if ( !data.error ) { |
| 257 |
setSaveTargetChecked( 'catalog/', false ); |
| 258 |
addSaveTarget( { |
| 259 |
label: backends.catalog.saveExistingLabel.format( id ), |
| 260 |
id: 'catalog/' + id, |
| 261 |
description: '', |
| 262 |
checked: true |
| 263 |
} ); |
| 264 |
} |
| 265 |
|
| 266 |
callback(data); |
| 267 |
} ); |
| 248 |
}, |
268 |
}, |
| 249 |
save: function( id, record, done ) { |
269 |
save: function( id, record, done ) { |
| 250 |
function finishCb( data ) { |
270 |
function finishCb( data ) { |
|
Lines 267-273
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 267 |
} |
287 |
} |
| 268 |
}, |
288 |
}, |
| 269 |
'marcxml': { |
289 |
'marcxml': { |
| 270 |
saveLabel: _("Save as MARCXML (.xml) file"), |
290 |
saveLabel: _("New MARCXML (.xml) file"), |
| 271 |
save: function( id, record, done ) { |
291 |
save: function( id, record, done ) { |
| 272 |
saveAs( new Blob( [record.toXML()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.xml' ); |
292 |
saveAs( new Blob( [record.toXML()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.xml' ); |
| 273 |
|
293 |
|
|
Lines 289-294
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 289 |
}, |
309 |
}, |
| 290 |
}; |
310 |
}; |
| 291 |
|
311 |
|
|
|
312 |
var editable_batches = { |
| 313 |
[%- FOREACH batch = editable_batches -%] |
| 314 |
[% batch.import_batch_id %]: { |
| 315 |
'name': '[% batch.file_name %]', |
| 316 |
}, |
| 317 |
[%- END -%] |
| 318 |
}; |
| 319 |
|
| 320 |
function addSaveTarget( target ) { |
| 321 |
state.saveTargets[target.id] = target; |
| 322 |
if (target.enabled == null) target.enabled = true; |
| 323 |
|
| 324 |
// Have to check that Preferences has been initialized |
| 325 |
var saved_value = Preferences.user && Preferences.user.selected_save_targets[target.id]; |
| 326 |
if ( saved_value != null ) target.checked = saved_value; |
| 327 |
|
| 328 |
var target_list = $.map( state.saveTargets, function( target ) { |
| 329 |
return target; |
| 330 |
} ); |
| 331 |
|
| 332 |
target_list.sort( function( a, b ) { |
| 333 |
return a.label.localeCompare(b.label); |
| 334 |
} ); |
| 335 |
|
| 336 |
$('#save-targets ol').empty(); |
| 337 |
|
| 338 |
$.each( target_list, function( i, target ) { |
| 339 |
var $new_target = $( |
| 340 |
'<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>' |
| 341 |
); |
| 342 |
|
| 343 |
$new_target.find('input').change( function() { |
| 344 |
target.checked = this.checked; |
| 345 |
} ); |
| 346 |
|
| 347 |
$('#save-targets ol').append($new_target); |
| 348 |
|
| 349 |
if (!target.enabled) $new_target.hide(); |
| 350 |
} ); |
| 351 |
} |
| 352 |
|
| 353 |
function setSaveTargetChecked( target_id, checked ) { |
| 354 |
if ( state.saveTargets[target_id] == null ) return; |
| 355 |
|
| 356 |
state.saveTargets[target_id].checked = checked; |
| 357 |
$( '#save-targets input[data-target-id="' + target_id + '"]' )[0].checked = checked; |
| 358 |
} |
| 359 |
|
| 360 |
function setSaveTargetEnabled( target_id, enabled ) { |
| 361 |
if ( !enabled ) { |
| 362 |
setSaveTargetChecked( target_id, false ); |
| 363 |
} |
| 364 |
|
| 365 |
state.saveTargets[target_id].enabled = enabled; |
| 366 |
$( '#save-targets input[data-target-id="' + target_id + '"]' ).closest('li').toggle(enabled); |
| 367 |
} |
| 368 |
|
| 292 |
function setSource(parts) { |
369 |
function setSource(parts) { |
| 293 |
state.backend = parts[0]; |
370 |
state.backend = parts[0]; |
| 294 |
state.recordID = parts[1]; |
371 |
state.recordID = parts[1]; |
|
Lines 299-311
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 299 |
|
376 |
|
| 300 |
document.location.hash = '#' + parts[0] + '/' + parts[1]; |
377 |
document.location.hash = '#' + parts[0] + '/' + parts[1]; |
| 301 |
|
378 |
|
| 302 |
$('#title').text( backend.titleForRecord.replace( '{ID}', parts[1] ) ); |
379 |
$('#title').text( backend.titleForRecord.format( parts[1] ) ); |
| 303 |
|
380 |
|
| 304 |
$.each( backend.links || [], function( i, link ) { |
381 |
$.each( backend.links || [], function( i, link ) { |
| 305 |
$('#title').append(' <a target="_blank" href="' + link.href.replace( '{ID}', parts[1] ) + '">(' + link.title + ')</a>' ); |
382 |
$('#title').append(' <a target="_blank" href="' + link.href.format( parts[1] ) + '">(' + link.title + ')</a>' ); |
| 306 |
} ); |
383 |
} ); |
| 307 |
$( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.replace( '{ID}', parts[1] ) ); |
384 |
$( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.format( parts[1] ) ); |
| 308 |
$('#save-record span').text( backends[ state.saveBackend ].saveLabel ); |
|
|
| 309 |
} |
385 |
} |
| 310 |
|
386 |
|
| 311 |
function saveRecord( recid, editor, callback ) { |
387 |
function saveRecord( recid, editor, callback ) { |
|
Lines 342-347
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 342 |
|
418 |
|
| 343 |
if (data.newId) { |
419 |
if (data.newId) { |
| 344 |
setSource(data.newId); |
420 |
setSource(data.newId); |
|
|
421 |
|
| 422 |
var backend = backends[ parts[0] ]; |
| 423 |
|
| 424 |
setSaveTargetChecked( recid, false ); |
| 425 |
addSaveTarget( { |
| 426 |
label: backend.saveExistingLabel.format( data.newId[1] ), |
| 427 |
id: data.newId.join('/'), |
| 428 |
description: '', |
| 429 |
checked: true |
| 430 |
} ); |
| 345 |
} else { |
431 |
} else { |
| 346 |
setSource( [ state.backend, state.recordID ] ); |
432 |
setSource( [ state.backend, state.recordID ] ); |
| 347 |
} |
433 |
} |
|
Lines 600-605
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 600 |
var value = Preferences.user[pref]; |
686 |
var value = Preferences.user[pref]; |
| 601 |
|
687 |
|
| 602 |
switch (pref) { |
688 |
switch (pref) { |
|
|
689 |
case 'enabledBatches': |
| 690 |
$.each( editable_batches, function( batch_id, batch ) { |
| 691 |
$( '#batches-list li[data-batch-id=' + batch_id + '] input' )[0].checked = Preferences.user.enabledBatches[batch_id]; |
| 692 |
setSaveTargetEnabled( 'batch:' + batch_id + '/', Preferences.user.enabledBatches[batch_id] || false ); |
| 693 |
} ); |
| 603 |
case 'fieldWidgets': |
694 |
case 'fieldWidgets': |
| 604 |
$( '#set-field-widgets' ).text( value ? _("Show fields verbatim") : _("Show helpers for fixed and coded fields") ); |
695 |
$( '#set-field-widgets' ).text( value ? _("Show fields verbatim") : _("Show helpers for fixed and coded fields") ); |
| 605 |
break; |
696 |
break; |
|
Lines 621-626
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 621 |
if ( saved_val != null ) server.checked = saved_val; |
712 |
if ( saved_val != null ) server.checked = saved_val; |
| 622 |
} ); |
713 |
} ); |
| 623 |
break; |
714 |
break; |
|
|
715 |
case 'selected_save_targets': |
| 716 |
$.each( state.saveTargets, function( target_id, target ) { |
| 717 |
var saved_val = Preferences.user.selected_save_targets[target_id]; |
| 718 |
|
| 719 |
if ( saved_val != null ) setSaveTargetChecked( target_id, saved_val ); |
| 720 |
} ); |
| 721 |
break; |
| 722 |
case 'selected_search_targets': |
| 723 |
$.each( z3950Servers, function( server_id, server ) { |
| 724 |
var saved_val = Preferences.user.selected_search_targets[server_id]; |
| 725 |
|
| 726 |
if ( saved_val != null ) server.checked = saved_val; |
| 727 |
} ); |
| 728 |
break; |
| 624 |
} |
729 |
} |
| 625 |
} |
730 |
} |
| 626 |
|
731 |
|
|
Lines 634-640
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 634 |
} ); |
739 |
} ); |
| 635 |
} |
740 |
} |
| 636 |
|
741 |
|
|
|
742 |
function _addLiveHandler( sel, event, handler ) { |
| 743 |
$( document ).on( event, sel, function (e) { |
| 744 |
e.preventDefault(); |
| 745 |
handler.call( this, e, Preferences.user[pref] ); |
| 746 |
Preferences.Save( [% USER_INFO.borrowernumber %] ); |
| 747 |
showPreference(pref); |
| 748 |
} ); |
| 749 |
} |
| 750 |
|
| 637 |
switch (pref) { |
751 |
switch (pref) { |
|
|
752 |
case 'enabledBatches': |
| 753 |
_addLiveHandler( '#batches-list input', 'change', function() { |
| 754 |
Preferences.user.enabledBatches[ $( this ).closest('li').data('batch-id') ] = this.checked; |
| 755 |
} ); |
| 756 |
break; |
| 638 |
case 'fieldWidgets': |
757 |
case 'fieldWidgets': |
| 639 |
_addHandler( '#set-field-widgets', 'click', function( e, oldValue ) { |
758 |
_addHandler( '#set-field-widgets', 'click', function( e, oldValue ) { |
| 640 |
editor.setUseWidgets( Preferences.user.fieldWidgets = !Preferences.user.fieldWidgets ); |
759 |
editor.setUseWidgets( Preferences.user.fieldWidgets = !Preferences.user.fieldWidgets ); |
|
Lines 650-655
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 650 |
Preferences.user.fontSize = $( e.target ).css( 'font-size' ); |
769 |
Preferences.user.fontSize = $( e.target ).css( 'font-size' ); |
| 651 |
} ); |
770 |
} ); |
| 652 |
break; |
771 |
break; |
|
|
772 |
case 'selected_save_targets': |
| 773 |
$( document ).on( 'change', 'input.save-toggle-target', function() { |
| 774 |
var target_id = $( this ).data('target-id'); |
| 775 |
Preferences.user.selected_save_targets[target_id] = this.checked; |
| 776 |
Preferences.Save( [% USER_INFO.borrowernumber %] ); |
| 777 |
} ); |
| 778 |
break; |
| 653 |
case 'selected_search_targets': |
779 |
case 'selected_search_targets': |
| 654 |
$( document ).on( 'change', 'input.search-toggle-server', function() { |
780 |
$( document ).on( 'change', 'input.search-toggle-server', function() { |
| 655 |
var server_id = $( this ).closest('li').data('server-id'); |
781 |
var server_id = $( this ).closest('li').data('server-id'); |
|
Lines 743-748
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 743 |
showSavedMacros(); |
869 |
showSavedMacros(); |
| 744 |
} |
870 |
} |
| 745 |
|
871 |
|
|
|
872 |
function addImportBatch(batch) { |
| 873 |
var backend_id = 'batch:' + batch.batch_id; |
| 874 |
backends[backend_id] = { |
| 875 |
titleForRecord: _("Editing record from batch: ") + batch.name, |
| 876 |
saveLabel: _("Batch: ") + batch.name, |
| 877 |
saveExistingLabel: batch.name + ": #%s", |
| 878 |
get: function( id, callback ) { |
| 879 |
KohaBackend.GetBatchRecord( batch.batch_id, id, function( data ) { |
| 880 |
if ( !data.error ) { |
| 881 |
setSaveTargetChecked( backend_id + '/', false ); |
| 882 |
addSaveTarget( { |
| 883 |
label: batch.name + ": #" + id, |
| 884 |
id: backend_id + '/' + id, |
| 885 |
description: '', |
| 886 |
checked: true |
| 887 |
} ); |
| 888 |
} |
| 889 |
|
| 890 |
callback(data); |
| 891 |
} ); |
| 892 |
}, |
| 893 |
save: function( id, record, done, options ) { |
| 894 |
function finishCb( data ) { |
| 895 |
done( { |
| 896 |
error: data.message || data.error, |
| 897 |
newRecord: data.updated_record, |
| 898 |
newId: data.import_record_id && [ backend_id, data.import_record_id ] |
| 899 |
} ); |
| 900 |
} |
| 901 |
|
| 902 |
if ( id ) { |
| 903 |
KohaBackend.SaveBatchRecord( batch.batch_id, id, record, finishCb, { allow_control_number_conflict: options.override_warnings } ); |
| 904 |
} else { |
| 905 |
KohaBackend.CreateBatchRecord( record, batch.batch_id, finishCb, { allow_control_number_conflict: options.override_warnings } ); |
| 906 |
} |
| 907 |
}, |
| 908 |
}; |
| 909 |
|
| 910 |
// Build batch UI |
| 911 |
var $batch_entry = $( '<li data-batch-id="' + batch.batch_id + '"><input type="checkbox" />' + batch.name + '</li>' ); |
| 912 |
|
| 913 |
var $batch_buttons = $('<span class="batch-buttons"></span>').appendTo($batch_entry); |
| 914 |
var $export_button = $( '<button>' + _("Export...") + '</button>' ).appendTo($batch_buttons).click( function() { |
| 915 |
$('#batches-list .batch-export').hide(); |
| 916 |
$export_screen.show(); |
| 917 |
} ); |
| 918 |
|
| 919 |
var $export_screen = $( |
| 920 |
'<form class="batch-export form-horizontal" style="display: none">' |
| 921 |
+ '<div class="control-group">' |
| 922 |
+ '<label class="control-label">' + _("Control number range:") + '</label>' |
| 923 |
+ '<div class="controls"><input class="batch-control-number-start" type="text"> - <input class="batch-control-number-end" type="text"></div>' |
| 924 |
+ '</div>' |
| 925 |
+ '<label class="control-label">' + _("Timestamp range (YYYYMMDD or YYYMMDDHHMMSS):") + '</label>' |
| 926 |
+ '<div class="controls"><input class="batch-timestamp-start" type="text"> - <input class="batch-timestamp-end" type="text"></div>' |
| 927 |
+ '</div>' |
| 928 |
+ '<div class="control-group">' |
| 929 |
+ '<div class="controls"><button class="batch-export-start">' + _("Start export") + '</div>' |
| 930 |
+ '</form>' |
| 931 |
).appendTo($batch_entry); |
| 932 |
|
| 933 |
$export_screen.find('.batch-export-start').click( function() { |
| 934 |
function getFormVal(name) { |
| 935 |
return $export_screen.find( '.batch-' + name ).val(); |
| 936 |
} |
| 937 |
|
| 938 |
var options = { |
| 939 |
start_control_number: getFormVal('control-number-start'), |
| 940 |
end_control_number: getFormVal('control-number-end'), |
| 941 |
start_timestamp: getFormVal('timestamp-start'), |
| 942 |
end_timestamp: getFormVal('timestamp-end'), |
| 943 |
}; |
| 944 |
|
| 945 |
KohaBackend.StartBatchExport( batch.batch_id, options ); |
| 946 |
} ); |
| 947 |
|
| 948 |
$('#batches-list').append( $batch_entry ); |
| 949 |
} |
| 950 |
|
| 746 |
$(document).ready( function() { |
951 |
$(document).ready( function() { |
| 747 |
// Editor setup |
952 |
// Editor setup |
| 748 |
editor = new MARCEditor( { |
953 |
editor = new MARCEditor( { |
|
Lines 792-797
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 792 |
$(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() ); |
997 |
$(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() ); |
| 793 |
} ); |
998 |
} ); |
| 794 |
}, 100); |
999 |
}, 100); |
|
|
1000 |
|
| 795 |
} |
1001 |
} |
| 796 |
|
1002 |
|
| 797 |
$( '#macro-ui' ).on( 'shown.bs.modal', function() { |
1003 |
$( '#macro-ui' ).on( 'shown.bs.modal', function() { |
|
Lines 832-840
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 832 |
$.each( backends, function( id, backend ) { |
1038 |
$.each( backends, function( id, backend ) { |
| 833 |
if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] ); |
1039 |
if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] ); |
| 834 |
} ); |
1040 |
} ); |
| 835 |
saveableBackends.sort(); |
1041 |
|
| 836 |
$.each( saveableBackends, function( undef, backend ) { |
1042 |
var batch_list = []; |
| 837 |
$( '#save-dropdown' ).append( '<li><a href="#" data-backend="' + backend[1] + '">' + backend[0] + '</a></li>' ); |
1043 |
|
|
|
1044 |
$.each( editable_batches, function( batch_id, batch ) { |
| 1045 |
batch_list.push( $.extend( { batch_id: batch_id }, batch ) ); |
| 1046 |
} ); |
| 1047 |
batch_list.sort( function( a, b ) { |
| 1048 |
return a.name.localeCompare(b.name); |
| 1049 |
} ); |
| 1050 |
$.each( batch_list, function() { |
| 1051 |
addImportBatch( this ); |
| 838 |
} ); |
1052 |
} ); |
| 839 |
|
1053 |
|
| 840 |
var macro_format_list = $.map( Macros.formats, function( format, name ) { |
1054 |
var macro_format_list = $.map( Macros.formats, function( format, name ) { |
|
Lines 850-863
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 850 |
// Click bindings |
1064 |
// Click bindings |
| 851 |
$( '#save-record, #save-dropdown a' ).click( function() { |
1065 |
$( '#save-record, #save-dropdown a' ).click( function() { |
| 852 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") ); |
1066 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") ); |
|
|
1067 |
var enabledTargets = []; |
| 1068 |
var targetNames = []; |
| 1069 |
$.each( state.saveTargets, function() { |
| 1070 |
if ( this.checked ) { |
| 1071 |
enabledTargets.push(this); |
| 1072 |
targetNames.push(this.label); |
| 1073 |
} |
| 1074 |
} ); |
| 1075 |
if ( enabledTargets.length == 0 ) { |
| 1076 |
humanMsg.displayAlert( _("Please select a save target"), { className: 'humanError' } ); |
| 1077 |
return false; |
| 1078 |
} |
| 1079 |
|
| 1080 |
$( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") ); |
| 1081 |
|
| 1082 |
var targets_left = enabledTargets.length; |
| 1083 |
var errors = false; |
| 853 |
|
1084 |
|
| 854 |
function finishCb(result) { |
1085 |
function finishCb(result) { |
| 855 |
if ( result.error == 'syntax' ) { |
1086 |
targets_left--; |
| 856 |
humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } ); |
1087 |
if ( result.error ) { |
| 857 |
} else if ( result.error == 'invalid' ) { |
1088 |
if ( result.error == 'syntax' ) { |
| 858 |
humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } ); |
1089 |
humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } ); |
| 859 |
} else if ( !result.error ) { |
1090 |
} else if ( result.error == 'invalid' ) { |
| 860 |
humanMsg.displayAlert( _("Record saved "), { className: 'humanSuccess' } ); |
1091 |
humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } ); |
|
|
1092 |
} else if ( result.error.type == 'control_number_match' ) { |
| 1093 |
humanMsg.displayAlert( _("Control number conflict, cannot save"), { className: 'humanError' } ); |
| 1094 |
} else { |
| 1095 |
humanMsg.displayAlert( _("Unknown error, record not saved to one or more targets"), { className: 'humanError' } ); |
| 1096 |
} |
| 1097 |
errors = true; |
| 861 |
} |
1098 |
} |
| 862 |
|
1099 |
|
| 863 |
$.each( result.errors || [], function( undef, error ) { |
1100 |
$.each( result.errors || [], function( undef, error ) { |
|
Lines 893-912
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 893 |
} |
1130 |
} |
| 894 |
} ); |
1131 |
} ); |
| 895 |
|
1132 |
|
| 896 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-hdd-o' ); |
|
|
| 897 |
|
1133 |
|
| 898 |
if ( result.error ) { |
1134 |
if ( targets_left == 0 ) { |
| 899 |
// Reset backend info |
1135 |
if ( !errors ) { |
| 900 |
setSource( [ state.backend, state.recordID ] ); |
1136 |
humanMsg.displayMsg( "<h3>" + _("Record saved to:</h3>") + "</h3>" + '<ul><li>' + targetNames.join('</li><li>') + '</li></ul>', { className: 'humanSuccess' } ); |
|
|
1137 |
} |
| 1138 |
|
| 1139 |
$( '#save-record' ).find('i').attr( 'class', 'icon-hdd' ).end().find('span').text( _("Save") ); |
| 901 |
} |
1140 |
} |
| 902 |
} |
1141 |
} |
| 903 |
|
1142 |
|
| 904 |
var backend = $( this ).data( 'backend' ) || ( state.saveBackend ); |
1143 |
$.each( enabledTargets, function() { |
| 905 |
if ( state.backend == backend ) { |
1144 |
saveRecord( this.id, editor, finishCb, options ); |
| 906 |
saveRecord( backend + '/' + state.recordID, editor, finishCb ); |
1145 |
} ); |
| 907 |
} else { |
|
|
| 908 |
saveRecord( backend + '/', editor, finishCb ); |
| 909 |
} |
| 910 |
|
1146 |
|
| 911 |
return false; |
1147 |
return false; |
| 912 |
} ); |
1148 |
} ); |
|
Lines 1047-1057
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 1047 |
} |
1283 |
} |
| 1048 |
} ); |
1284 |
} ); |
| 1049 |
|
1285 |
|
|
|
1286 |
$('#open-batches').click( function() { |
| 1287 |
$('#batches-ui').modal(); |
| 1288 |
|
| 1289 |
return false; |
| 1290 |
} ); |
| 1291 |
|
| 1292 |
$('#create-batch').click( function() { |
| 1293 |
var batch_name = prompt( _("Name of new import batch:") ); |
| 1294 |
if (batch_name == null) return false; |
| 1295 |
|
| 1296 |
KohaBackend.CreateBatch( batch_name, function( data ) { |
| 1297 |
if ( data.error ) { |
| 1298 |
humanMsg.displayAlert( _("Could not create import batch"), { className: 'humanError' } ); |
| 1299 |
} else { |
| 1300 |
humanMsg.displayAlert( _("Import batch created"), { className: 'humanSuccess' } ); |
| 1301 |
|
| 1302 |
addImportBatch( editable_batches[data.batch_id] = { batch_id: data.batch_id, name: batch_name } ); |
| 1303 |
|
| 1304 |
var backend_id = 'batch:' + data.batch_id; |
| 1305 |
addSaveTarget( { |
| 1306 |
label: backends[backend_id].saveLabel, |
| 1307 |
id: backend_id + '/', |
| 1308 |
description: '', |
| 1309 |
enabled: false, |
| 1310 |
} ); |
| 1311 |
} |
| 1312 |
} ); |
| 1313 |
|
| 1314 |
return false; |
| 1315 |
} ); |
| 1316 |
|
| 1317 |
$('#manage-batches').click( function() { |
| 1318 |
window.open('/cgi-bin/koha/tools/manage-marc-import.pl'); |
| 1319 |
|
| 1320 |
return false; |
| 1321 |
} ); |
| 1322 |
|
| 1050 |
// Key bindings |
1323 |
// Key bindings |
| 1051 |
bindGlobalKeys(); |
1324 |
bindGlobalKeys(); |
| 1052 |
|
1325 |
|
| 1053 |
// Setup UI |
1326 |
// Setup UI |
| 1054 |
$("#advanced-search-ui, #search-results-ui, #macro-ui").each( function() { |
1327 |
$(".ui-modal").each( function() { |
| 1055 |
$(this).modal({ show: false }); |
1328 |
$(this).modal({ show: false }); |
| 1056 |
} ); |
1329 |
} ); |
| 1057 |
|
1330 |
|
|
Lines 1113-1118
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
| 1113 |
$('#loading').hide(); |
1386 |
$('#loading').hide(); |
| 1114 |
} |
1387 |
} |
| 1115 |
); |
1388 |
); |
|
|
1389 |
}; ); |
| 1390 |
|
| 1391 |
$.each( backends, function( name ) { |
| 1392 |
if ( !this.save ) return; // Not a saving backend |
| 1393 |
|
| 1394 |
addSaveTarget( { |
| 1395 |
label: this.saveLabel, |
| 1396 |
id: name + '/', |
| 1397 |
description: '', |
| 1398 |
} ); |
| 1116 |
} ); |
1399 |
} ); |
| 1117 |
|
1400 |
|
| 1118 |
// Start editor |
1401 |
// Start editor |