got much of myopac wired up (usernama, password, email address change)
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Nov 2005 21:17:14 +0000 (21:17 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 15 Nov 2005 21:17:14 +0000 (21:17 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@2034 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/opac/common/js/config.js
Open-ILS/web/opac/common/js/opac_utils.js
Open-ILS/web/opac/common/js/utils.js
Open-ILS/web/opac/skin/default/css/layout.css
Open-ILS/web/opac/skin/default/js/myopac.js
Open-ILS/web/opac/skin/default/xml/myopac_checked.xml
Open-ILS/web/opac/skin/default/xml/myopac_summary.xml

index 15d8b30..0ffbf6f 100644 (file)
@@ -196,6 +196,10 @@ var FETCH_TRANSACTIONS                     = "open-ils.actor:open-ils.actor.user.transactions.have
 var FETCH_CROSSREF                             = "open-ils.search:open-ils.search.authority.crossref";
 var CREATE_HOLD                                        = "open-ils.circ:open-ils.circ.holds.create";
 var CANCEL_HOLD                                        = "open-ils.circ:open-ils.circ.hold.cancel";
+var UPDATE_USERNAME                            = "open-ils.actor:open-ils.actor.user.username.update";
+var UPDATE_PASSWORD                            = "open-ils.actor:open-ils.actor.user.password.update";
+var UPDATE_EMAIL                                       = "open-ils.actor:open-ils.actor.user.email.update";
+var RENEW_CIRC                                         = "open-ils.circ:open-ils.circ.renew";
 /* ---------------------------------------------------------------------------- */
 
 
index 1e81d04..b17a0c4 100644 (file)
@@ -253,6 +253,7 @@ function grabUser(ses, force) {
 
 }
 
+
 /* sets the 'prefs' field of the user object to their preferences 
        and returns the preferences */
 function grabUserPrefs(user, force) {
index 174b27d..c6d8e2d 100644 (file)
@@ -83,6 +83,11 @@ function removeChildren(dom) {
                dom.removeChild(dom.childNodes[0]);
 }
 
+function appendClear(node, child) {
+       removeChildren(node);
+       node.appendChild(child);
+}
+
 
 function instanceOf(object, constructorFunction) {
 
@@ -226,10 +231,8 @@ function findNodeByName(root, nodeName) {
 
        if(root.nodeType != 1) return null;
 
-       if(root.getAttribute("name") == nodeName ||
-                       root.name == nodeName ) {
+       if(root.getAttribute("name") == nodeName || root.name == nodeName ) 
                return root;
-       }
 
        var children = root.childNodes;
 
@@ -239,7 +242,6 @@ function findNodeByName(root, nodeName) {
        }
 
        return null;
-
 }
 
 
index c0f11d9..de00859 100644 (file)
@@ -156,3 +156,7 @@ border-left: 1px solid #E0E0E0; border-top: 1px solid #E0E0E0; border-bottom: 1p
 .tips { padding: 2px; text-align: center; border: solid #E0E0E0 3px; -moz-border-radius: 3px; width: 99%; }
 
 .holds_cell { border: 1px solid #E0E0E0; padding: 5px; width: 50%;}
+.myopac_update_cell { border: 3px solid #E0E0E0; width:100%; padding-top: 4px; padding-bottom: 4px;}
+.myopac_update_span { padding: 5px;}
+
+
index 30bceac..c458d4b 100644 (file)
@@ -92,6 +92,7 @@ function myOPACShowChecked() {
 
 
 var checkedRowTemplate;
+var circsCache = new Array();
 function myOPACDrawCheckedOut(r) {
 
 
@@ -129,12 +130,26 @@ function myOPACDrawCheckedOut(r) {
                dlink.appendChild(text(due));
                rlink.appendChild(text(circ.renewal_remaining()));
                unHideMe(row);
-               //rnlink /* set the renew action */
+               rnlink.setAttribute('href', 'javascript:myOPACRenewCirc("'+circ.id()+'");');
+               circsCache.push(circ);
 
                tbody.appendChild(row);
        }
 }
 
+function myOPACRenewCirc(circid) {
+       var circ;
+       for( var i = 0; i != circsCache.length; i++ ) 
+               if(circsCache[i].id() == circid)
+                       circ = circsCache[i];
+
+       alert('renewing ' + circ.id());
+       var req = new Request(RENEW_CIRC, G.user.session, circ );
+       req.send(true);
+       req.result();
+       alert($('myopac_renew_success').innerHTML);     
+}
+
 
 
 function myOPACShowHolds() {
@@ -324,27 +339,36 @@ function myOPACShowSummary() {
        req.send();
 }
 
+var addrRowTemplate;
 function _myOPACSummaryShowUer(r) {
 
        var user = r.getResultObject();
        fleshedUser = user;
 
-       $('myopac_summary_first').appendChild(text(user.first_given_name()));
-       $('myopac_summary_middle').appendChild(text(user.second_given_name()));
-       $('myopac_summary_dayphone').appendChild(text(user.day_phone()));
-       $('myopac_summary_eveningphone').appendChild(text(user.evening_phone()));
-       $('myopac_summary_otherphone').appendChild(text(user.other_phone()));
-       $('myopac_summary_last').appendChild(text(user.family_name()));
-       $('myopac_summary_username').appendChild(text(user.usrname()));
-       $('myopac_summary_email').appendChild(text(user.email()));
-       $('myopac_summary_barcode').appendChild(text(user.card().barcode()));
-       $('myopac_summary_ident1').appendChild(text(user.ident_value()));
-       $('myopac_summary_ident2').appendChild(text(user.ident_value2()));
-       $('myopac_summary_homelib').appendChild(text(findOrgUnit(user.home_ou()).name()));
-       $('myopac_summary_create_date').appendChild(text(user.create_date()));
+       appendClear($('myopac_summary_first'),text(user.first_given_name()));
+       appendClear($('myopac_summary_middle'),text(user.second_given_name()));
+       appendClear($('myopac_summary_dayphone'),text(user.day_phone()));
+       appendClear($('myopac_summary_eveningphone'),text(user.evening_phone()));
+       appendClear($('myopac_summary_otherphone'),text(user.other_phone()));
+       appendClear($('myopac_summary_last'),text(user.family_name()));
+       appendClear($('myopac_summary_username'),text(user.usrname()));
+       appendClear($('myopac_summary_email'),text(user.email()));
+       appendClear($('myopac_summary_barcode'),text(user.card().barcode()));
+       appendClear($('myopac_summary_ident1'),text(user.ident_value()));
+       appendClear($('myopac_summary_ident2'),text(user.ident_value2()));
+       appendClear($('myopac_summary_homelib'),text(findOrgUnit(user.home_ou()).name()));
+       appendClear($('myopac_summary_create_date'),text(user.create_date()));
 
        var tbody = $('myopac_addr_tbody');
-       var template = tbody.removeChild($('myopac_addr_row'));
+       var template;
+
+       if(addrRowTemplate) { 
+               template = addrRowTemplate;
+       } else {
+               template = tbody.removeChild($('myopac_addr_row'));
+               addrRowTemplate = template;
+       }
+
        for( var a in user.addresses() ) {
                var row = template.cloneNode(true);
                myOPACDrawAddr(row, user.addresses()[a]);
@@ -353,13 +377,80 @@ function _myOPACSummaryShowUer(r) {
 }
 
 function myOPACDrawAddr(row, addr) {
-       $n(row, 'myopac_addr_type').appendChild(text(addr.address_type()));
+
+       appendClear($n(row, 'myopac_addr_type'),text(addr.address_type()));
        var street = (addr.street2()) ? addr.street1() + ", " + addr.street2() : addr.street1();
-       $n(row, 'myopac_addr_street').appendChild(text(street));
-       $n(row, 'myopac_addr_city').appendChild(text(addr.city()));
-       $n(row, 'myopac_addr_county').appendChild(text(addr.county()));
-       $n(row, 'myopac_addr_state').appendChild(text(addr.state()));
-       $n(row, 'myopac_addr_zip').appendChild(text(addr.post_code()));
+       appendClear($n(row, 'myopac_addr_street'),text(street));
+       appendClear($n(row, 'myopac_addr_city'),text(addr.city()));
+       appendClear($n(row, 'myopac_addr_county'),text(addr.county()));
+       appendClear($n(row, 'myopac_addr_state'),text(addr.state()));
+       appendClear($n(row, 'myopac_addr_zip'),text(addr.post_code()));
+}
+
+
+function myOPACUpdateUsername() {
+       var username = $('myopac_new_username').value;
+       if(username == null || username == "") {
+               alert($('myopac_username_error').innerHTML);
+               return;
+       }
+       var req = new Request(UPDATE_USERNAME, G.user.session, username );
+       req.send(true);
+       if(req.result()) {
+               G.user.usrname(username);
+               hideMe($('myopac_update_username_row'));
+               userShown = false;
+               myOPACShowSummary();
+               return;
+       }
+
+       alert($('myopac_username_failure').innerHTML);
+}
+
+function myOPACUpdateEmail() {
+       var email = $('myopac_new_email').value;
+       if(email == null || email == "") {
+               alert($('myopac_email_error').innerHTML);
+               return;
+       }
+
+       var req = new Request(UPDATE_EMAIL, G.user.session, email );
+       req.send(true);
+       if(req.result()) {
+               G.user.usrname(email);
+               hideMe($('myopac_update_email_row'));
+               userShown = false;
+               myOPACShowSummary();
+               return;
+       }
+
+       alert($('myopac_email_failure').innerHTML);
+}
+
+
+function myOPACUpdatePassword() {
+       var curpassword = $('myopac_current_password').value;
+       var password = $('myopac_new_password').value;
+       var password2 = $('myopac_new_password2').value;
+
+       if(     curpassword == null || curpassword == "" || 
+                       password == null || password == "" || 
+                       password2 == null || password2 == "" || password != password2 ) {
+               alert($('myopac_password_error').innerHTML);
+               return;
+       }
+
+       var req = new Request(UPDATE_PASSWORD, G.user.session, password, curpassword );
+       req.send(true);
+       if(req.result()) {
+               G.user.usrname(password);
+               hideMe($('myopac_update_password_row'));
+               userShown = false;
+               myOPACShowSummary();
+               return;
+       }
+
+       alert($('myopac_password_failure').innerHTML);
 }
 
 
index f3a7340..55c6a28 100644 (file)
@@ -44,6 +44,7 @@
                </tbody>
        </table>
 
+       <div id='myopac_renew_success' class='hide_me'>Item successfully renewed</div>
 
 </div>
 
index 2587bfb..f77e149 100644 (file)
@@ -4,11 +4,11 @@
 
        <br/>
 
-       <table width='60%' class='light_border myopac_table'>
+       <table width='100%' class='light_border myopac_table'>
 
                <tbody id='myopac_summary_tbody'>
                        <tr>
-                               <td class='color_3 light_border'>First Name</td>
+                               <td class='color_3 light_border' width='20%'>First Name</td>
                                <td class='light_border' id='myopac_summary_first'> </td>
                        </tr>
                        <tr>
                                <td class='color_3 light_border'>Username</td>
                                <td class='light_border' id='myopac_summary_username'> </td>
                                <td class='light_border'><a href='javascript:void(0);' 
+                                       onclick='unHideMe($("myopac_update_username_row"));$("myopac_new_username").focus();'
                                        id='myopac_summary_username_change' style='text-decoration: underline;'>Change</a></td>
                        </tr>
+
+                       <tr id='myopac_update_username_row' class='hide_me'>
+                               <td class='myopac_update_cell' colspan='3'>
+                                       <span class='myopac_update_span'>Enter new username: </span>
+                                       <input type='text' size='24' id='myopac_new_username'
+                                               onkeydown='if(userPressedEnter(event)) myOPACUpdateUsername();'> </input>
+                                       <span class='myopac_update_span'>
+                                               <button onclick='myOPACUpdateUsername();'>Submit</button>
+                                       </span>
+                                       <span class='myopac_update_span'>
+                                               <button onclick='hideMe($("myopac_update_username_row"));'>Cancel</button>
+                                       </span>
+                               </td>
+                       </tr>
+
+
                        <tr>
                                <td class='color_3 light_border'>Password</td>
                                <td class='light_border' id='myopac_summary_password'>(not shown)</td>
                                <td class='light_border'><a href='javascript:void(0);' 
+                                       onclick='unHideMe($("myopac_update_password_row"));$("myopac_current_password").focus();'
                                        id='myopac_summary_password_change' style='text-decoration: underline;'>Change</a></td>
                        </tr>
+
+                       <tr id='myopac_update_password_row' class='hide_me'>
+                               <td class='myopac_update_cell' colspan='3'>
+
+                                       <table><tbody>
+                                               <tr>
+                                                       <td><span class='myopac_update_span'>Enter current password: </span></td>
+                                                       <td><input type='password' size='24' id='myopac_current_password'
+                                                               onkeydown='if(userPressedEnter(event)) myOPACUpdatePassword();'> </input></td>
+                                               </tr>
+                                               <tr>
+                                                       <td><span class='myopac_update_span'>Enter new password: </span></td>
+                                                       <td><input type='password' size='24' id='myopac_new_password'
+                                                               onkeydown='if(userPressedEnter(event)) myOPACUpdatePassword();'> </input></td>
+                                               </tr>
+                                               <tr>
+                                                       <td><span class='myopac_update_span'>Re-Enter new password: </span></td>
+                                                       <td><input type='password' size='24' id='myopac_new_password2'
+                                                               onkeydown='if(userPressedEnter(event)) myOPACUpdatePassword();'> </input></td>
+                                               </tr>
+                                       </tbody></table>
+
+                                       <span class='myopac_update_span'>
+                                               <button onclick='myOPACUpdatePassword();'>Submit</button>
+                                       </span>
+                                       <span class='myopac_update_span'>
+                                               <button onclick='hideMe($("myopac_update_password_row"));'>Cancel</button>
+                                       </span>
+                               </td>
+                       </tr>
+
                        <tr>
                                <td class='color_3 light_border'>Email Address</td>
                                <td class='light_border' id='myopac_summary_email'> </td>
-                               <td class='light_border'><a href='javascript:void(0);' id='myopac_summary_email_change' style='text-decoration: underline;'>Change</a></td>
+                               <td class='light_border'><a href='javascript:void(0);' 
+                                       onclick='unHideMe($("myopac_update_email_row"));$("myopac_new_email").focus();'
+                                       id='myopac_summary_email_change' style='text-decoration: underline;'>Change</a></td>
                        </tr>
+
+                       <tr id='myopac_update_email_row' class='hide_me'>
+                               <td class='myopac_update_cell' colspan='3'>
+                                       <span class='myopac_update_span'>Enter new email address: </span>
+                                       <input type='text' size='24' id='myopac_new_email'
+                                               onkeydown='if(userPressedEnter(event)) myOPACUpdateEmail();'> </input>
+                                       <span class='myopac_update_span'>
+                                               <button onclick='myOPACUpdateEmail();'>Submit</button>
+                                       </span>
+                                       <span class='myopac_update_span'>
+                                               <button onclick='hideMe($("myopac_update_email_row"));'>Cancel</button>
+                                       </span>
+                               </td>
+                       </tr>
+
                        <tr>
                                <td class='color_3 light_border'>Primary Identification</td>
                                <td class='light_border' id='myopac_summary_ident1'> </td>
                </tbody>
        </table>
 
-       <br/><br/><br/>
-
 
+       <br/><br/><br/>
        <table width='100%' class='light_border myopac_table'>
                <thead class='color_3'>
                        <tr><td style='background: none; border-bottom: none' align='center' colspan='7'><b>Addresses</b></td></tr>
                                <td name='myopac_addr_zip'> </td>
                        </tr>
                </tbody>
-
        </table>
+
+       <div class='hide_me' id='myopac_username_error'>Please enter a username</div>
+       <div class='hide_me' id='myopac_username_success'>Username successfully updated</div>
+       <div class='hide_me' id='myopac_username_failure'>Username update failed</div>
+
+       <div class='hide_me' id='myopac_email_error'>Please enter a valid email address</div>
+       <div class='hide_me' id='myopac_email_success'>Email address successfully updated</div>
+       <div class='hide_me' id='myopac_email_failure'>Email address update failed</div>
+
+       <div class='hide_me' id='myopac_password_error'>Passwords are empty or do not match</div>
+       <div class='hide_me' id='myopac_password_success'>Password successfully updated</div>
+       <div class='hide_me' id='myopac_password_failure'>Password update failed</div>
 </div>