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();
* single subfield, '@'.
*/
-require( [ 'widget' ], function( Widget ) {
+require( [ 'koha-backend', 'widget', 'text-marc' ], function( KohaBackend, Widget, TextMarc ) {
Widget.Register( '000@', {
makeTemplate: function() {
return ' nam a22 7a 4500';
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' );
}