small tweaks. making sure focus follows user as they page through
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 20 Feb 2006 18:09:33 +0000 (18:09 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Mon, 20 Feb 2006 18:09:33 +0000 (18:09 +0000)
started building the use save method

git-svn-id: svn://svn.open-ils.org/ILS/trunk@3133 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/xul/staff_client/server/patron/user_editor.js
Open-ILS/xul/staff_client/server/patron/user_editor.xml

index 93a6dce..f6f31d7 100644 (file)
@@ -18,14 +18,15 @@ var pages           = [
        'uedit_finalize',
        ];
 
+/* ID's of objects that should be focused when their page is made visible */
 var pageFocus  = [
        'ue_barcode',
        'ue_email1',
        'ue_addr_label',
-       'ue_barcode',
-       'ue_barcode',
-       'ue_barcode',
-       'ue_barcode'
+       'ue_profile',
+       'ue_stat_cat_selector_1',
+       'ue_survey_selector_1',
+       'ue_view_summary'
 ];
 
 /* fetch the necessary data to start off */
@@ -36,7 +37,7 @@ function uEditInit() {
        if(cgi.param('adv')) advanced = true 
        if(!session) throw "User session is not defined";
 
-       user = fetchUser(session);
+       fetchUser(session);
        $('uedit_user').appendChild(text(USER.usrname()));
        uEditShowPage('uedit_userid');
 
@@ -74,7 +75,7 @@ function uEditShowPage(id) {
        addCSSClass($(id+'_label'), 'label_active');
        var idx = _findPageIdx(id);
        var fpage = pageFocus[idx];
-       if(fpage) { $(fpage).focus(); $(fpage).select() }
+       if(fpage) { $(fpage).focus(); try{$(fpage).select()}catch(e){} }
 
        unHideMe($('ue_back'));
        unHideMe($('ue_fwd'));
@@ -129,12 +130,12 @@ function uEditDrawStatCats(r) {
 
        for( var c in cats ) {
                var row = templ.cloneNode(true);
-               uEditInsertCat( tbody, row, cats[c] );
+               uEditInsertCat( tbody, row, cats[c], c );
                tbody.appendChild(row);
        }
 }
 
-function uEditInsertCat( tbody, row, cat ) {
+function uEditInsertCat( tbody, row, cat, idx ) {
 
        cat.entries().sort(  /* sort the entries by value */
                function( a, b ) { 
@@ -145,6 +146,7 @@ function uEditInsertCat( tbody, row, cat ) {
        );
 
        var selector = $n(row, 'ue_stat_cat_selector');
+       if( idx == 0 ) selector.id = 'ue_stat_cat_selector_1'; 
        $n(row, 'ue_stat_cat_name').appendChild(text(cat.name()));
        $n(row, 'ue_stat_cat_owner').appendChild(text(fetchOrgUnit(cat.owner()).shortname()));
 
@@ -167,32 +169,32 @@ function uEditDrawSurveys(r) {
        var div = $('uedit_surveys');
        var table = div.removeChild($('ue_survey_table'));
 
+       var x = 0;
        for( var s in surveys ) {
                var survey = surveys[s];
                var clone = table.cloneNode(true);
-               uEditInsertSurvey( div, clone, survey );
+               uEditInsertSurvey( div, clone, survey, x++ );
                div.appendChild(clone);
        }
 }
 
-function uEditInsertSurvey( div, table, survey ) {
+function uEditInsertSurvey( div, table, survey, sidx ) {
        $n(table, 'ue_survey_name').appendChild(text(survey.name()));
        $n(table, 'ue_survey_desc').appendChild(text(survey.description()));
        var tbody = $n(table, 'ue_survey_tbody');
        var templ = tbody.removeChild($n(table, 'ue_survey_row'));
 
-       var selector    = $('ue_survey_answer');
        var polldiv             = $('ue_survey_answer_poll');
 
        var idx = 1;
        for( var q in survey.questions() ) {
                var row = templ.cloneNode(true);
-               uEditInsertSurveyQuestion( div, table, tbody, row, survey, survey.questions()[q] );
+               uEditInsertSurveyQuestion( div, table, tbody, row, survey, survey.questions()[q], sidx );
                tbody.appendChild(row);
        }
 }
 
-function uEditInsertSurveyQuestion( div, table, tbody, row, survey, question ) {
+function uEditInsertSurveyQuestion( div, table, tbody, row, survey, question, sidx ) {
 
        $n(row, 'ue_survey_question').appendChild(text(question.question()));
 
@@ -202,6 +204,8 @@ function uEditInsertSurveyQuestion( div, table, tbody, row, survey, question ) {
        var polltbody   = $n(row, 'ue_survey_answer_poll_tbody');
        var pollrow             = polltbody.removeChild($n(polltbody, 'ue_survey_answer_poll_row'));
 
+       if( sidx == 0 ) selector.id = 'ue_survey_selector_1'; 
+
        for( var a in question.answers() ) {
 
                var answer = question.answers()[a];
@@ -230,3 +234,21 @@ function uEditInsertSurveyQuestion( div, table, tbody, row, survey, question ) {
 }
 
 
+function uEditSaveUser() {
+
+       if(patron == null) patron = new au();
+
+       var barcode = $('ue_barcode').value;
+       patron.usrname($('ue_username').value); 
+       patron.passwd($('ue_password1').value); 
+       patron.first_given_name($('ue_firstname').value);
+       patron.second_given_name($('ue_middlename').value);
+       patron.family_name($('ue_lastname').value);
+       patron.suffix($('ue_suffix').value);
+       patron.dob($('ue_dob').value);
+
+       alert(js2JSON(patron));
+
+}
+
+
index a522e77..2faa1b9 100644 (file)
@@ -53,7 +53,7 @@
                        .uedit_table { width: 80% }
                        .address_table { 
                                -moz-border-radius: 4px;
-                               border: 3px solid #E0E0F0;
+                               border: 4px solid #E0E0F0;
                                padding: 4px;
                                }
                        .address_table td { 
                                                <!-- ************************************************************** -->
                                                <div id='uedit_stat_cats' class='main_div hide_me'>
                                                        <table class='uedit_table' style='width: 98%'>
-                                                               <thead><tr><td>Stat Cat Name</td><td>Owner</td><td>Value</td></tr></thead>
+                                                               <thead>
+                                                                       <tr style='font-weight: bold;'>
+                                                                               <td>Stat Cat Name</td>
+                                                                               <td>Owner</td>
+                                                                               <td>Value</td>
+                                                                       </tr>
+                                                               </thead>
                                                                <tbody id='ue_stat_cat_tbody'>
                                                                        <tr id='ue_stat_cat_row'>
-                                                                               <td><div class='wide right' style='font-weight: bold;' name='ue_stat_cat_name'/></td>
+                                                                               <td><div class='wide right' name='ue_stat_cat_name'/></td>
                                                                                <td><div class='wide right' style='font-size: 8pt' name='ue_stat_cat_owner'/></td>
                                                                                <td>
                                                                                        <div class='wide left'>
                                                                                                <select name='ue_stat_cat_selector'>
                                                                                                        <option> -- Select One -- </option>
                                                                                                </select>
-                                                                                               <span class='pad'> Or Enter a new value: </span>
+                                                                                               <span class='pad'> or </span>
                                                                                                <input class='pad' type='text' name='ue_stat_cat_newval'/>
                                                                                        </div>
                                                                                </td>
                                                <!-- Finish Up -->
                                                <!-- ************************************************************** -->
                                                <div id='uedit_finalize' class='main_div hide_me'>
+                                                       <div class='has_color' style='width: 95%; margin-top: 40px; text-align: center'>
+                                                               <div>
+                                                                       You are now ready to save the user to the database.  <br/>
+                                                                       To view or print a summary of the changes, click on the "View Summary" link.  <br/>
+                                                                       To save the user, click on the 'Save User' button.
+                                                               </div>
+                                                               <br/>
+                                                               <a style='margin-right: 30px;' id='ue_view_summary' 
+                                                                       href='javascript:uEditShowSummary();'>View Summary</a>
+                                                               <input style='margin-left: 30px;' type='submit' value='Save User' onclick='uEditSaveUser();'/>
+                                                       </div>
                                                </div>