Bug 16232: Fix edit as new in Rancor
[koha-equinox.git] / koha-tmpl / intranet-tmpl / prog / en / includes / cateditor-ui.inc
index 501dd0d..db6dc66 100644 (file)
@@ -234,6 +234,21 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
                 callback( record );
             },
         },
+        'duplicate': {
+            titleForRecord: _("Editing duplicate record of #{ID}"),
+            get: function( id, callback ) {
+                if ( !id ) return false;
+
+                KohaBackend.GetRecord( id, callback );
+            },
+            save: function( id, record, done ) {
+                function finishCb( data ) {
+                    done( { error: data.error, newRecord: data.marcxml && data.marcxml[0], newId: data.biblionumber && [ 'catalog', data.biblionumber ] } );
+                }
+
+                KohaBackend.CreateRecord( record, finishCb );
+            }
+        },
         'catalog': {
             titleForRecord: _("Editing catalog record #{ID}"),
             links: [
@@ -259,7 +274,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
             }
         },
         'iso2709': {
-            saveLabel: _("Save as ISO2709 (.mrc) file"),
+            saveLabel: _("Save as MARC (.mrc) file"),
             save: function( id, record, done ) {
                 saveAs( new Blob( [record.toISO2709()], { 'type': 'application/octet-stream;charset=utf-8' } ), 'record.mrc' );
 
@@ -785,7 +800,7 @@ require( [ 'koha-backend', 'search', 'macros', 'marc-editor', 'marc-record', 'pr
             if ( resizeTimer == null ) resizeTimer = setTimeout( function() {
                 resizeTimer = null;
 
-                var pos = $('#editor .CodeMirror').position();
+                var pos = $('#editor .CodeMirror').offset();
                 $('#editor .CodeMirror').height( $(window).height() - pos.top - 24 - $('#changelanguage').height() ); // 24 is hardcoded value but works well
 
                 $('.modal-body').each( function() {