Serials: Caption/pattern wizard use enum fields for chronology when no enum
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 21 Jan 2013 19:54:55 +0000 (14:54 -0500)
committerDan Wells <dbw2@calvin.edu>
Tue, 29 Jan 2013 21:05:44 +0000 (16:05 -0500)
MFHD spec says that when there are no ‡a - ‡f enumeration captions, any
chronology captions should move back from their usual ‡i - ‡m places
back into enumeration space.

The predictions engine we already have deals with this better than with
the wrong patterns we were creating before, e.g.:

853 20 ‡81 ‡i(year) ‡j(month) ‡wm

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
Open-ILS/xul/staff_client/server/serial/pattern_wizard.js

index 68c58d3..6842562 100644 (file)
@@ -545,6 +545,13 @@ function ChronEditor() {
         }
     };
 
+    /* When a caption and pattern has no enumeration, the chronology
+     * fields should go into the enumeration fields. */
+    this._shift_to_enum = function(subfield) {
+        /* i -> a, j -> b, ... */
+        return String.fromCharCode(subfield.charCodeAt(0) - 8);
+    };
+
     this.remove_row = function(subfield) {
         if (this._test_removability(subfield)) {
             hard_empty(this.rows[subfield].element);
@@ -582,7 +589,7 @@ function ChronEditor() {
         (this.active ? show : hide)("chron_editor_here");
     };
 
-    this.compile = function() {
+    this.compile = function(enum_used) {
         if (!this.active) return [];
 
         return this.subfields.filter(
@@ -592,7 +599,12 @@ function ChronEditor() {
                 var caption = self.rows[subfield].fields.caption.value;
                 if (!self.rows[subfield].fields.display_in_holding.checked)
                     caption = "(" + caption + ")";
-                return result.concat([subfield, caption]);
+                return result.concat(
+                    [
+                        (enum_used ? subfield : self._shift_to_enum(subfield)),
+                        caption
+                    ]
+                );
             }, []
         );
     };
@@ -896,7 +908,7 @@ function Wizard() {
         ];
 
         code = code.concat(this.enum_editor.compile());
-        code = code.concat(this.chron_editor.compile());
+        code = code.concat(this.chron_editor.compile(this.enum_editor.active));
 
         code = code.concat("w", this.field_w.value);