Lines 232-237
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
232 |
[% END %] |
232 |
[% END %] |
233 |
} |
233 |
} |
234 |
|
234 |
|
|
|
235 |
function resetSaveTargets() { |
236 |
$('input.save-toggle-target').each(function() { |
237 |
targetid = $(this).data('target-id'); |
238 |
parts = targetid.split('/'); |
239 |
if (parts[1]) { |
240 |
$(this).parent().remove(); |
241 |
delete state.saveTargets[targetid]; |
242 |
} |
243 |
}); |
244 |
} |
245 |
|
235 |
// Record loading |
246 |
// Record loading |
236 |
var backends = { |
247 |
var backends = { |
237 |
'new': { |
248 |
'new': { |
Lines 464-470
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
464 |
|
475 |
|
465 |
var backend = backends[ parts[0] ]; |
476 |
var backend = backends[ parts[0] ]; |
466 |
|
477 |
|
467 |
setSaveTargetChecked( recid, false ); |
478 |
setSaveTargetChecked( recid, true ); |
468 |
addSaveTarget( { |
479 |
addSaveTarget( { |
469 |
label: backend.saveExistingLabel.format( data.newId[1] ), |
480 |
label: backend.saveExistingLabel.format( data.newId[1] ), |
470 |
id: data.newId.join('/'), |
481 |
id: data.newId.join('/'), |
Lines 652-657
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
652 |
} ); |
663 |
} ); |
653 |
$tr.find( '.open-link' ).click( function() { |
664 |
$tr.find( '.open-link' ).click( function() { |
654 |
$( '#search-results-ui' ).modal('hide'); |
665 |
$( '#search-results-ui' ).modal('hide'); |
|
|
666 |
resetSaveTargets(); |
655 |
openRecord( hit.id, editor ); |
667 |
openRecord( hit.id, editor ); |
656 |
|
668 |
|
657 |
return false; |
669 |
return false; |
Lines 1109-1130
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
1109 |
// Click bindings |
1121 |
// Click bindings |
1110 |
$( '#save-record, #save-dropdown a' ).click( function() { |
1122 |
$( '#save-record, #save-dropdown a' ).click( function() { |
1111 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") ); |
1123 |
$( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner fa-spin' ).siblings( 'span' ).text( _("Saving...") ); |
1112 |
var enabledTargets = []; |
1124 |
var filteredTargets = []; |
1113 |
var targetNames = []; |
1125 |
var targetNames = []; |
1114 |
$.each( state.saveTargets, function() { |
1126 |
$.each( state.saveTargets, function() { |
1115 |
if ( this.checked ) { |
1127 |
if ( this.checked ) { |
1116 |
enabledTargets.push(this); |
1128 |
// Filtering the targets so that if Batch and record in the |
|
|
1129 |
// same Batch are selected, we keep only the record. |
1130 |
// This avoid create (duplicate error) + update. |
1131 |
parts = this.id.split('/'); |
1132 |
filteredTargets[parts[0]] = ''; |
1133 |
if (parts[1]) { |
1134 |
filteredTargets[parts[0]] = parts[1]; |
1135 |
} |
1117 |
targetNames.push(this.label); |
1136 |
targetNames.push(this.label); |
1118 |
} |
1137 |
} |
1119 |
} ); |
1138 |
} ); |
1120 |
if ( enabledTargets.length == 0 ) { |
1139 |
if ( Object.keys(filteredTargets).length == 0 ) { |
1121 |
humanMsg.displayAlert( _("Please select a save target"), { className: 'humanError' } ); |
1140 |
humanMsg.displayAlert( _("Please select a save target"), { className: 'humanError' } ); |
1122 |
return false; |
1141 |
return false; |
1123 |
} |
1142 |
} |
1124 |
|
1143 |
|
1125 |
$( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") ); |
1144 |
$( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") ); |
1126 |
|
1145 |
|
1127 |
var targets_left = enabledTargets.length; |
1146 |
var targets_left = Object.keys(filteredTargets).length; |
1128 |
var errors = false; |
1147 |
var errors = false; |
1129 |
|
1148 |
|
1130 |
function finishCb(result) { |
1149 |
function finishCb(result) { |
Lines 1187-1194
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
1187 |
|
1206 |
|
1188 |
var options = { override_warnings: $(this).is('#save-with-override') } |
1207 |
var options = { override_warnings: $(this).is('#save-with-override') } |
1189 |
|
1208 |
|
1190 |
$.each( enabledTargets, function() { |
1209 |
Object.keys(filteredTargets).forEach(function(key) { |
1191 |
saveRecord( this.id, editor, finishCb, options ); |
1210 |
id = key + '/' + filteredTargets[key]; |
|
|
1211 |
saveRecord( id, editor, finishCb, options ); |
1192 |
} ); |
1212 |
} ); |
1193 |
|
1213 |
|
1194 |
return false; |
1214 |
return false; |
Lines 1217-1222
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
1217 |
|
1237 |
|
1218 |
if (record.marc8_corrupted) humanMsg.displayMsg( '<h3>' + _("Possible record corruption") + '</h3><p>' + _("Record not marked as UTF-8, may be corrupted") + '</p>', { className: 'humanError' } ); |
1238 |
if (record.marc8_corrupted) humanMsg.displayMsg( '<h3>' + _("Possible record corruption") + '</h3><p>' + _("Record not marked as UTF-8, may be corrupted") + '</p>', { className: 'humanError' } ); |
1219 |
|
1239 |
|
|
|
1240 |
resetSaveTargets(); |
1220 |
editor.displayRecord( record ); |
1241 |
editor.displayRecord( record ); |
1221 |
}; |
1242 |
}; |
1222 |
|
1243 |
|
Lines 1410-1415
require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
Link Here
|
1410 |
$('#new-record' ).click( function() { |
1431 |
$('#new-record' ).click( function() { |
1411 |
if ( editor.modified && !confirm( _("Are you sure you want to erase your changes?") ) ) return; |
1432 |
if ( editor.modified && !confirm( _("Are you sure you want to erase your changes?") ) ) return; |
1412 |
|
1433 |
|
|
|
1434 |
resetSaveTargets(); |
1413 |
openRecord( 'new/', editor ); |
1435 |
openRecord( 'new/', editor ); |
1414 |
return false; |
1436 |
return false; |
1415 |
} ); |
1437 |
} ); |
1416 |
- |
|
|