[open-ils-commits] r12209 - 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
Tue Feb 17 17:50:46 EST 2009
Author: erickson
Date: 2009-02-17 17:50:41 -0500 (Tue, 17 Feb 2009)
New Revision: 12209
Modified:
trunk/Open-ILS/web/js/ui/default/actor/user/register.js
trunk/Open-ILS/web/templates/default/actor/user/register.tt2
Log:
plugged in new/delete addr handling
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-17 22:49:37 UTC (rev 12208)
+++ trunk/Open-ILS/web/js/ui/default/actor/user/register.js 2009-02-17 22:50:41 UTC (rev 12209)
@@ -21,12 +21,23 @@
var widgetPile = [];
var uEditCardVirtId = -1;
var uEditAddrVirtId = -1;
+var orgSettings = {};
+var tbody;
+var addrTemplateRows;
function load() {
staff = new openils.User().user;
pcrud = new openils.PermaCrud();
-
+ uEditNewPatron(); /* XXX */
+
+ orgSettings = fieldmapper.aou.fetchOrgSettingBatch(staff.ws_ou(), [
+ 'global.juvenile_age_threshold',
+ 'patron.password.use_phone',
+ ]);
+ for(k in orgSettings)
+ orgSettings[k] = orgSettings[k].value;
+
var list = pcrud.search('fdoc', {fm_class:fmClasses});
for(var i in list) {
var doc = list[i];
@@ -35,18 +46,21 @@
fieldDoc[doc.fm_class()][doc.field()] = doc;
}
- var tbody = dojo.byId('uedit-tbody');
+ tbody = dojo.byId('uedit-tbody');
+
+ addrTemplateRows = dojo.query('tr[type=addr-template]', tbody);
+ dojo.forEach(addrTemplateRows, function(row) { row.parentNode.removeChild(row); } );
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'));
- loadStaticFields(tbody);
- loadStatCats(tbody);
- loadSurveys(tbody);
+ loadStaticFields();
+ uEditNewAddr(null, uEditAddrVirtId);
+ loadStatCats();
+ loadSurveys();
}
-function loadStaticFields(tbody) {
- // draw static user/addr fields
+function loadStaticFields() {
for(var idx = 0; tbody.childNodes[idx]; idx++) {
var row = tbody.childNodes[idx];
if(row.nodeType != row.ELEMENT_NODE) continue;
@@ -56,7 +70,8 @@
}
}
-function loadStatCats(tbody) {
+function loadStatCats() {
+
statCats = fieldmapper.standardRequest(
['open-ils.circ', 'open-ils.circ.stat_cat.actor.retrieve.all'],
{params : [openils.User.authtoken, staff.ws_ou()]}
@@ -84,7 +99,7 @@
}
}
-function loadSurveys(tbody) {
+function loadSurveys() {
surveys = fieldmapper.standardRequest(
['open-ils.circ', 'open-ils.circ.survey.retrieve.all'],
@@ -120,11 +135,12 @@
}
-function fleshFMRow(row, fmcls) {
+function fleshFMRow(row, fmcls, args) {
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(!args) args = {};
var existing = dojo.query('td', row);
var htd = existing[0] || row.appendChild(document.createElement('td'));
@@ -135,7 +151,7 @@
if(fieldDoc[fmcls] && fieldDoc[fmcls][fmfield]) {
var link = dojo.byId('uedit-help-template').cloneNode(true);
link.id = '';
- link.setAttribute('href', 'javascript:ueLoadContextHelp("'+fmcls+'","'+fmfield+'")');
+ link.onclick = function() { ueLoadContextHelp(fmcls, fmfield) };
openils.Util.removeCSSClass(link, 'hidden');
htd.appendChild(link);
}
@@ -161,8 +177,9 @@
widget._wtype = fmcls;
widget._fmfield = fmfield;
- widget._addr = uEditAddrVirtId;
+ widget._addr = args.addr;
widgetPile.push(widget);
+ return widget;
}
function getByName(node, name) {
@@ -183,7 +200,7 @@
patron.isnew(1);
patron.id(-1);
card = new ac();
- card.id(uEditCardVirtId--);
+ card.id(uEditCardVirtId);
card.isnew(1);
patron.card(card);
patron.cards([card]);
@@ -215,11 +232,8 @@
}
function uEditSave() {
- if(!patron) uEditNewPatron();
-
for(var idx in widgetPile) {
var w = widgetPile[idx];
- console.log(w._wtype + ' : ' + w._fmfield + ' : ' + uEditWidgetVal(w));
switch(w._wtype) {
case 'au':
@@ -237,7 +251,6 @@
addr.id(w._addr);
addr.isnew(1);
patron.addresses().push(addr);
- console.log("pushing address " + addr.id());
}
addr[w._fmfield](uEditWidgetVal(w));
break;
@@ -267,9 +280,6 @@
}
}
- console.log(js2JSON(patron.addresses()));
- alert(js2JSON(patron));
-
fieldmapper.standardRequest(
['open-ils.actor', 'open-ils.actor.patron.update'],
{ async: true,
@@ -277,11 +287,8 @@
oncomplete: function(r) {
patron = openils.Util.readResponse(r);
if(patron) {
- alert('success');
- //uEditRefresh();
- } else {
- alert('no success?');
- }
+ uEditRefresh();
+ }
}
}
);
@@ -293,11 +300,31 @@
location.href = href;
}
+function uEditNewAddr(evt, id) {
+ if(id == null) id = --uEditAddrVirtId;
+ dojo.forEach(addrTemplateRows,
+ function(row) {
+ row = tbody.insertBefore(row.cloneNode(true), dojo.byId('new-addr-row'));
+ row.setAttribute('type', '');
+ row.setAttribute('addr', id+'');
+ if(row.getAttribute('fmclass')) {
+ fleshFMRow(row, 'aua', {addr:id});
+ } else {
+ var btn = dojo.query('[name=delete-button]', row)[0];
+ if(btn) btn.onclick = function(){ uEditDeleteAddr(id) };
+ }
+ }
+ );
+}
+function uEditDeleteAddr(id) {
+ if(!confirm('Delete address ' + id)) return; /* XXX i18n */
+ var rows = dojo.query('tr[addr='+id+']', tbody);
+ for(var i = 0; i < rows.length; i++)
+ rows[i].parentNode.removeChild(rows[i]);
+ widgetPile = widgetPile.filter(function(w){return (w._addr != id)});
+}
-
-
openils.Util.addOnLoad(load);
-
Modified: trunk/Open-ILS/web/templates/default/actor/user/register.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-02-17 22:49:37 UTC (rev 12208)
+++ trunk/Open-ILS/web/templates/default/actor/user/register.tt2 2009-02-17 22:50:41 UTC (rev 12209)
@@ -44,6 +44,19 @@
background-color: #e0e0e0;
}
+ .divider span { padding: 0px 5px 0px 5px; }
+
+ .newaddr-row td {
+ text-align: right;
+ border-top:1px dashed #d9e8f9;
+ }
+ .newaddr-row td:last-child {
+ border-right:1px dashed #d9e8f9;
+ }
+
+ .uedit-addr-del-button {margin-left: 10px; color:red;}
+
+
</style>
<table>
@@ -75,28 +88,37 @@
<tr fmclass='au' fmfield='claims_returned_count'/>
<tr fmclass='au' fmfield='alert_message' wclass='dijit.form.Textarea' wstyle='height:5em'/>
- <tr class='divider' type='addr'><td colspan='0'>Address</td></tr>
- <tr fmclass='aua' fmfield='address_type' type='addr'/>
- <tr fmclass='aua' fmfield='post_code' type='addr'/>
- <tr fmclass='aua' fmfield='street1' type='addr'/>
- <tr fmclass='aua' fmfield='street2' type='addr'/>
- <tr fmclass='aua' fmfield='city' type='addr'/>
- <tr fmclass='aua' fmfield='county' type='addr'/>
- <tr fmclass='aua' fmfield='state' type='addr'/>
- <tr fmclass='aua' fmfield='country' type='addr'/>
- <tr fmclass='aua' fmfield='valid' type='addr'/>
- <tr fmclass='aua' fmfield='within_city_limits' type='addr'/>
+ <!-- Address -->
+ <tr name='uedit-addr-divider' class='divider' type='addr-template'>
+ <td colspan='2'>Address</td>
+ <td>
+ <span>Mailing</span><input type='radio' name='mailing_address'>
+ <span>Billing</span><input type='radio' name='billing_address'>
+ <button name='delete-button' class='uedit-addr-del-button'>X</button>
+ </td>
+ </tr>
+ <tr fmclass='aua' fmfield='address_type' type='addr-template'/>
+ <tr fmclass='aua' fmfield='post_code' type='addr-template'/>
+ <tr fmclass='aua' fmfield='street1' type='addr-template'/>
+ <tr fmclass='aua' fmfield='street2' type='addr-template'/>
+ <tr fmclass='aua' fmfield='city' type='addr-template'/>
+ <tr fmclass='aua' fmfield='county' type='addr-template'/>
+ <tr fmclass='aua' fmfield='state' type='addr-template'/>
+ <tr fmclass='aua' fmfield='country' type='addr-template'/>
+ <tr fmclass='aua' fmfield='valid' type='addr-template'/>
+ <tr fmclass='aua' fmfield='within_city_limits' type='addr-template'/>
- <tr type='addr'><td class='uedit-help'><td>Billing Address</td>
- <td><div dojoType='dijit.form.CheckBox' name='billing-addr-widget'></div></td>
+ <tr id='new-addr-row' class='newaddr-row'>
+ <td colspan='0' align='middle'/>
+ <button dojoType='dijit.form.Button' onClick='uEditNewAddr'>New Address</button>
+ </td>
</tr>
- <tr type='addr'><td class='uedit-help'><td>Mailing Address</td>
- <td><div dojoType='dijit.form.CheckBox' name='billing-addr-widget'></div></td>
- </tr>
+ <!-- stat cats -->
<tr class='divider' id='stat-cat-divider'><td colspan='0'>Statistical Categories</td></tr>
<tr id='stat-cat-row-template'><td class='uedit-help'/><td name='name'/><td name='widget'/></tr>
+ <!-- surveys -->
<tr id='survey-row-template' class='divider'><td colspan='0' name='name'/></tr>
<tr id='survey-question-row-template'><td class='uedit-help'/><td name='question'/><td name='answers'/></tr>
</tbody>
@@ -104,8 +126,7 @@
<div id='uedit-save-div'>
<button dojoType='dijit.form.Button' jsId='saveButton' onClick='uEditSave'>Save</button>
- <button dojoType='dijit.form.Button' jsId='saveCloneButton'>Save & Clone</button>
- <button dojoType='dijit.form.Button' jsId='cancelButton'>Cancel</button>
+ <button dojoType='dijit.form.Button' jsId='saveCloneButton' onClick='uEditSaveClone'>Save & Clone</button>
</div>
<!-- context help widget -->
More information about the open-ils-commits
mailing list