| 
      
            Lines 38-43
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 38 | 
                      recordtype: 'biblio',  | 
          38 | 
                      recordtype: 'biblio',  | 
        
        
          | 39 | 
                      checked: false,  | 
          39 | 
                      checked: false,  | 
        
        
          | 40 | 
                  },  | 
          40 | 
                  },  | 
        
            
               | 
               | 
              41 | 
                      [%- FOREACH batch = editable_batches -%]  | 
            
            
              | 42 | 
                          'batch:[% batch.import_batch_id %]': { | 
            
            
              | 43 | 
                              name: _("Batch: ") + '[% batch.file_name %]', | 
            
            
              | 44 | 
                              recordtype: 'biblio',  | 
            
            
              | 45 | 
                              checked: false,  | 
            
            
              | 46 | 
                          },  | 
            
            
              | 47 | 
                      [%- END -%]  | 
            
        
          | 41 | 
                  [%- FOREACH server = z3950_servers -%]  | 
          48 | 
                  [%- FOREACH server = z3950_servers -%]  | 
        
        
          | 42 | 
                      [% server.id | html %]: { | 
          49 | 
                      [% server.id | html %]: { | 
        
        
          | 43 | 
                          name: '[% server.servername | html %]',  | 
          50 | 
                          name: '[% server.servername | html %]',  | 
        
  
    | 
      
            Lines 63-70
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 63 | 
           | 
          70 | 
           | 
        
        
          | 64 | 
              var state = { | 
          71 | 
              var state = { | 
        
        
          | 65 | 
                  backend: '',  | 
          72 | 
                  backend: '',  | 
        
          
            
              | 66 | 
                      saveBackend: 'catalog',  | 
              73 | 
                      recordID: undefined,  | 
            
            
              | 67 | 
                      recordID: undefined  | 
              74 | 
                      saveTargets: {}, | 
            
        
          | 68 | 
              };  | 
          75 | 
              };  | 
        
        
          | 69 | 
           | 
          76 | 
           | 
        
        
          | 70 | 
              var editor;  | 
          77 | 
              var editor;  | 
        
  
    | 
      
            Lines 228-243
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 228 | 
                      },  | 
          235 | 
                      },  | 
        
        
          | 229 | 
                  },  | 
          236 | 
                  },  | 
        
        
          | 230 | 
                  'catalog': { | 
          237 | 
                  'catalog': { | 
        
          
            
              | 231 | 
                          titleForRecord: _("Editing catalog record #{ID}"), | 
              238 | 
                          titleForRecord: _("Editing catalog record #%s"), | 
            
        
          | 232 | 
                      links: [  | 
          239 | 
                      links: [  | 
        
          
            
              | 233 | 
                              { title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber={ID}" }, | 
              240 | 
                              { title: _("view"), href: "/cgi-bin/koha/catalogue/detail.pl?biblionumber=%s" }, | 
            
            
              | 234 | 
                              { title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber={ID}" }, | 
              241 | 
                              { title: _("edit items"), href: "/cgi-bin/koha/cataloguing/additem.pl?biblionumber=%s" }, | 
            
        
          | 235 | 
                      ],  | 
          242 | 
                      ],  | 
        
          
            
              | 236 | 
                          saveLabel: _("Save to catalog"), | 
              243 | 
                          saveLabel: _("New catalog record"), | 
            
            
               | 
               | 
              244 | 
                          saveExistingLabel: _("Catalog record #%s"), | 
            
        
          | 237 | 
                      get: function( id, callback ) { | 
          245 | 
                      get: function( id, callback ) { | 
        
        
          | 238 | 
                          if ( !id ) return false;  | 
          246 | 
                          if ( !id ) return false;  | 
        
        
          | 239 | 
           | 
          247 | 
           | 
        
          
            
              | 240 | 
                              KohaBackend.GetRecord( id, callback );  | 
              248 | 
                              KohaBackend.GetRecord( id, function( data ) { | 
            
            
               | 
               | 
              249 | 
                                  if ( !data.error ) { | 
            
            
              | 250 | 
                                      setSaveTargetChecked( 'catalog/', false );  | 
            
            
              | 251 | 
                                      addSaveTarget( { | 
            
            
              | 252 | 
                                          label: backends.catalog.saveExistingLabel.format( id ),  | 
            
            
              | 253 | 
                                          id: 'catalog/' + id,  | 
            
            
              | 254 | 
                                          description: '',  | 
            
            
              | 255 | 
                                          checked: true  | 
            
            
              | 256 | 
                                      } );  | 
            
            
              | 257 | 
                                  }  | 
            
            
              | 258 | 
               | 
            
            
              | 259 | 
                                  callback(data);  | 
            
            
              | 260 | 
                              } );  | 
            
        
          | 241 | 
                      },  | 
          261 | 
                      },  | 
        
        
          | 242 | 
                      save: function( id, record, done ) { | 
          262 | 
                      save: function( id, record, done ) { | 
        
        
          | 243 | 
                          function finishCb( data ) { | 
          263 | 
                          function finishCb( data ) { | 
        
  
    | 
      
            Lines 252-258
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 252 | 
                      }  | 
          272 | 
                      }  | 
        
        
          | 253 | 
                  },  | 
          273 | 
                  },  | 
        
        
          | 254 | 
                  'iso2709': { | 
          274 | 
                  'iso2709': { | 
        
          
            
              | 255 | 
                          saveLabel: _("Save as ISO2709 (.mrc) file"), | 
              275 | 
                          saveLabel: _("New ISO2709 (.mrc) file"), | 
            
        
          | 256 | 
                      save: function( id, record, done ) { | 
          276 | 
                      save: function( id, record, done ) { | 
        
        
          | 257 | 
                          saveAs( new Blob( [record.toISO2709()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.mrc' ); | 
          277 | 
                          saveAs( new Blob( [record.toISO2709()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.mrc' ); | 
        
        
          | 258 | 
           | 
          278 | 
           | 
        
  
    | 
      
            Lines 260-266
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 260 | 
                      }  | 
          280 | 
                      }  | 
        
        
          | 261 | 
                  },  | 
          281 | 
                  },  | 
        
        
          | 262 | 
                  'marcxml': { | 
          282 | 
                  'marcxml': { | 
        
          
            
              | 263 | 
                          saveLabel: _("Save as MARCXML (.xml) file"), | 
              283 | 
                          saveLabel: _("New MARCXML (.xml) file"), | 
            
        
          | 264 | 
                      save: function( id, record, done ) { | 
          284 | 
                      save: function( id, record, done ) { | 
        
        
          | 265 | 
                          saveAs( new Blob( [record.toXML()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.xml' ); | 
          285 | 
                          saveAs( new Blob( [record.toXML()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.xml' ); | 
        
        
          | 266 | 
           | 
          286 | 
           | 
        
  
    | 
      
            Lines 282-287
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 282 | 
                  },  | 
          302 | 
                  },  | 
        
        
          | 283 | 
              };  | 
          303 | 
              };  | 
        
        
          | 284 | 
           | 
          304 | 
           | 
        
            
               | 
               | 
              305 | 
                  var editable_batches = { | 
            
            
              | 306 | 
                      [%- FOREACH batch = editable_batches -%]  | 
            
            
              | 307 | 
                          [% batch.import_batch_id %]: { | 
            
            
              | 308 | 
                              'name': '[% batch.file_name %]',  | 
            
            
              | 309 | 
                          },  | 
            
            
              | 310 | 
                      [%- END -%]  | 
            
            
              | 311 | 
                  };  | 
            
            
              | 312 | 
               | 
            
            
              | 313 | 
                  function addSaveTarget( target ) { | 
            
            
              | 314 | 
                      state.saveTargets[target.id] = target;  | 
            
            
              | 315 | 
                      if (target.enabled == null) target.enabled = true;  | 
            
            
              | 316 | 
               | 
            
            
              | 317 | 
                      // Have to check that Preferences has been initialized  | 
            
            
              | 318 | 
                      var saved_value = Preferences.user && Preferences.user.selected_save_targets[target.id];  | 
            
            
              | 319 | 
                      if ( saved_value != null ) target.checked = saved_value;  | 
            
            
              | 320 | 
               | 
            
            
              | 321 | 
                      var target_list = $.map( state.saveTargets, function( target ) { | 
            
            
              | 322 | 
                          return target;  | 
            
            
              | 323 | 
                      } );  | 
            
            
              | 324 | 
               | 
            
            
              | 325 | 
                      target_list.sort( function( a, b ) { | 
            
            
              | 326 | 
                          return a.label.localeCompare(b.label);  | 
            
            
              | 327 | 
                      } );  | 
            
            
              | 328 | 
               | 
            
            
              | 329 | 
                      $('#save-targets ol').empty(); | 
            
            
              | 330 | 
               | 
            
            
              | 331 | 
                      $.each( target_list, function( i, target ) { | 
            
            
              | 332 | 
                          var $new_target = $(  | 
            
            
              | 333 | 
                              '<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>'  | 
            
            
              | 334 | 
                          );  | 
            
            
              | 335 | 
               | 
            
            
              | 336 | 
                          $new_target.find('input').change( function() { | 
            
            
              | 337 | 
                              target.checked = this.checked;  | 
            
            
              | 338 | 
                          } );  | 
            
            
              | 339 | 
               | 
            
            
              | 340 | 
                          $('#save-targets ol').append($new_target); | 
            
            
              | 341 | 
               | 
            
            
              | 342 | 
                          if (!target.enabled) $new_target.hide();  | 
            
            
              | 343 | 
                      } );  | 
            
            
              | 344 | 
                  }  | 
            
            
              | 345 | 
               | 
            
            
              | 346 | 
                  function setSaveTargetChecked( target_id, checked ) { | 
            
            
              | 347 | 
                      if ( state.saveTargets[target_id] == null ) return;  | 
            
            
              | 348 | 
               | 
            
            
              | 349 | 
                      state.saveTargets[target_id].checked = checked;  | 
            
            
              | 350 | 
                      $( '#save-targets input[data-target-id="' + target_id + '"]' )[0].checked = checked;  | 
            
            
              | 351 | 
                  }  | 
            
            
              | 352 | 
               | 
            
            
              | 353 | 
                  function setSaveTargetEnabled( target_id, enabled ) { | 
            
            
              | 354 | 
                      if ( !enabled ) { | 
            
            
              | 355 | 
                          setSaveTargetChecked( target_id, false );  | 
            
            
              | 356 | 
                      }  | 
            
            
              | 357 | 
               | 
            
            
              | 358 | 
                      state.saveTargets[target_id].enabled = enabled;  | 
            
            
              | 359 | 
                      $( '#save-targets input[data-target-id="' + target_id + '"]' ).closest('li').toggle(enabled); | 
            
            
              | 360 | 
                  }  | 
            
            
              | 361 | 
               | 
            
        
          | 285 | 
              function setSource(parts) { | 
          362 | 
              function setSource(parts) { | 
        
        
          | 286 | 
                  state.backend = parts[0];  | 
          363 | 
                  state.backend = parts[0];  | 
        
        
          | 287 | 
                  state.recordID = parts[1];  | 
          364 | 
                  state.recordID = parts[1];  | 
        
  
    | 
      
            Lines 292-304
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 292 | 
           | 
          369 | 
           | 
        
        
          | 293 | 
                  document.location.hash = '#' + parts[0] + '/' + parts[1];  | 
          370 | 
                  document.location.hash = '#' + parts[0] + '/' + parts[1];  | 
        
        
          | 294 | 
           | 
          371 | 
           | 
        
          
            
              | 295 | 
                      $('#title').text( backend.titleForRecord.replace( '{ID}', parts[1] ) ); | 
              372 | 
                      $('#title').text( backend.titleForRecord.format( parts[1] ) ); | 
            
        
          | 296 | 
           | 
          373 | 
           | 
        
        
          | 297 | 
                  $.each( backend.links || [], function( i, link ) { | 
          374 | 
                  $.each( backend.links || [], function( i, link ) { | 
        
          
            
              | 298 | 
                          $('#title').append(' <a target="_blank" href="' + link.href.replace( '{ID}', parts[1] ) + '">(' + link.title + ')</a>' ); | 
              375 | 
                          $('#title').append(' <a target="_blank" href="' + link.href.format( parts[1] ) + '">(' + link.title + ')</a>' ); | 
            
        
          | 299 | 
                  } );  | 
          376 | 
                  } );  | 
        
          
            
              | 300 | 
                      $( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.replace( '{ID}', parts[1] ) ); | 
              377 | 
                      $( 'title', document.head ).html( _("Koha › Cataloging › ") + backend.titleForRecord.format( parts[1] ) ); | 
            
            
              | 301 | 
                      $('#save-record span').text( backends[ state.saveBackend ].saveLabel ); | 
               | 
               | 
            
        
          | 302 | 
              }  | 
          378 | 
              }  | 
        
        
          | 303 | 
           | 
          379 | 
           | 
        
        
          | 304 | 
              function saveRecord( recid, editor, callback ) { | 
          380 | 
              function saveRecord( recid, editor, callback ) { | 
        
  
    | 
      
            Lines 334-339
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 334 | 
           | 
          410 | 
           | 
        
        
          | 335 | 
                      if (data.newId) { | 
          411 | 
                      if (data.newId) { | 
        
        
          | 336 | 
                          setSource(data.newId);  | 
          412 | 
                          setSource(data.newId);  | 
        
            
               | 
               | 
              413 | 
               | 
            
            
              | 414 | 
                              var backend = backends[ parts[0] ];  | 
            
            
              | 415 | 
               | 
            
            
              | 416 | 
                              setSaveTargetChecked( recid, false );  | 
            
            
              | 417 | 
                              addSaveTarget( { | 
            
            
              | 418 | 
                                  label: backend.saveExistingLabel.format( data.newId[1] ),  | 
            
            
              | 419 | 
                                  id: data.newId.join('/'), | 
            
            
              | 420 | 
                                  description: '',  | 
            
            
              | 421 | 
                                  checked: true  | 
            
            
              | 422 | 
                              } );  | 
            
        
          | 337 | 
                      } else { | 
          423 | 
                      } else { | 
        
        
          | 338 | 
                          setSource( [ state.backend, state.recordID ] );  | 
          424 | 
                          setSource( [ state.backend, state.recordID ] );  | 
        
        
          | 339 | 
                      }  | 
          425 | 
                      }  | 
        
  
    | 
      
            Lines 592-597
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 592 | 
                  var value = Preferences.user[pref];  | 
          678 | 
                  var value = Preferences.user[pref];  | 
        
        
          | 593 | 
           | 
          679 | 
           | 
        
        
          | 594 | 
                  switch (pref) { | 
          680 | 
                  switch (pref) { | 
        
            
               | 
               | 
              681 | 
                          case 'enabledBatches':  | 
            
            
              | 682 | 
                              $.each( editable_batches, function( batch_id, batch ) { | 
            
            
              | 683 | 
                                  $( '#batches-list li[data-batch-id=' + batch_id + '] input' )[0].checked = Preferences.user.enabledBatches[batch_id];  | 
            
            
              | 684 | 
                                  setSaveTargetEnabled( 'batch:' + batch_id + '/', Preferences.user.enabledBatches[batch_id] || false );  | 
            
            
              | 685 | 
                              } );  | 
            
        
          | 595 | 
                      case 'fieldWidgets':  | 
          686 | 
                      case 'fieldWidgets':  | 
        
        
          | 596 | 
                          $( '#set-field-widgets' ).text( value ? _("Show fields verbatim") : _("Show helpers for fixed and coded fields") ); | 
          687 | 
                          $( '#set-field-widgets' ).text( value ? _("Show fields verbatim") : _("Show helpers for fixed and coded fields") ); | 
        
        
          | 597 | 
                          break;  | 
          688 | 
                          break;  | 
        
  
    | 
      
            Lines 613-618
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 613 | 
                              if ( saved_val != null ) server.checked = saved_val;  | 
          704 | 
                              if ( saved_val != null ) server.checked = saved_val;  | 
        
        
          | 614 | 
                          } );  | 
          705 | 
                          } );  | 
        
        
          | 615 | 
                          break;  | 
          706 | 
                          break;  | 
        
            
               | 
               | 
              707 | 
                          case 'selected_save_targets':  | 
            
            
              | 708 | 
                              $.each( state.saveTargets, function( target_id, target ) { | 
            
            
              | 709 | 
                                  var saved_val = Preferences.user.selected_save_targets[target_id];  | 
            
            
              | 710 | 
               | 
            
            
              | 711 | 
                                  if ( saved_val != null ) setSaveTargetChecked( target_id, saved_val );  | 
            
            
              | 712 | 
                              } );  | 
            
            
              | 713 | 
                              break;  | 
            
            
              | 714 | 
                          case 'selected_search_targets':  | 
            
            
              | 715 | 
                              $.each( z3950Servers, function( server_id, server ) { | 
            
            
              | 716 | 
                                  var saved_val = Preferences.user.selected_search_targets[server_id];  | 
            
            
              | 717 | 
               | 
            
            
              | 718 | 
                                  if ( saved_val != null ) server.checked = saved_val;  | 
            
            
              | 719 | 
                              } );  | 
            
            
              | 720 | 
                              break;  | 
            
        
          | 616 | 
                  }  | 
          721 | 
                  }  | 
        
        
          | 617 | 
              }  | 
          722 | 
              }  | 
        
        
          | 618 | 
           | 
          723 | 
           | 
        
  
    | 
      
            Lines 626-632
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 626 | 
                      } );  | 
          731 | 
                      } );  | 
        
        
          | 627 | 
                  }  | 
          732 | 
                  }  | 
        
        
          | 628 | 
           | 
          733 | 
           | 
        
            
               | 
               | 
              734 | 
                      function _addLiveHandler( sel, event, handler ) { | 
            
            
              | 735 | 
                          $( document ).on( event, sel, function (e) { | 
            
            
              | 736 | 
                              e.preventDefault();  | 
            
            
              | 737 | 
                              handler.call( this, e, Preferences.user[pref] );  | 
            
            
              | 738 | 
                              Preferences.Save( [% USER_INFO.borrowernumber %] );  | 
            
            
              | 739 | 
                              showPreference(pref);  | 
            
            
              | 740 | 
                          } );  | 
            
            
              | 741 | 
                      }  | 
            
            
              | 742 | 
               | 
            
        
          | 629 | 
                  switch (pref) { | 
          743 | 
                  switch (pref) { | 
        
            
               | 
               | 
              744 | 
                          case 'enabledBatches':  | 
            
            
              | 745 | 
                              _addLiveHandler( '#batches-list input', 'change', function() { | 
            
            
              | 746 | 
                                  Preferences.user.enabledBatches[ $( this ).closest('li').data('batch-id') ] = this.checked; | 
            
            
              | 747 | 
                              } );  | 
            
            
              | 748 | 
                              break;  | 
            
        
          | 630 | 
                      case 'fieldWidgets':  | 
          749 | 
                      case 'fieldWidgets':  | 
        
        
          | 631 | 
                          _addHandler( '#set-field-widgets', 'click', function( e, oldValue ) { | 
          750 | 
                          _addHandler( '#set-field-widgets', 'click', function( e, oldValue ) { | 
        
        
          | 632 | 
                              editor.setUseWidgets( Preferences.user.fieldWidgets = !Preferences.user.fieldWidgets );  | 
          751 | 
                              editor.setUseWidgets( Preferences.user.fieldWidgets = !Preferences.user.fieldWidgets );  | 
        
  
    | 
      
            Lines 642-647
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 642 | 
                              Preferences.user.fontSize = $( e.target ).css( 'font-size' );  | 
          761 | 
                              Preferences.user.fontSize = $( e.target ).css( 'font-size' );  | 
        
        
          | 643 | 
                          } );  | 
          762 | 
                          } );  | 
        
        
          | 644 | 
                          break;  | 
          763 | 
                          break;  | 
        
            
               | 
               | 
              764 | 
                          case 'selected_save_targets':  | 
            
            
              | 765 | 
                              $( document ).on( 'change', 'input.save-toggle-target', function() { | 
            
            
              | 766 | 
                                  var target_id = $( this ).data('target-id'); | 
            
            
              | 767 | 
                                  Preferences.user.selected_save_targets[target_id] = this.checked;  | 
            
            
              | 768 | 
                                  Preferences.Save( [% USER_INFO.borrowernumber %] );  | 
            
            
              | 769 | 
                              } );  | 
            
            
              | 770 | 
                              break;  | 
            
        
          | 645 | 
                      case 'selected_search_targets':  | 
          771 | 
                      case 'selected_search_targets':  | 
        
        
          | 646 | 
                          $( document ).on( 'change', 'input.search-toggle-server', function() { | 
          772 | 
                          $( document ).on( 'change', 'input.search-toggle-server', function() { | 
        
        
          | 647 | 
                              var server_id = $( this ).closest('li').data('server-id'); | 
          773 | 
                              var server_id = $( this ).closest('li').data('server-id'); | 
        
  
    | 
      
            Lines 735-740
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 735 | 
                  showSavedMacros();  | 
          861 | 
                  showSavedMacros();  | 
        
        
          | 736 | 
              }  | 
          862 | 
              }  | 
        
        
          | 737 | 
           | 
          863 | 
           | 
        
            
               | 
               | 
              864 | 
                  function addImportBatch(batch) { | 
            
            
              | 865 | 
                      var backend_id = 'batch:' + batch.batch_id;  | 
            
            
              | 866 | 
                      backends[backend_id] = { | 
            
            
              | 867 | 
                          titleForRecord: _("Editing record from batch: ") + batch.name, | 
            
            
              | 868 | 
                          saveLabel: _("Batch: ") + batch.name, | 
            
            
              | 869 | 
                          saveExistingLabel: batch.name + ": #%s",  | 
            
            
              | 870 | 
                          get: function( id, callback ) { | 
            
            
              | 871 | 
                              KohaBackend.GetBatchRecord( batch.batch_id, id, function( data ) { | 
            
            
              | 872 | 
                                  if ( !data.error ) { | 
            
            
              | 873 | 
                                      setSaveTargetChecked( backend_id + '/', false );  | 
            
            
              | 874 | 
                                      addSaveTarget( { | 
            
            
              | 875 | 
                                          label: batch.name + ": #" + id,  | 
            
            
              | 876 | 
                                          id: backend_id + '/' + id,  | 
            
            
              | 877 | 
                                          description: '',  | 
            
            
              | 878 | 
                                          checked: true  | 
            
            
              | 879 | 
                                      } );  | 
            
            
              | 880 | 
                                  }  | 
            
            
              | 881 | 
               | 
            
            
              | 882 | 
                                  callback(data);  | 
            
            
              | 883 | 
                              } );  | 
            
            
              | 884 | 
                          },  | 
            
            
              | 885 | 
                          save: function( id, record, done, options ) { | 
            
            
              | 886 | 
                              function finishCb( data ) { | 
            
            
              | 887 | 
                                  done( { | 
            
            
              | 888 | 
                                      error: data.message || data.error,  | 
            
            
              | 889 | 
                                      newRecord: data.updated_record,  | 
            
            
              | 890 | 
                                      newId: data.import_record_id && [ backend_id, data.import_record_id ]  | 
            
            
              | 891 | 
                                  } );  | 
            
            
              | 892 | 
                              }  | 
            
            
              | 893 | 
               | 
            
            
              | 894 | 
                              if ( id ) { | 
            
            
              | 895 | 
                                  KohaBackend.SaveBatchRecord( batch.batch_id, id, record, finishCb, { allow_control_number_conflict: options.override_warnings } ); | 
            
            
              | 896 | 
                              } else { | 
            
            
              | 897 | 
                                  KohaBackend.CreateBatchRecord( record, batch.batch_id, finishCb, { allow_control_number_conflict: options.override_warnings } ); | 
            
            
              | 898 | 
                              }  | 
            
            
              | 899 | 
                          },  | 
            
            
              | 900 | 
                      };  | 
            
            
              | 901 | 
               | 
            
            
              | 902 | 
                      // Build batch UI  | 
            
            
              | 903 | 
                      var $batch_entry = $( '<li data-batch-id="' + batch.batch_id + '"><input type="checkbox" />' + batch.name + '</li>' );  | 
            
            
              | 904 | 
               | 
            
            
              | 905 | 
                      var $batch_buttons = $('<span class="batch-buttons"></span>').appendTo($batch_entry); | 
            
            
              | 906 | 
                      var $export_button = $( '<button>' + _("Export...") + '</button>' ).appendTo($batch_buttons).click( function() { | 
            
            
              | 907 | 
                          $('#batches-list .batch-export').hide(); | 
            
            
              | 908 | 
                          $export_screen.show();  | 
            
            
              | 909 | 
                      } );  | 
            
            
              | 910 | 
               | 
            
            
              | 911 | 
                      var $export_screen = $(  | 
            
            
              | 912 | 
                          '<form class="batch-export form-horizontal" style="display: none">'  | 
            
            
              | 913 | 
                          + '<div class="control-group">'  | 
            
            
              | 914 | 
                          + '<label class="control-label">' + _("Control number range:") + '</label>' | 
            
            
              | 915 | 
                          + '<div class="controls"><input class="batch-control-number-start" type="text"> - <input class="batch-control-number-end" type="text"></div>'  | 
            
            
              | 916 | 
                          + '</div>'  | 
            
            
              | 917 | 
                          + '<label class="control-label">' + _("Timestamp range (YYYYMMDD or YYYMMDDHHMMSS):") + '</label>' | 
            
            
              | 918 | 
                          + '<div class="controls"><input class="batch-timestamp-start" type="text"> - <input class="batch-timestamp-end" type="text"></div>'  | 
            
            
              | 919 | 
                          + '</div>'  | 
            
            
              | 920 | 
                          + '<div class="control-group">'  | 
            
            
              | 921 | 
                          + '<div class="controls"><button class="batch-export-start">' + _("Start export") + '</div>' | 
            
            
              | 922 | 
                          + '</form>'  | 
            
            
              | 923 | 
                      ).appendTo($batch_entry);  | 
            
            
              | 924 | 
               | 
            
            
              | 925 | 
                      $export_screen.find('.batch-export-start').click( function() { | 
            
            
              | 926 | 
                          function getFormVal(name) { | 
            
            
              | 927 | 
                              return $export_screen.find( '.batch-' + name ).val();  | 
            
            
              | 928 | 
                          }  | 
            
            
              | 929 | 
               | 
            
            
              | 930 | 
                          var options = { | 
            
            
              | 931 | 
                              start_control_number: getFormVal('control-number-start'), | 
            
            
              | 932 | 
                              end_control_number: getFormVal('control-number-end'), | 
            
            
              | 933 | 
                              start_timestamp: getFormVal('timestamp-start'), | 
            
            
              | 934 | 
                              end_timestamp: getFormVal('timestamp-end'), | 
            
            
              | 935 | 
                          };  | 
            
            
              | 936 | 
               | 
            
            
              | 937 | 
                          KohaBackend.StartBatchExport( batch.batch_id, options );  | 
            
            
              | 938 | 
                      } );  | 
            
            
              | 939 | 
               | 
            
            
              | 940 | 
                      $('#batches-list').append( $batch_entry ); | 
            
            
              | 941 | 
                  }  | 
            
            
              | 942 | 
               | 
            
        
          | 738 | 
              $(document).ready( function() { | 
          943 | 
              $(document).ready( function() { | 
        
        
          | 739 | 
                  // Editor setup  | 
          944 | 
                  // Editor setup  | 
        
        
          | 740 | 
                  editor = new MARCEditor( { | 
          945 | 
                  editor = new MARCEditor( { | 
        
  
    | 
      
            Lines 784-789
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 784 | 
                              $(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() ); | 
          989 | 
                              $(this).height( $(window).height() * .8 - $(this).prevAll('.modal-header').height() ); | 
        
        
          | 785 | 
                          } );  | 
          990 | 
                          } );  | 
        
        
          | 786 | 
                      }, 100);  | 
          991 | 
                      }, 100);  | 
        
            
               | 
               | 
              992 | 
               | 
            
        
          | 787 | 
                  }  | 
          993 | 
                  }  | 
        
        
          | 788 | 
           | 
          994 | 
           | 
        
        
          | 789 | 
                  $( '#macro-ui' ).on( 'shown.bs.modal', function() { | 
          995 | 
                  $( '#macro-ui' ).on( 'shown.bs.modal', function() { | 
        
  
    | 
      
            Lines 824-832
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 824 | 
                  $.each( backends, function( id, backend ) { | 
          1030 | 
                  $.each( backends, function( id, backend ) { | 
        
        
          | 825 | 
                      if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] );  | 
          1031 | 
                      if ( backend.save ) saveableBackends.push( [ backend.saveLabel, id ] );  | 
        
        
          | 826 | 
                  } );  | 
          1032 | 
                  } );  | 
        
          
            
              | 827 | 
                      saveableBackends.sort();  | 
              1033 | 
               | 
            
            
              | 828 | 
                      $.each( saveableBackends, function( undef, backend ) { | 
              1034 | 
                      var batch_list = [];  | 
            
            
              | 829 | 
                          $( '#save-dropdown' ).append( '<li><a href="#" data-backend="' + backend[1] + '">' + backend[0] + '</a></li>' );  | 
              1035 | 
               | 
            
            
               | 
               | 
              1036 | 
                      $.each( editable_batches, function( batch_id, batch ) { | 
            
            
              | 1037 | 
                          batch_list.push( $.extend( { batch_id: batch_id }, batch ) ); | 
            
            
              | 1038 | 
                      } );  | 
            
            
              | 1039 | 
                      batch_list.sort( function( a, b ) { | 
            
            
              | 1040 | 
                          return a.name.localeCompare(b.name);  | 
            
            
              | 1041 | 
                      } );  | 
            
            
              | 1042 | 
                      $.each( batch_list, function() { | 
            
            
              | 1043 | 
                          addImportBatch( this );  | 
            
        
          | 830 | 
                  } );  | 
          1044 | 
                  } );  | 
        
        
          | 831 | 
           | 
          1045 | 
           | 
        
        
          | 832 | 
                  var macro_format_list = $.map( Macros.formats, function( format, name ) { | 
          1046 | 
                  var macro_format_list = $.map( Macros.formats, function( format, name ) { | 
        
  
    | 
      
            Lines 841-855
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 841 | 
           | 
          1055 | 
           | 
        
        
          | 842 | 
                  // Click bindings  | 
          1056 | 
                  // Click bindings  | 
        
        
          | 843 | 
                  $( '#save-record, #save-dropdown a' ).click( function() { | 
          1057 | 
                  $( '#save-record, #save-dropdown a' ).click( function() { | 
        
          
            
              | 844 | 
                          $( '#save-record' ).find('i').attr( 'class', 'fa fa-spinner' ).siblings( 'span' ).text( _("Saving...") ); | 
              1058 | 
                          var enabledTargets = [];  | 
            
            
               | 
               | 
              1059 | 
                          var targetNames = [];  | 
            
            
              | 1060 | 
                          $.each( state.saveTargets, function() { | 
            
            
              | 1061 | 
                              if ( this.checked ) { | 
            
            
              | 1062 | 
                                  enabledTargets.push(this);  | 
            
            
              | 1063 | 
                                  targetNames.push(this.label);  | 
            
            
              | 1064 | 
                              }  | 
            
            
              | 1065 | 
                          } );  | 
            
            
              | 1066 | 
                          if ( enabledTargets.length == 0 ) { | 
            
            
              | 1067 | 
                              humanMsg.displayAlert( _("Please select a save target"), { className: 'humanError' } ); | 
            
            
              | 1068 | 
                              return false;  | 
            
            
              | 1069 | 
                          }  | 
            
            
              | 1070 | 
               | 
            
            
              | 1071 | 
                          $( '#save-record' ).find('i').attr( 'class', 'icon-loading' ).siblings( 'span' ).text( _("Saving...") ); | 
            
            
              | 1072 | 
               | 
            
            
              | 1073 | 
                          var targets_left = enabledTargets.length;  | 
            
            
              | 1074 | 
                          var errors = false;  | 
            
        
          | 845 | 
           | 
          1075 | 
           | 
        
        
          | 846 | 
                      function finishCb(result) { | 
          1076 | 
                      function finishCb(result) { | 
        
          
            
              | 847 | 
                              if ( result.error == 'syntax' ) { | 
              1077 | 
                              targets_left--;  | 
            
            
              | 848 | 
                                  humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } ); | 
              1078 | 
                              if ( result.error ) { | 
            
            
              | 849 | 
                              } else if ( result.error == 'invalid' ) { | 
              1079 | 
                                  if ( result.error == 'syntax' ) { | 
            
            
              | 850 | 
                                  humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } ); | 
              1080 | 
                                      humanMsg.displayAlert( _("Incorrect syntax, cannot save"), { className: 'humanError' } ); | 
            
            
              | 851 | 
                              } else if ( !result.error ) { | 
              1081 | 
                                  } else if ( result.error == 'invalid' ) { | 
            
            
              | 852 | 
                                  humanMsg.displayAlert( _("Record saved "), { className: 'humanSuccess' } ); | 
              1082 | 
                                      humanMsg.displayAlert( _("Record structure invalid, cannot save"), { className: 'humanError' } ); | 
            
            
               | 
               | 
              1083 | 
                                  } else if ( result.error.type == 'control_number_match' ) { | 
            
            
              | 1084 | 
                                      humanMsg.displayAlert( _("Control number conflict, cannot save"), { className: 'humanError' } ); | 
            
            
              | 1085 | 
                                  } else { | 
            
            
              | 1086 | 
                                      humanMsg.displayAlert( _("Unknown error, record not saved to one or more targets"), { className: 'humanError' } ); | 
            
            
              | 1087 | 
                                  }  | 
            
            
              | 1088 | 
                                  errors = true;  | 
            
        
          | 853 | 
                          }  | 
          1089 | 
                          }  | 
        
        
          | 854 | 
           | 
          1090 | 
           | 
        
        
          | 855 | 
                          $.each( result.errors || [], function( undef, error ) { | 
          1091 | 
                          $.each( result.errors || [], function( undef, error ) { | 
        
  
    | 
      
            Lines 885-904
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 885 | 
                              }  | 
          1121 | 
                              }  | 
        
        
          | 886 | 
                          } );  | 
          1122 | 
                          } );  | 
        
        
          | 887 | 
           | 
          1123 | 
           | 
        
            
              | 888 | 
                              $( '#save-record' ).find('i').attr( 'class', 'fa fa-hdd-o' ); | 
               | 
               | 
            
        
          | 889 | 
           | 
          1124 | 
           | 
        
          
            
              | 890 | 
                              if ( result.error ) { | 
              1125 | 
                              if ( targets_left == 0 ) { | 
            
            
              | 891 | 
                                  // Reset backend info  | 
              1126 | 
                                  if ( !errors ) { | 
            
            
              | 892 | 
                                  setSource( [ state.backend, state.recordID ] );  | 
              1127 | 
                                      humanMsg.displayMsg( "<h3>" + _("Record saved to:</h3>") + "</h3>" + '<ul><li>' + targetNames.join('</li><li>') + '</li></ul>', { className: 'humanSuccess' } ); | 
            
            
               | 
               | 
              1128 | 
                                  }  | 
            
            
              | 1129 | 
               | 
            
            
              | 1130 | 
                                  $( '#save-record' ).find('i').attr( 'class', 'icon-hdd' ).end().find('span').text( _("Save") ); | 
            
        
          | 893 | 
                          }  | 
          1131 | 
                          }  | 
        
        
          | 894 | 
                      }  | 
          1132 | 
                      }  | 
        
        
          | 895 | 
           | 
          1133 | 
           | 
        
          
            
              | 896 | 
                          var backend = $( this ).data( 'backend' ) || ( state.saveBackend );  | 
              1134 | 
                          $.each( enabledTargets, function() { | 
            
            
              | 897 | 
                          if ( state.backend == backend ) { | 
              1135 | 
                              saveRecord( this.id, editor, finishCb, options );  | 
            
            
              | 898 | 
                              saveRecord( backend + '/' + state.recordID, editor, finishCb );  | 
              1136 | 
                          } );  | 
            
            
              | 899 | 
                          } else { | 
               | 
               | 
            
            
              | 900 | 
                              saveRecord( backend + '/', editor, finishCb );  | 
            
            
              | 901 | 
                          }  | 
            
        
          | 902 | 
           | 
          1137 | 
           | 
        
        
          | 903 | 
                      return false;  | 
          1138 | 
                      return false;  | 
        
        
          | 904 | 
                  } );  | 
          1139 | 
                  } );  | 
        
  
    | 
      
            Lines 1039-1049
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 1039 | 
                      }  | 
          1274 | 
                      }  | 
        
        
          | 1040 | 
                  } );  | 
          1275 | 
                  } );  | 
        
        
          | 1041 | 
           | 
          1276 | 
           | 
        
            
               | 
               | 
              1277 | 
                      $('#open-batches').click( function() { | 
            
            
              | 1278 | 
                          $('#batches-ui').modal(); | 
            
            
              | 1279 | 
               | 
            
            
              | 1280 | 
                          return false;  | 
            
            
              | 1281 | 
                      } );  | 
            
            
              | 1282 | 
               | 
            
            
              | 1283 | 
                      $('#create-batch').click( function() { | 
            
            
              | 1284 | 
                          var batch_name = prompt( _("Name of new import batch:") ); | 
            
            
              | 1285 | 
                          if (batch_name == null) return false;  | 
            
            
              | 1286 | 
               | 
            
            
              | 1287 | 
                          KohaBackend.CreateBatch( batch_name, function( data ) { | 
            
            
              | 1288 | 
                              if ( data.error ) { | 
            
            
              | 1289 | 
                                  humanMsg.displayAlert( _("Could not create import batch"), { className: 'humanError' } ); | 
            
            
              | 1290 | 
                              } else { | 
            
            
              | 1291 | 
                                  humanMsg.displayAlert( _("Import batch created"), { className: 'humanSuccess' } ); | 
            
            
              | 1292 | 
               | 
            
            
              | 1293 | 
                                  addImportBatch( editable_batches[data.batch_id] = { batch_id: data.batch_id, name: batch_name } ); | 
            
            
              | 1294 | 
               | 
            
            
              | 1295 | 
                                  var backend_id = 'batch:' + data.batch_id;  | 
            
            
              | 1296 | 
                                  addSaveTarget( { | 
            
            
              | 1297 | 
                                      label: backends[backend_id].saveLabel,  | 
            
            
              | 1298 | 
                                      id: backend_id + '/',  | 
            
            
              | 1299 | 
                                      description: '',  | 
            
            
              | 1300 | 
                                      enabled: false,  | 
            
            
              | 1301 | 
                                  } );  | 
            
            
              | 1302 | 
                              }  | 
            
            
              | 1303 | 
                          } );  | 
            
            
              | 1304 | 
               | 
            
            
              | 1305 | 
                          return false;  | 
            
            
              | 1306 | 
                      } );  | 
            
            
              | 1307 | 
               | 
            
            
              | 1308 | 
                      $('#manage-batches').click( function() { | 
            
            
              | 1309 | 
                          window.open('/cgi-bin/koha/tools/manage-marc-import.pl'); | 
            
            
              | 1310 | 
               | 
            
            
              | 1311 | 
                          return false;  | 
            
            
              | 1312 | 
                      } );  | 
            
            
              | 1313 | 
               | 
            
        
          | 1042 | 
                  // Key bindings  | 
          1314 | 
                  // Key bindings  | 
        
        
          | 1043 | 
                  bindGlobalKeys();  | 
          1315 | 
                  bindGlobalKeys();  | 
        
        
          | 1044 | 
           | 
          1316 | 
           | 
        
        
          | 1045 | 
                  // Setup UI  | 
          1317 | 
                  // Setup UI  | 
        
          
            
              | 1046 | 
                      $("#advanced-search-ui, #search-results-ui, #macro-ui").each( function() { | 
              1318 | 
                      $(".ui-modal").each( function() { | 
            
        
          | 1047 | 
                      $(this).modal({ show: false }); | 
          1319 | 
                      $(this).modal({ show: false }); | 
        
        
          | 1048 | 
                  } );  | 
          1320 | 
                  } );  | 
        
        
          | 1049 | 
           | 
          1321 | 
           | 
        
  
    | 
      
            Lines 1093-1098
          require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
      
      
        Link Here
      
     | 
  
        
          | 1093 | 
                          { return undefined; } | 
          1365 | 
                          { return undefined; } | 
        
        
          | 1094 | 
                  };  | 
          1366 | 
                  };  | 
        
        
          | 1095 | 
           | 
          1367 | 
           | 
        
            
               | 
               | 
              1368 | 
                      $.each( backends, function( name ) { | 
            
            
              | 1369 | 
                          if ( !this.save ) return; // Not a saving backend  | 
            
            
              | 1370 | 
               | 
            
            
              | 1371 | 
                          addSaveTarget( { | 
            
            
              | 1372 | 
                              label: this.saveLabel,  | 
            
            
              | 1373 | 
                              id: name + '/',  | 
            
            
              | 1374 | 
                              description: '',  | 
            
            
              | 1375 | 
                          } );  | 
            
            
              | 1376 | 
                      } );  | 
            
            
              | 1377 | 
               | 
            
        
          | 1096 | 
                  // Start editor  | 
          1378 | 
                  // Start editor  | 
        
        
          | 1097 | 
                  Preferences.Load( [% logged_in_user.borrowernumber || 0 | html %] );  | 
          1379 | 
                  Preferences.Load( [% logged_in_user.borrowernumber || 0 | html %] );  | 
        
        
          | 1098 | 
                  displayPreferences(editor);  | 
          1380 | 
                  displayPreferences(editor);  |