Lines 223-228
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
223 |
[% END %] |
223 |
[% END %] |
224 |
} |
224 |
} |
225 |
|
225 |
|
|
|
226 |
function resetSaveTargets() { |
227 |
$('input.save-toggle-target').each(function() { |
228 |
targetid = $(this).data('target-id'); |
229 |
parts = targetid.split('/'); |
230 |
if (parts[1]) { |
231 |
$(this).parent().remove(); |
232 |
delete state.saveTargets[targetid]; |
233 |
} |
234 |
}); |
235 |
} |
236 |
|
226 |
// Record loading |
237 |
// Record loading |
227 |
var backends = { |
238 |
var backends = { |
228 |
'new': { |
239 |
'new': { |
Lines 439-445
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
439 |
|
450 |
|
440 |
var backend = backends[ parts[0] ]; |
451 |
var backend = backends[ parts[0] ]; |
441 |
|
452 |
|
442 |
setSaveTargetChecked( recid, false ); |
453 |
setSaveTargetChecked( recid, true ); |
443 |
addSaveTarget( { |
454 |
addSaveTarget( { |
444 |
label: backend.saveExistingLabel.format( data.newId[1] ), |
455 |
label: backend.saveExistingLabel.format( data.newId[1] ), |
445 |
id: data.newId.join('/'), |
456 |
id: data.newId.join('/'), |
Lines 627-632
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
627 |
} ); |
638 |
} ); |
628 |
$tr.find( '.open-link' ).click( function() { |
639 |
$tr.find( '.open-link' ).click( function() { |
629 |
$( '#search-results-ui' ).modal('hide'); |
640 |
$( '#search-results-ui' ).modal('hide'); |
|
|
641 |
resetSaveTargets(); |
630 |
openRecord( hit.id, editor ); |
642 |
openRecord( hit.id, editor ); |
631 |
|
643 |
|
632 |
return false; |
644 |
return false; |
Lines 1084-1105
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
1084 |
// Click bindings |
1096 |
// Click bindings |
1085 |
$( '#save-record, #save-dropdown a' ).click( function() { |
1097 |
$( '#save-record, #save-dropdown a' ).click( function() { |
1086 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") ); |
1098 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") ); |
1087 |
var enabledTargets = []; |
1099 |
var filteredTargets = []; |
1088 |
var targetNames = []; |
1100 |
var targetNames = []; |
1089 |
$.each( state.saveTargets, function() { |
1101 |
$.each( state.saveTargets, function() { |
1090 |
if ( this.checked ) { |
1102 |
if ( this.checked ) { |
1091 |
enabledTargets.push(this); |
1103 |
// Filtering the targets so that if Batch and record in the |
|
|
1104 |
// same Batch are selected, we keep only the record. |
1105 |
// This avoid create (duplicate error) + update. |
1106 |
parts = this.id.split('/'); |
1107 |
filteredTargets[parts[0]] = ''; |
1108 |
if (parts[1]) { |
1109 |
filteredTargets[parts[0]] = parts[1]; |
1110 |
} |
1092 |
targetNames.push(this.label); |
1111 |
targetNames.push(this.label); |
1093 |
} |
1112 |
} |
1094 |
} ); |
1113 |
} ); |
1095 |
if ( enabledTargets.length == 0 ) { |
1114 |
if ( Object.keys(filteredTargets).length == 0 ) { |
1096 |
humanMsg.displayAlert( _("Please select a save target"), { className: 'humanError' } ); |
1115 |
humanMsg.displayAlert( _("Please select a save target"), { className: 'humanError' } ); |
1097 |
return false; |
1116 |
return false; |
1098 |
} |
1117 |
} |
1099 |
|
1118 |
|
1100 |
$( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") ); |
1119 |
$( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") ); |
1101 |
|
1120 |
|
1102 |
var targets_left = enabledTargets.length; |
1121 |
var targets_left = Object.keys(filteredTargets).length; |
1103 |
var errors = false; |
1122 |
var errors = false; |
1104 |
|
1123 |
|
1105 |
function finishCb(result) { |
1124 |
function finishCb(result) { |
Lines 1162-1169
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
1162 |
|
1181 |
|
1163 |
var options = { override_warnings: $(this).is('#save-with-override') } |
1182 |
var options = { override_warnings: $(this).is('#save-with-override') } |
1164 |
|
1183 |
|
1165 |
$.each( enabledTargets, function() { |
1184 |
Object.keys(filteredTargets).forEach(function(key) { |
1166 |
saveRecord( this.id, editor, finishCb, options ); |
1185 |
id = key + '/' + filteredTargets[key]; |
|
|
1186 |
saveRecord( id, editor, finishCb, options ); |
1167 |
} ); |
1187 |
} ); |
1168 |
|
1188 |
|
1169 |
return false; |
1189 |
return false; |
Lines 1192-1197
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
1192 |
|
1212 |
|
1193 |
if (record.marc8_corrupted) humanMsg.displayMsg( '<h3>' + _("Possible record corruption") + '</h3><p>' + _("Record not marked as UTF-8, may be corrupted") + '</p>', { className: 'humanError' } ); |
1213 |
if (record.marc8_corrupted) humanMsg.displayMsg( '<h3>' + _("Possible record corruption") + '</h3><p>' + _("Record not marked as UTF-8, may be corrupted") + '</p>', { className: 'humanError' } ); |
1194 |
|
1214 |
|
|
|
1215 |
resetSaveTargets(); |
1195 |
editor.displayRecord( record ); |
1216 |
editor.displayRecord( record ); |
1196 |
}; |
1217 |
}; |
1197 |
|
1218 |
|
Lines 1385-1390
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
1385 |
$('#new-record' ).click( function() { |
1406 |
$('#new-record' ).click( function() { |
1386 |
if ( editor.modified && !confirm( _("Are you sure you want to erase your changes?") ) ) return; |
1407 |
if ( editor.modified && !confirm( _("Are you sure you want to erase your changes?") ) ) return; |
1387 |
|
1408 |
|
|
|
1409 |
resetSaveTargets(); |
1388 |
openRecord( 'new/', editor ); |
1410 |
openRecord( 'new/', editor ); |
1389 |
return false; |
1411 |
return false; |
1390 |
} ); |
1412 |
} ); |
1391 |
- |
|
|