Bugzilla – Attachment 183301 Details for
Bug 40156
Advanced editor should not create empty fields and subfields
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40156: Advanced editor should not create empty fields and subfields
Bug-40156-Advanced-editor-should-not-create-empty-.patch (text/plain), 3.23 KB, created by
Janusz Kaczmarek
on 2025-06-17 10:45:57 UTC
(
hide
)
Description:
Bug 40156: Advanced editor should not create empty fields and subfields
Filename:
MIME Type:
Creator:
Janusz Kaczmarek
Created:
2025-06-17 10:45:57 UTC
Size:
3.23 KB
patch
obsolete
>From ecb1ccc315e1523cb440b59fd11a05005d34b523 Mon Sep 17 00:00:00 2001 >From: Janusz Kaczmarek <januszop@gmail.com> >Date: Tue, 17 Jun 2025 10:15:31 +0000 >Subject: [PATCH] Bug 40156: Advanced editor should not create empty fields and > subfields >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Currently, advanced bibliographic records editor creates empty >subfields (or even empty fields) when no content is placed after >â¡<code> (or, in case of control fields, after <tag>). > >Test plan: >========== >1. Enable EnableAdvancedCatalogingEditor (have StripWhitespaceChars > set to "Don't strip" - the default setting). >2. Open a record in the advanced editor, create empty subfield and > empty fields, e.g.: > >007 >500 _ _ â¡a >246 3 1 â¡aAdditional title :â¡b > >3. Save the record. Go to bibliographic record Normal view and in > modal "MARC preview" notice that the fields / subfields you entered as > empty exist in the record with no data. This is wrong. >4. Apply the patch ; restart_all. >5. Repeat p. 2 and 3. Note that empty fields/subfields have not been > created. > >Sponsored-by: Ignatianum University in Cracow >--- > .../lib/koha/cateditor/text-marc.js | 19 +++++++++++++------ > 1 file changed, 13 insertions(+), 6 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/text-marc.js b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/text-marc.js >index b7623de805..7f3950c11d 100644 >--- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/text-marc.js >+++ b/koha-tmpl/intranet-tmpl/lib/koha/cateditor/text-marc.js >@@ -58,9 +58,11 @@ define( [ 'marc-record' ], function( MARC ) { > tagNumber = tagNumber[1]; > > if ( tagNumber < '010' ) { >- var field = new MARC.Field( tagNumber, ' ', ' ', [ [ '@', line.substring( 4 ) ] ] ); >- field.sourceLine = i; >- record.addField( field ); >+ if (line.length > 4) { >+ var field = new MARC.Field(tagNumber, ' ', ' ', [['@', line.substring(4)]]); >+ field.sourceLine = i; >+ record.addField(field); >+ } > } else { > var indicators = line.match( /^... ([0-9A-Za-z_ ]) ([0-9A-Za-z_ ])/ ); > if ( !indicators ) { >@@ -86,12 +88,17 @@ define( [ 'marc-record' ], function( MARC ) { > > $.each( subfields, function( i, subfield ) { > var next = subfields[ i + 1 ]; >- >- field.addSubfield( [ subfield.code, line.substring( subfield.ch + 2, next ? next.ch : line.length ) ] ); >+ var subfield_start = subfield.ch + 2; >+ var subfield_end = (next ? next.ch : line.length); >+ if (subfield_end > subfield_start) { >+ field.addSubfield( [ subfield.code, line.substring( subfield_start, subfield_end ) ] ); >+ } > } ); > > field.sourceLine = i; >- record.addField( field ); >+ if (field.subfields().length) { >+ record.addField( field ); >+ } > } > } ); > >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40156
:
183301
|
183309