[open-ils-commits] r12194 - in trunk/Open-ILS/web: js/ui/default/actor/user templates/default/actor/user (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 16 21:30:47 EST 2009
Author: erickson
Date: 2009-02-16 21:30:46 -0500 (Mon, 16 Feb 2009)
New Revision: 12194
Modified:
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
trunk/Open-ILS/web/templates/default/actor/user/register.tt2
Log:
initial plugin of staff-cats
Modified: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-02-16 22:00:06 UTC (rev 12193)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-02-17 02:30:46 UTC (rev 12194)
@@ -1,6 +1,7 @@
dojo.require('dojo.data.ItemFileReadStore');
dojo.require('dijit.form.Textarea');
dojo.require('dijit.form.FilteringSelect');
+dojo.require('dijit.form.ComboBox');
dojo.require('fieldmapper.IDL');
dojo.require('openils.PermaCrud');
dojo.require('openils.widget.AutoGrid');
@@ -10,81 +11,101 @@
var pcrud;
var fmClasses = ['au', 'ac', 'aua', 'actsc', 'asv', 'asvq', 'asva'];
var fieldDoc = {};
+var statCats;
+var surveys;
+var staff;
function load() {
+ staff = new openils.User().user;
pcrud = new openils.PermaCrud();
- pcrud.search('fdoc',
- {fm_class:fmClasses},
- {
- oncomplete : function(r) {
- var list = openils.Util.readResponse(r, null, true);
- for(var i in list) {
- var doc = list[i];
- if(!fieldDoc[doc.fm_class()])
- fieldDoc[doc.fm_class()] = {};
- fieldDoc[doc.fm_class()][doc.field()] = doc;
- }
- loadTable();
- }
- }
+
+ var list = pcrud.search('fdoc', {fm_class:fmClasses});
+ for(var i in list) {
+ var doc = list[i];
+ if(!fieldDoc[doc.fm_class()])
+ fieldDoc[doc.fm_class()] = {};
+ fieldDoc[doc.fm_class()][doc.field()] = doc;
+ }
+
+ statCats = fieldmapper.standardRequest(
+ ['open-ils.circ', 'open-ils.circ.stat_cat.actor.retrieve.all'],
+ {params : [openils.User.authtoken, staff.ws_ou()]}
);
+
+ surveys = fieldmapper.standardRequest(
+ ['open-ils.circ', 'open-ils.circ.survey.retrieve.all'],
+ {params : [openils.User.authtoken]}
+ );
+
+ loadTable();
}
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;
var fmcls = row.getAttribute('fmclass');
if(!fmcls) continue;
+ fleshFMRow(row, fmcls);
+ }
- var fmfield = row.getAttribute('fmfield');
- var wclass = row.getAttribute('wclass');
- var wstyle = row.getAttribute('wstyle');
- var fieldIdl = fieldmapper.IDL.fmclasses[fmcls].field_map[fmfield];
+ for(var idx in statCats) {
+ var stat = statCats[idx];
+ var row = dojo.byId('stat-cat-row-' + idx);
+ if(!row) row = dojo.byId('stat-cat-row-0').cloneNode(true);
+ row.id = 'stat-cat-row-' + idx;
+ dojo.query('[name=name]', row)[0].innerHTML = stat.name();
+ var valtd = dojo.query('[name=widget]', row)[0];
+ var span = valtd.appendChild(document.createElement('span'));
+ new dijit.form.ComboBox({}, span);
+ tbody.insertBefore(row, dojo.byId('survey-cat-divider'));
+ }
+}
- if(!fieldIdl)
- console.log("failed loading " + fmcls + ' : ' + fmfield);
- var existing = dojo.query('td', row);
- var htd = existing[0] || row.appendChild(document.createElement('td'));
- var ltd = existing[1] || row.appendChild(document.createElement('td'));
- var wtd = existing[2] || row.appendChild(document.createElement('td'));
+function fleshFMRow(row, fmcls) {
+ var fmfield = row.getAttribute('fmfield');
+ var wclass = row.getAttribute('wclass');
+ var wstyle = row.getAttribute('wstyle');
+ var fieldIdl = fieldmapper.IDL.fmclasses[fmcls].field_map[fmfield];
- openils.Util.addCSSClass(htd, 'uedit-help');
- if(fieldDoc[fmcls] && fieldDoc[fmcls][fmfield]) {
- var link = dojo.byId('uedit-help-template').cloneNode(true);
- link.id = '';
- link.setAttribute('href', 'javascript:ueLoadContextHelp("'+fmcls+'","'+fmfield+'")');
- openils.Util.removeCSSClass(link, 'hidden');
- htd.appendChild(link);
- console.log(link.href);
- }
+ var existing = dojo.query('td', row);
+ var htd = existing[0] || row.appendChild(document.createElement('td'));
+ var ltd = existing[1] || row.appendChild(document.createElement('td'));
+ var wtd = existing[2] || row.appendChild(document.createElement('td'));
- if(!ltd.textContent) {
- var span = document.createElement('span');
- ltd.appendChild(document.createTextNode(fieldIdl.label));
- }
+ openils.Util.addCSSClass(htd, 'uedit-help');
+ if(fieldDoc[fmcls] && fieldDoc[fmcls][fmfield]) {
+ var link = dojo.byId('uedit-help-template').cloneNode(true);
+ link.id = '';
+ link.setAttribute('href', 'javascript:ueLoadContextHelp("'+fmcls+'","'+fmfield+'")');
+ openils.Util.removeCSSClass(link, 'hidden');
+ htd.appendChild(link);
+ }
- span = document.createElement('span');
- wtd.appendChild(span);
+ if(!ltd.textContent) {
+ var span = document.createElement('span');
+ ltd.appendChild(document.createTextNode(fieldIdl.label));
+ }
- var widget = new openils.widget.AutoFieldWidget({
- idlField : fieldIdl,
- fmObject : null, // XXX
- fmClass : fmcls,
- parentNode : span,
- widgetClass : wclass,
- dijitArgs : {style: wstyle},
- orgLimitPerms : ['UPDATE_USER'],
- });
- widget.build();
- }
+ span = document.createElement('span');
+ wtd.appendChild(span);
+
+ var widget = new openils.widget.AutoFieldWidget({
+ idlField : fieldIdl,
+ fmObject : null, // XXX
+ fmClass : fmcls,
+ parentNode : span,
+ widgetClass : wclass,
+ dijitArgs : {style: wstyle},
+ orgLimitPerms : ['UPDATE_USER'],
+ });
+ widget.build();
}
+
function ueLoadContextHelp(fmcls, fmfield) {
openils.Util.removeCSSClass(dojo.byId('uedit-help-div'), 'hidden');
dojo.byId('uedit-help-field').innerHTML = fieldmapper.IDL.fmclasses[fmcls].field_map[fmfield].label;
Modified: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-02-16 22:00:06 UTC (rev 12193)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-02-17 02:30:46 UTC (rev 12194)
@@ -85,8 +85,10 @@
<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'><td colspan='10'>Statistical Categories</td></tr>
- <tr class='divider'><td colspan='10'>Surveys</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>
</tbody>
</table>
[% END %]
+
More information about the open-ils-commits
mailing list