JBAS-1132 Card style stat cat; delivery method field
authorBill Erickson <berickxx@gmail.com>
Thu, 17 Mar 2016 21:10:07 +0000 (17:10 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 21 Mar 2019 19:46:23 +0000 (15:46 -0400)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/openils/var/templates_kcls/opac/register.tt2
KCLS/sql/schema/deploy/patron-self-reg-mods.sql
KCLS/sql/schema/revert/patron-self-reg-mods.sql
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Register.pm
Open-ILS/web/js/ui/default/opac/register.js

index 8123e73..9707025 100644 (file)
@@ -17,9 +17,9 @@ card_url = 'https://www.kcls.org/images/library/cards/Card_';
 wallet_cards = ['12man', 'blank', 'books', 'mirror'];
 keychain_cards = ['keychain'];
 
-MACRO input_field(fclass, fname, label, type, css_class) BLOCK;
+MACRO input_field(fclass, fname, label, type, css_class, value) BLOCK;
   field_path = fclass _ "." _ fname; 
-  value = ctx.register.values.$fclass.$fname;
+  value = ctx.register.values.$fclass.$fname || value;
   type = type || 'text';
   css_class = css_class || '';
 %]
@@ -162,7 +162,7 @@ END; # input_field()
             <div><img class="card-img" src="[% card_url _ ctype _ '.jpg' %]"/></div>
             <div class="card-style-option">
               <input [% IF loop.first %]id='first-wallet-card'[% END %]
-                type="radio" name="stgu.card_style" value="[% ctype %]"/>
+                type="radio" name="stgsc.10" value="[% ctype %]"/>
             </div>
           </div>
           [% END %]
@@ -177,7 +177,7 @@ END; # input_field()
             <div><img class="card-img" src="[% card_url _ ctype _ '.jpg' %]"/></div>
             <div class="card-style-option">
               <input [% IF loop.first %]id='first-keychain-card'[% END %]
-                type="radio" name="stgu.card_style" value="[% ctype %]"/>
+                type="radio" name="stgsc.10" value="[% ctype %]"/>
             </div>
           </div>
           [% END %]
@@ -185,6 +185,24 @@ END; # input_field()
         <div class="grid-clear"></div>
       </li>
 
+      <li>
+        <label>Choose delivery method of your new library card:</label>
+        <div>
+          <ul>
+            <li>
+              <input type='radio' name='stgu.delivery_method' 
+                value='Mail' checked='checked'/>
+              <label>Mail to me.</label>
+            </li>
+            <li>
+              <input type='radio' name='stgu.delivery_method' 
+                value='Pick up'/>
+              <label>I will pick up at my home library</label>
+            </li>
+          </ul>
+        </div>
+      </li>
+
       <li><h2>Your Information</h2></li>
       <hr/>
 
index ecb4415..80b9ce4 100644 (file)
@@ -6,23 +6,23 @@ BEGIN;
 -- parent/guardian
 ALTER TABLE staging.user_stage 
     ADD COLUMN ident_value2 TEXT,
-    ADD COLUMN card_style TEXT;
-
-INSERT INTO config.org_unit_setting_type
-    (grp, name, datatype, fm_class, label, description)        
-VALUES (
-    'circ', 
-    'opac.self_register.profile', 
-    'link', 'pgt',
-    'Patron Self-Reg. Default Profile', 
-    'Permission group/profile used for self-register patrons'
-);
+    ADD COLUMN delivery_method TEXT;
 
 -- Insert data if needed
 DO $$
 BEGIN
     IF evergreen.insert_on_deploy() THEN
 
+        INSERT INTO config.org_unit_setting_type
+            (grp, name, datatype, fm_class, label, description)        
+        VALUES (
+            'circ', 
+            'opac.self_register.profile', 
+            'link', 'pgt',
+            'Patron Self-Reg. Default Profile', 
+            'Permission group/profile used for self-register patrons'
+        );
+
         -- Online Registration
         INSERT INTO actor.org_unit_setting (org_unit, name, value) 
             VALUES (1, 'opac.self_register.profile', '26');
@@ -33,6 +33,13 @@ BEGIN
 
         INSERT INTO actor.org_unit_setting (org_unit, name, value) 
             VALUES (1, 'ui.patron.edit.au.ident_value2.show', 'true');
