[open-ils-commits] r12193 - in trunk/Open-ILS/web: js/ui/default js/ui/default/actor js/ui/default/actor/user templates/default templates/default/actor templates/default/actor/user (erickson)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 16 17:00:11 EST 2009
Author: erickson
Date: 2009-02-16 17:00:06 -0500 (Mon, 16 Feb 2009)
New Revision: 12193
Added:
trunk/Open-ILS/web/js/ui/default/actor/
trunk/Open-ILS/web/js/ui/default/actor/user/
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
trunk/Open-ILS/web/templates/default/actor/
trunk/Open-ILS/web/templates/default/actor/user/
trunk/Open-ILS/web/templates/default/actor/user/register.tt2
Log:
experimental flattened/idl-aware user editor that takes advantage of auto-widgets and field-docs (i.e. context help)
Added: trunk/Open-ILS/web/js/ui/default/actor/user/register.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/actor/user/register.js (rev 0)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-02-16 22:00:06 UTC (rev 12193)
@@ -0,0 +1,96 @@
+dojo.require('dojo.data.ItemFileReadStore');
+dojo.require('dijit.form.Textarea');
+dojo.require('dijit.form.FilteringSelect');
+dojo.require('fieldmapper.IDL');
+dojo.require('openils.PermaCrud');
+dojo.require('openils.widget.AutoGrid');
+dojo.require('openils.widget.AutoFieldWidget');
+dojo.require('dijit.form.CheckBox');
+
+var pcrud;
+var fmClasses = ['au', 'ac', 'aua', 'actsc', 'asv', 'asvq', 'asva'];
+var fieldDoc = {};
+
+
+function load() {
+ 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();
+ }
+ }
+ );
+}
+
+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;
+
+ var fmfield = row.getAttribute('fmfield');
+ var wclass = row.getAttribute('wclass');
+ var wstyle = row.getAttribute('wstyle');
+ var fieldIdl = fieldmapper.IDL.fmclasses[fmcls].field_map[fmfield];
+
+ 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'));
+
+ 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);
+ }
+
+ if(!ltd.textContent) {
+ var span = document.createElement('span');
+ ltd.appendChild(document.createTextNode(fieldIdl.label));
+ }
+
+ 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;
+ dojo.byId('uedit-help-text').innerHTML = fieldDoc[fmcls][fmfield].string();
+}
+
+
+openils.Util.addOnLoad(load);
+
Added: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2 (rev 0)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-02-16 22:00:06 UTC (rev 12193)
@@ -0,0 +1,92 @@
+[% WRAPPER default/base.tt2 %]
+<script src='[% ctx.media_prefix %]/js/ui/default/actor/user/register.js'> </script>
+
+<style>
+
+ /* XXX Move me into the CSS tree XXX */
+
+ #uedit-tbody tr td {
+ padding: 5px;
+ text-align: left;
+ }
+ #uedit-help-div {
+ position: fixed;
+ top: 40px;
+ right: 30px;
+ width:300px;
+ height:200px;
+ border:2px dashed #e0e0c0;
+ -moz-border-radius: 10px;
+ font-weight: bold;
+ padding: 20px;
+ }
+ .uedit-help {
+ width: 25px;
+ border:1px solid #e0e0e0;
+ text-align:center;
+ vertical-align:middle;
+ }
+ .divider td {
+ min-height:10px;
+ background-color: #e0e0e0;
+ }
+
+</style>
+
+<!-- context help widget -->
+<a class='hidden' id='uedit-help-template'><img src='/opac/images/advancedsearch-icon.png'></img></a>
+<fieldset id='uedit-help-div' class='hidden'>
+ <legend id='uedit-help-field'/>
+ <div id='uedit-help-text'/>
+</fieldset>
+
+<table>
+ <tbody id='uedit-tbody'>
+ <tr fmclass='ac' fmfield='barcode'/>
+ <tr fmclass='au' fmfield='usrname'/>
+ <tr fmclass='au' fmfield='passwd'/>
+ <tr fmclass='au' fmfield='passwd'><td/><td>Verify Password</td><td/></tr>
+ <tr fmclass='au' fmfield='first_given_name'/>
+ <tr fmclass='au' fmfield='second_given_name'/>
+ <tr fmclass='au' fmfield='family_name'/>
+ <tr fmclass='au' fmfield='suffix'/>
+ <tr fmclass='au' fmfield='alias'/>
+ <tr fmclass='au' fmfield='dob'/>
+ <tr fmclass='au' fmfield='juvenile'/>
+ <tr fmclass='au' fmfield='ident_type'/>
+ <tr fmclass='au' fmfield='ident_value'/>
+ <tr fmclass='au' fmfield='email'/>
+ <tr fmclass='au' fmfield='day_phone'/>
+ <tr fmclass='au' fmfield='evening_phone'/>
+ <tr fmclass='au' fmfield='other_phone'/>
+ <tr fmclass='au' fmfield='home_ou'/>
+ <tr fmclass='au' fmfield='profile'/>
+ <tr fmclass='au' fmfield='expire_date'/>
+ <tr fmclass='au' fmfield='net_access_level'/>
+ <tr fmclass='au' fmfield='active'/>
+ <tr fmclass='au' fmfield='barred'/>
+ <tr fmclass='au' fmfield='master_account'/>
+ <tr fmclass='au' fmfield='claims_returned_count'/>
+ <tr fmclass='au' fmfield='alert_message' wclass='dijit.form.Textarea' wstyle='height:5em'/>
+ <tr class='divider'><td colspan='10'>Address</td></tr>
+ <tr fmclass='aua' fmfield='address_type'/>
+ <tr fmclass='aua' fmfield='post_code'/>
+ <tr fmclass='aua' fmfield='street1'/>
+ <tr fmclass='aua' fmfield='street2'/>
+ <tr fmclass='aua' fmfield='city'/>
+ <tr fmclass='aua' fmfield='county'/>
+ <tr fmclass='aua' fmfield='state'/>
+ <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'><td colspan='10'>Statistical Categories</td></tr>
+ <tr class='divider'><td colspan='10'>Surveys</td></tr>
+ </tbody>
+</table>
+[% END %]
More information about the open-ils-commits
mailing list