plugged in surveys
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 17 Feb 2009 04:10:06 +0000 (04:10 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 17 Feb 2009 04:10:06 +0000 (04:10 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@12196 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/web/js/ui/default/actor/user/register.js
Open-ILS/web/templates/default/actor/user/register.tt2

index a401329..de61863 100644 (file)
@@ -44,6 +44,7 @@ function load() {
 
 function loadTable() {
     var tbody = dojo.byId('uedit-tbody');
+
     for(var idx = 0; tbody.childNodes[idx]; idx++) {
         var row = tbody.childNodes[idx];
         if(row.nodeType != row.ELEMENT_NODE) continue;
@@ -52,13 +53,15 @@ function loadTable() {
         fleshFMRow(row, fmcls);
     }
 
-    statCatTemplate = tbody.removeChild(dojo.byId('stat-cat-row-0'));
+    statCatTemplate = tbody.removeChild(dojo.byId('stat-cat-row-template'));
+    surveyTemplate = tbody.removeChild(dojo.byId('survey-row-template'));
+    surveyQuestionTemplate = tbody.removeChild(dojo.byId('survey-question-row-template'));
 
     for(var idx in statCats) {
         var stat = statCats[idx];
         var row = statCatTemplate.cloneNode(true);
         row.id = 'stat-cat-row-' + idx;
-        tbody.insertBefore(row, dojo.byId('survey-cat-divider'));
+        tbody.appendChild(row);
         dojo.query('[name=name]', row)[0].innerHTML = stat.name();
         var valtd = dojo.query('[name=widget]', row)[0];
         var span = valtd.appendChild(document.createElement('span'));
@@ -68,6 +71,27 @@ function loadTable() {
         comboBox.labelAttr = 'value';
         comboBox.searchAttr = 'value';
     }
+
+    for(var idx in surveys) {
+        var survey = surveys[idx];
+        var srow = surveyTemplate.cloneNode(true);
+        tbody.appendChild(srow);
+        dojo.query('[name=name]', srow)[0].innerHTML = survey.name();
+
+        for(var q in survey.questions()) {
+            var quest = survey.questions()[q];
+            var qrow = surveyQuestionTemplate.cloneNode(true);
+            tbody.appendChild(qrow);
+            dojo.query('[name=question]', qrow)[0].innerHTML = quest.question();
+
+            var span = dojo.query('[name=answers]', qrow)[0].appendChild(document.createElement('span'));
+            var store = new dojo.data.ItemFileReadStore(
+                {data:fieldmapper.asva.toStoreData(quest.answers())});
+            var select = new dijit.form.FilteringSelect({store:store}, span);
+            select.labelAttr = 'answer';
+            select.searchAttr = 'answer';
+        }
+    }
 }
 
 
index f4bdb86..6f5f6be 100644 (file)
         <tr fmclass='aua' fmfield='country'/>
         <tr fmclass='aua' fmfield='valid'/>
         <tr fmclass='aua' fmfield='within_city_limits'/>
+
         <tr><td class='uedit-help'><td>Billing Address</td>
             <td><div dojoType='dijit.form.CheckBox' name='billing-addr-widget'></div></td>
         </tr>
         <tr><td class='uedit-help'><td>Mailing Address</td>
             <td><div dojoType='dijit.form.CheckBox' name='billing-addr-widget'></div></td>
         </tr>
+
         <tr class='divider' id='stat-cat-divider'><td colspan='10'>Statistical Categories</td></tr>
-        <tr id='stat-cat-row-0'><td class='uedit-help'/><td name='name'/><td name='widget'/></tr>
-        <tr class='divider' id='survey-cat-divider'><td colspan='10'>Surveys</td></tr>
+        <tr id='stat-cat-row-template'><td class='uedit-help'/><td name='name'/><td name='widget'/></tr>
+
+        <tr id='survey-row-template' class='divider'><td colspan='10' name='name'/></tr>
+        <tr id='survey-question-row-template'><td class='uedit-help'/><td name='question'/><td name='answers'/></tr>
     </tbody>
 </table>
 [% END %]