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