ui.patron.registration.require_address org unit setting and associated behavior for...
authorphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 10 Sep 2010 18:17:20 +0000 (18:17 +0000)
committerphasefx <phasefx@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 10 Sep 2010 18:17:20 +0000 (18:17 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@17582 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/002.schema.config.sql
Open-ILS/src/sql/Pg/950.data.seed-values.sql
Open-ILS/src/sql/Pg/upgrade/0392.data.org-setting-ui.patron.editor_address_requirement.sql [new file with mode: 0644]
Open-ILS/web/js/dojo/openils/actor/nls/register.js
Open-ILS/web/js/ui/default/actor/user/register.js

index ed21364..5c2e085 100644 (file)
@@ -68,7 +68,7 @@ CREATE TABLE config.upgrade_log (
     install_date    TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW()
 );
 
-INSERT INTO config.upgrade_log (version) VALUES ('0391'); -- miker
+INSERT INTO config.upgrade_log (version) VALUES ('0392'); -- phasefx
 
 CREATE TABLE config.bib_source (
        id              SERIAL  PRIMARY KEY,
index 78667c5..ad92ab0 100644 (file)
@@ -6916,4 +6916,20 @@ INSERT INTO config.org_unit_setting_type ( name, label, description, datatype )
         'string'
 );
 
+-- 0392.data.org-setting-ui.patron.editor_address_requirement.sql
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
+        'ui.patron.registration.require_address',
+        oils_i18n_gettext(
+            'ui.patron.registration.require_address',
+            'GUI: Require at least one address for Patron Registration', 
+            'coust', 
+            'label'),
+        oils_i18n_gettext(
+            'ui.patron.registration.require_address',
+            'Enforces a requirement for having at least one address for a patron during registration.',
+            'coust', 
+            'description'),
+        'bool'
+);
 
diff --git a/Open-ILS/src/sql/Pg/upgrade/0392.data.org-setting-ui.patron.editor_address_requirement.sql b/Open-ILS/src/sql/Pg/upgrade/0392.data.org-setting-ui.patron.editor_address_requirement.sql
new file mode 100644 (file)
index 0000000..0b916e8
--- /dev/null
@@ -0,0 +1,20 @@
+BEGIN;
+
+INSERT INTO config.upgrade_log (version) VALUES ('0392'); -- phasefx
+
+INSERT INTO config.org_unit_setting_type ( name, label, description, datatype ) VALUES (
+        'ui.patron.registration.require_address',
+        oils_i18n_gettext(
+            'ui.patron.registration.require_address',
+            'GUI: Require at least one address for Patron Registration', 
+            'coust', 
+            'label'),
+        oils_i18n_gettext(
+            'ui.patron.registration.require_address',
+            'Enforces a requirement for having at least one address for a patron during registration.',
+            'coust', 
+            'description'),
+        'bool'
+);
+
+COMMIT;
index dabee10..6e0f8af 100644 (file)
@@ -1,4 +1,6 @@
 {
+    "DELETE_ADDRESS" : "Delete address ${0}?",
+    "NEED_ADDRESS" : "An address is required during registration.",
     "DUPE_PATRON_NAME" : "Found ${0} patron(s) with the same name",
     "DUPE_PATRON_EMAIL" : "Found ${0} patron(s) with the same email address",
     "DUPE_PATRON_IDENT" : "Found ${0} patron(s) with the same identification",
index b1aea17..cff9071 100644 (file)
@@ -84,6 +84,7 @@ function load() {
         'ui.patron.default_inet_access_level',
         'ui.patron.default_ident_type',
         'ui.patron.default_country',
+        'ui.patron.registration.require_address',
         'circ.holds.behind_desk_pickup_supported',
         'circ.patron_edit.clone.copy_address'
     ]);
@@ -1348,8 +1349,14 @@ function uEditApproveAddress(addr) {
 
 
 function uEditDeleteAddr(id, noAlert) {
+    if (patron.isnew() && orgSettings['ui.patron.registration.require_address']) {
+        if (dojo.query('tr[name=uedit-addr-divider]').length < 2) {
+            alert(localeStrings.NEED_ADDRESS);
+            return;
+        }
+    }
     if(!noAlert) {
-        if(!confirm('Delete address ' + id)) return; /* XXX i18n */
+        if(!confirm(dojo.string.substitute(localeStrings.DELETE_ADDRESS, [id]))) return;
     }
     var addr = patron.addresses().filter(function(i){return (i.id() == id)})[0];
     if (addr) { addr.isdeleted(1); }