@@ -, +, @@ --- .../intranet-tmpl/lib/koha/cateditor/widget.js | 7 ++++++ .../prog/en/includes/cateditor-widgets-marc21.inc | 26 +++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) --- a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/widget.js +++ a/koha-tmpl/intranet-tmpl/lib/koha/cateditor/widget.js @@ -121,6 +121,13 @@ define( [ 'resources' ], function( Resources ) { materialInfo[ $(this).attr('id') ] = this; } ); + if (widget.getMaterial) { + const material = widget.getMaterial(); + if (material) { + $matSelect.val(material); + } + } + $matSelect.change( function() { widget.loadXMLMaterial( materialInfo[ $matSelect.val() ] ); widget.nodeChanged(); --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-widgets-marc21.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/cateditor-widgets-marc21.inc @@ -85,7 +85,7 @@ * single subfield, '@'. */ -require( [ 'koha-backend', 'widget' ], function( KohaBackend, Widget ) { +require( [ 'koha-backend', 'widget', 'text-marc' ], function( KohaBackend, Widget, TextMarc ) { Widget.Register( '000@', { makeTemplate: function() { return ' nam a22 7a 4500'; @@ -237,6 +237,30 @@ require( [ 'koha-backend', 'widget' ], function( KohaBackend, Widget ) { return $result[0]; }, + materialTypeMapping: { + a: { + a: 'BKS', c: 'BKS', d: 'BKS', m: 'BKS', + b: 'CR', i: 'CR', s: 'CR', + }, + t: 'BKS', + c: 'MU', d: 'MU', i: 'MU', j: 'MU', + e: 'MP', f: 'MP', + g: 'VM', k: 'VM', o: 'VM', r: 'VM', + m: 'CF', + p: 'MX', + }, + getMaterial: function () { + const record = TextMarc.TextToRecord(this.editor.cm.getValue()); + const leader = record.leader(); + const leader6 = leader.substring(6, 7); + let materialType = this.materialTypeMapping[leader6]; + if (typeof materialType === 'object') { + const leader7 = leader.substring(7, 8); + materialType = materialType[leader7]; + } + + return materialType; + }, postCreate: function( node, mark ) { this.createFromXML( 'marc21/xml/008' ); } --