Stab wildly at a Dojo dialogue supporting basic password reset requests. With i18n...
authordbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Apr 2010 19:26:39 +0000 (19:26 +0000)
committerdbs <dbs@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Thu, 8 Apr 2010 19:26:39 +0000 (19:26 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_6@16175 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/dojo/openils/opac/nls/opac.js
Open-ILS/web/opac/skin/default/js/password_reset.js [new file with mode: 0644]
Open-ILS/web/opac/skin/default/xml/common/login.xml

index c197860..49454cc 100644 (file)
@@ -1,4 +1,16 @@
 {
+    "BARCODE_PROMPT": "Barcode: ",
+    "USERNAME_PROMPT": "User name: ",
+    "CANCEL_BUTTON_LABEL": "Cancel",
+    "SUBMIT_BUTTON_LABEL": "Submit",
+    "OK": "OK",
+    "PWD_RESET_RESPONSE_TITLE": "Password reset response",
+    "PWD_RESET_SUBMIT_SUCCESS": "Your request to begin the password reset process has been processed. If your account has a valid email address, you should soon receive an email containing further instructions for resetting your password.",
+    "PWD_RESET_SUBMIT_ERROR": "The system could not process your request for a password reset. Please try again, or contact circulation staff for assistance.",
+    "PWD_RESET_SUBMIT_STATUS": "Sending request...",
+    "PWD_RESET_FORGOT_PROMPT": "Forgot your password?",
+    "PWD_RESET_FORM_TITLE": "Request password reset",
+    "PWD_RESET_SUBMIT_PROMPT": "To begin the password reset process, enter either your barcode or user name in the following pwResetForm and click 'Submit'",
        "CREATE_MFHD": "Add MFHD Record",
        "CREATED_MFHD_RECORD": "Created MFHD record for ${0}",
        "DELETE_MFHD": "Delete Record",
diff --git a/Open-ILS/web/opac/skin/default/js/password_reset.js b/Open-ILS/web/opac/skin/default/js/password_reset.js
new file mode 100644 (file)
index 0000000..9628c4c
--- /dev/null
@@ -0,0 +1,104 @@
+dojo.require('dojo.parser');
+dojo.require('dijit.Dialog');
+dojo.require('dijit.form.Button');
+dojo.require('dijit.form.TextBox');
+
+dojo.requireLocalization("openils.opac", "opac");
+opac_strings = dojo.i18n.getLocalization("openils.opac", "opac");
+
+dojo.addOnLoad(function() {
+
+    // Create the password reset dialog
+    var pwResetFormDlg = createResetDialog();
+    dojo.parser.parse();
+
+    // Connect the buttons to submit / cancel events that override
+    // the default actions associated with the buttons to do
+    // pleasing Ajax things
+    dojo.connect(dijit.byId("cancelButton"), "onClick", function(event) {
+        event.preventDefault();
+        event.stopPropagation();
+        pwResetFormDlg.hide();
+    });
+    dojo.connect(dijit.byId("submitButton"), "onClick", function(event) {
+        event.preventDefault();
+        event.stopPropagation();
+        var xhrArgs = {
+            form: dojo.byId("requestReset"),
+            handleAs: "text",
+            load: function(data) {
+                pwResetFormDlg.hide();
+                passwordSubmission(opac_strings.PWD_RESET_SUBMIT_SUCCESS);
+            },
+            error: function(error) {
+                pwResetFormDlg.hide();
+                passwordSubmission(opac_strings.PWD_RESET_SUBMIT_ERROR);
+            }
+        }
+        var deferred = dojo.xhrPost(xhrArgs);
+        pwResetFormDlg.attr("content", opac_strings.PWD_RESET_SUBMIT_STATUS);
+    });
+    dojo.place("<tr><td colspan='2' align='center'><a class='classic_link' id='pwResetLink' onClick='dijit.byId(\"pwResetFormDlg\").show();'</a></td></tr>", "login_table_body");
+    dojo.query("#pwResetLink").attr("innerHTML", opac_strings.PWD_RESET_FORGOT_PROMPT);
+
+});
+
+function passwordSubmission( msg ) {
+    var responseDialog = new dijit.Dialog({
+        title: opac_strings.PWD_RESET_RESPONSE_TITLE
+    });
+    responseDialog.startup();
+    var requestStatusDiv = dojo.create("div", { style: "width: 30em" });
+    var requestStatusMsg = dojo.create("div", { innerHTML: msg }, requestStatusDiv);
+    var okButton = new dijit.form.Button({
+        id: "okButton",
+        type: "submit",
+        label: opac_strings.OK
+    }).placeAt(requestStatusDiv);
+    responseDialog.attr("content", requestStatusDiv);
+    responseDialog.show();
+    dojo.connect(dijit.byId("okButton"), "onClick", responseDialog, "hide");
+}
+
+function createResetDialog() {
+    var pwResetFormDlg = new dijit.Dialog({
+        id: "pwResetFormDlg",
+        title: opac_strings.PWD_RESET_FORM_TITLE
+    });
+    pwResetFormDlg.startup();
+
+    // Instantiate the form
+    var pwResetFormDiv = dojo.create("form", { id: "requestReset", style: "width: 30em", method: "post", action: "/opac/password/en-US" });
+    dojo.create("p", { innerHTML: opac_strings.PWD_RESET_SUBMIT_PROMPT }, pwResetFormDiv);
+    var pwResetFormTable = dojo.create("table", null, pwResetFormDiv);
+    var pwResetFormRow = dojo.create("tr", null, pwResetFormTable);
+    var pwResetFormCell = dojo.create("td", null, pwResetFormRow);
+    var pwResetFormLabel = dojo.create("label", null, pwResetFormCell);
+    dojo.attr(formCell, { innerHTML: opac_strings.BARCODE_PROMPT });
+    pwResetFormCell = dojo.create("td", null, pwResetFormRow);
+    var barcodeText = new dijit.form.TextBox({
+        name: "barcode"
+    }).placeAt(formCell);
+    pwResetFormRow = dojo.create("tr", {}, pwResetFormTable);
+    pwResetFormCell = dojo.create("td", {}, pwResetFormRow);
+    dojo.attr(formCell, { innerHTML: opac_strings.USERNAME_PROMPT });
+    pwResetFormCell = dojo.create("td", {}, pwResetFormRow);
+    var usernameText = new dijit.form.TextBox({
+        name: "username"
+    }).placeAt(formCell);
+    var submitButton = new dijit.form.Button({
+        id: "submitButton",
+        type: "submit",
+        label: opac_strings.SUBMIT_BUTTON_LABEL
+    }).placeAt(formDiv);
+    var cancelButton = new dijit.form.Button({
+        id: "cancelButton",
+        type: "cancel",
+        label: opac_strings.CANCEL_BUTTON_LABEL
+    }).placeAt(formDiv);
+
+    // Set the content of the Dialog to the pwResetForm
+    pwResetFormDlg.attr("content", pwResetFormDiv);
+    return pwResetFormDlg;
+}
+
index 8172089..9501d36 100644 (file)
@@ -11,6 +11,7 @@
                config.ids.login.cancel         = "login_cancel_button";
                config.ids.altcanvas.login                      = config.ids.login.box;
        </script>
+       <script type='text/javascript' src='<!--#echo var="OILS_OPAC_JS_HOST"-->/skin/default/js/password-reset.js'></script>
 
        <br/>
 
@@ -21,7 +22,7 @@
        <br/>
 
        <table id='login_table' class='data_grid' style='margin-left: 20px;' width='95%'>
-               <tbody>
+               <tbody id='login_tbody'>
                        <tr>
                                <td><span class='login_text'>&login.username;</span></td>
                                <td>