From 52f13d946eaa663b6f7a94d69150347b2aa3408e Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Mon, 9 May 2011 15:13:41 -0400 Subject: [PATCH] Bug fixes; Add a method for setting fixed fields; Set the Type FF when rtype=AUT --- Open-ILS/web/js/dojo/MARC/FixedFields.js | 62 +++++++++++++++++++++++++++++--- Open-ILS/web/js/dojo/MARC/Record.js | 6 ++++ 2 files changed, 63 insertions(+), 5 deletions(-) diff --git a/Open-ILS/web/js/dojo/MARC/FixedFields.js b/Open-ILS/web/js/dojo/MARC/FixedFields.js index 9a92c30c4e..ae7527121b 100644 --- a/Open-ILS/web/js/dojo/MARC/FixedFields.js +++ b/Open-ILS/web/js/dojo/MARC/FixedFields.js @@ -1480,7 +1480,7 @@ if(!dojo._hasResource["MARC.FixedFields"]) { } MARC.Record.prototype.videorecordingFormatName = function () { - var _7 = this.field('007'); + var _7 = this.field('007').data; if (_7.match(/^v/)) { var _v_e = _7.substr( @@ -1495,7 +1495,7 @@ if(!dojo._hasResource["MARC.FixedFields"]) { } MARC.Record.prototype.videorecordingFormatCode = function () { - var _7 = this.field('007'); + var _7 = this.field('007').data; if (_7.match(/^v/)) { return _7.substr( @@ -1509,9 +1509,9 @@ if(!dojo._hasResource["MARC.FixedFields"]) { MARC.Record.prototype.extractFixedField = function (field, dflt) { - var _l = this.field('007'); - var _8 = this.field('008'); - var _6 = this.field('006'); + var _l = this.leader; + var _8 = this.field('008').data; + var _6 = this.field('006').data; var rtype = this.recordType(); @@ -1572,4 +1572,56 @@ if(!dojo._hasResource["MARC.FixedFields"]) { return val; } + + MARC.Record.prototype.setFixedField = function (field, value) { + + var _l = this.leader; + var _8 = this.field('008').data; + var _6 = this.field('006').data; + + var rtype = this.recordType(); + + var val; + + if (MARC.Record._ff_pos[field].ldr) { + if (MARC.Record._ff_pos[field].ldr[rtype]) { // It's in the leader + val = value.substr(0, MARC.Record._ff_pos[field].ldr[rtype].len); + this.leader = + _l.substring(0, MARC.Record._ff_pos[field].ldr[rtype].start) + + val + + _l.substring( + MARC.Record._ff_pos[field].ldr[rtype].start + + MARC.Record._ff_pos[field].ldr[rtype].len + ); + } + } else if (MARC.Record._ff_pos[field]._8) { + if (MARC.Record._ff_pos[field]._8[rtype]) { // Nope, it's in the 008 + val = value.substr(0, MARC.Record._ff_pos[field]._8[rtype].len); + this.field('008').update( + _8.substring(0, MARC.Record._ff_pos[field]._8[rtype].start) + + val + + _8.substring( + MARC.Record._ff_pos[field]._8[rtype].start + + MARC.Record._ff_pos[field]._8[rtype].len + ) + ); + } + } + + if (!val && MARC.Record._ff_pos[field]._6) { + if (MARC.Record._ff_pos[field]._6[rtype]) { // ok, maybe the 006? + val = value.substr(0, MARC.Record._ff_pos[field]._6[rtype].len); + this.field('006').update( + _6.substring(0, MARC.Record._ff_pos[field]._6[rtype].start) + + val + + _6.substring( + MARC.Record._ff_pos[field]._6[rtype].start + + MARC.Record._ff_pos[field]._6[rtype].len + ) + ); + } + } + + return val; + } } diff --git a/Open-ILS/web/js/dojo/MARC/Record.js b/Open-ILS/web/js/dojo/MARC/Record.js index 3aea14c3ae..8bb6a1b8cb 100644 --- a/Open-ILS/web/js/dojo/MARC/Record.js +++ b/Open-ILS/web/js/dojo/MARC/Record.js @@ -43,6 +43,12 @@ if(!dojo._hasResource["MARC.Record"]) { this.fromBreaker(kwargs.marcbreaker); if (this.onLoad) this.onLoad(); } + + if (kwargs.rtype == 'AUT') { + dojo.require('MARC.FixedFields'); + this.setFixedField('Type','z'); + } + }, title : function () { return this.subfield('245','a') }, -- 2.11.0