From d27b1018a96667c6fce8fc746e968e9a206858a0 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 24 Dec 2020 13:35:28 +0000 Subject: [PATCH] Bug 27308: Skip blank lines when inserting new MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The intent of the macro insert new function is to add a new field at the correct numerical place in the record. If you have a blank line while editing, however, the new line will be inserted at the blank line, rather than checking the rest of the record. To test: 1 - Create a macro like new 690=‡aLOCAL SUBJECT 2 - Insert a blank line into your record somewhere before where the 690 should be inserted 3 - Run the macro 4 - Line is inserted before the blank line 5 - Apply patch 6 - Reload (ensure cache is cleared and JS files are reloaded) 7 - Remove the previously created field, but leave the blank 8 - Run the macro 9 - Field is created at correct position Signed-off-by: Barbara Johnson Signed-off-by: Martin Renvoize Bug 27308: (QA follow-up) Remove commented line I don't think we need to keep the original line as a comment.. this patch simply cleans it up. Signed-off-by: Martin Renvoize Signed-off-by: Jonathan Druart (cherry picked from commit 3b0f86b53173d30da5dbb42710a7c9bf9edaa3bb) Signed-off-by: Fridolin Somers --- koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js index fb0bac5d98..6d90176e0a 100644 --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js +++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/marc-editor.js @@ -812,7 +812,8 @@ define( [ 'marc-record', 'koha-backend', 'preferences', 'text-marc', 'widget' ], createFieldOrdered: function( tag ) { var line, contents; - for ( line = 0; (contents = this.cm.getLine(line)); line++ ) { + for ( line = 0; line <= this.cm.lastLine(); line++ ) { + contents = this.cm.getLine(line); if ( contents && contents.substr(0, 3) > tag ) break; } -- 2.39.5