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