+
+        INSERT INTO actor.stat_cat (id, owner, name)
+            VALUES (10, 1, 'Card Design (online)');
+
+        -- need to retain the ID since it's referenced in the code.
+        PERFORM SETVAL('biblio.peer_type_id_seq'::TEXT, 11);
+
     END IF;
 
 END $$;
index 086c895..e9354f0 100644 (file)
@@ -2,6 +2,12 @@
 
 BEGIN;
 
+DELETE FROM actor.stat_cat_entry_usr_map WHERE stat_cat = 10;
+DELETE FROM actor.stat_cat WHERE id = 10;
+
+-- need to retain the ID since it's referenced in the code.
+SELECT SETVAL('biblio.peer_type_id_seq'::TEXT, 10);
+
 DELETE FROM actor.org_unit_setting 
     WHERE name = 'opac.self_register.profile';
 
@@ -25,6 +31,6 @@ DELETE FROM config.org_unit_setting_type
 
 ALTER TABLE staging.user_stage 
     DROP COLUMN ident_value2,
-    DROP COLUMN card_style;
+    DROP COLUMN delivery_method;
 
 COMMIT;
index 5680003..cf74ce6 100644 (file)
@@ -10713,7 +10713,7 @@ SELECT  usr,
                                                <field reporter:label="Preferred Middle Name" name="pref_second_given_name" reporter:datatype="text"/>
                                                <field reporter:label="Preferred Last Name" name="pref_family_name"  reporter:datatype="text"/>
             <field reporter:label="Parent/Guardian" name="ident_value2" reporter:datatype="text"/>
-            <field reporter:label="Card Style" name="card_style" reporter:datatype="text"/>
+            <field reporter:label="Delivery" name="delivery_method" reporter:datatype="text"/>
         </fields>
         <links>
             <link field="requesting_usr" reltype="has_a" key="id" map="" class="au"/>
index 90cab58..1638bce 100644 (file)
@@ -292,6 +292,13 @@ sub handle_stat_cats {
         push(@$stat_cats, $stat_cat);
     }
 
+    if (my $card_style = $cgi->param('stgsc.10')) {
+        my $stat_cat = Fieldmapper::staging::statcat_stage->new;
+        $stat_cat->statcat(10);
+        $stat_cat->value($card_style);
+        push(@$stat_cats, $stat_cat);
+    }
+
     # Events mailing
     $stat_cat = Fieldmapper::staging::statcat_stage->new;
     $stat_cat->statcat(3);
index 4fe22a6..b9fdf1f 100644 (file)
@@ -5,14 +5,14 @@
 var invalid_fields = {};
 var is_juvenile = false;
 var required_fields = [
-    'stgu.card_style',
+    'stgsc.10',
     'stgu.first_given_name',
     'stgu.family_name',
     'stgu.dob',
     'stgba.street1',
     'stgba.city',
     'stgba.state',
-    'stgba.post_code',
+    'stgba.post_code'
 ];
 
 var last_activity = new Date();
@@ -108,26 +108,6 @@ function validate(dom_id) {
 
             break;
 
-        case 'stgu.card_style': 
-            // be sure the user has selected a card style.
-            // In this case dom_id is really a radio selector name.
-            var styles = document.getElementsByName(dom_id);
-            var checked = false;
-            for (var i = 0; i < styles.length; i++) {
-                if (styles[i].checked) {
-                    checked = true;
-                    break;
-                }
-            }
-
-            if (checked) {
-                valid = false;
-                delete invalid_fields[dom_id];
-            } else {
-                invalid_fields[dom_id] = "Please select a card style."
-            }
-            break;
-
         case 'stgba.street1':
             if (value) {
                 delete invalid_fields[dom_id];
@@ -151,6 +131,27 @@ function validate(dom_id) {
                 invalid_fields[dom_id] = "Please enter an address zip/post code";
             }
             break;
+
+          case 'stgsc.10':
+            // stgsc.10 == card type stat cat.  Its values are represented
+            // across multiple values.  Make sure at least one is selected.
+            var found = false;
+            var inputs = document.getElementsByTagName('input');
+            for (var i = 0; i < inputs.length; i++) {
+                var ipt = inputs[i];
+                var name = ipt.getAttribute('name');
+                if (name == 'stgsc.10' && ipt.checked) {
+                    found = true;
+                    break;
+                }
+            }
+
+            if (found) {
+                delete invalid_fields[dom_id];
+            } else {
+                invalid_fields[dom_id] = "Please select a card style."
+            }
+            break;
     }
 
     if (element) {