}, true);
});
+ if (stageUser) processStageUserValues();
+
lock_ready = true;
}
}
}
+ // if either mailing or billing addresses are not provided,
+ // use each for the other as a fall-back.
+ if (patron.mailing_address() && !patron.billing_address()) {
+ patron.billing_address(patron.mailing_address());
+ } else if (patron.billing_address() && !patron.mailing_address()) {
+ patron.mailing_address(patron.billing_address());
+ }
+
// TODO: uses the first card only
if(data.cards.length) {
var card = new fieldmapper.ac();
}
}
+ // Copy stat cat data
+ dojo.forEach(data.statcats, function(stat_cat) {
+ var entry = new fieldmapper.actscecm();
+ entry.isnew(true);
+ entry.stat_cat(stat_cat.statcat());
+ entry.stat_cat_entry(stat_cat.value());
+ entry.target_usr(patron.id());
+ patron.stat_cat_entries().push(entry);
+ });
+
return patron;
}
return widget;
}
+// JBAS-1132
+// When loading a staged user, force the on-change handler to run for
+// various fields, since their values are applied at load- time instead
+// of via manual changing.
+// All staged user values of concern are simple text values, whose
+// widgets are loaded synchronously. No need to setTimeout or
+// track loaded fields, etc. before calling this function.
+// Force on-change to run for:
+// * duplicate value searches
+// * setting default password from phone
+function processStageUserValues() {
+
+ dojo.forEach(
+ ['family_name', 'email', 'ident_value', 'ident_value2',
+ 'dob', 'day_phone', 'evening_phone', 'other_phone'],
+ function(field) {
+ var val = findWidget('au', field).widget.attr('value');
+ if (val) {
+ findWidget('au', field).widget.attr('value', '');
+ findWidget('au', field).widget.attr('value', val);
+ }
+ }
+ );
+
+ dojo.forEach(
+ patron.addresses(),
+ function(addr) {
+ var callback = function(w) { return w._addr == addr.id() };
+ var widg = findWidget('aua', 'street1', callback).widget;
+ var val = widg.attr('value');
+ if (val) {
+ widg.attr('value', '');
+ widg.attr('value', val);
+ }
+ }
+ );
+}
+
function trimGrpTree(autoWidget) {
var store = autoWidget.widget.store;
if(!store) return;
return;
case 'profile': // when the profile changes, update the expire date
- dojo.connect(widget.widget, 'onChange',
- function() {
- var self = this;
- var expireWidget = findWidget('au', 'expire_date');
- function found(items) {
- if(items.length == 0) return;
- var item = items[0];
- var interval = self.store.getValue(item, 'perm_interval');
- expireWidget.widget.attr('value', dojo.date.add(new Date(),
- 'second', openils.Util.intervalToSeconds(interval)));
- }
- this.store.fetch({onComplete:found, query:{id:this.attr('value')}});
+
+ function profileChangedHandler(self) {
+ var expireWidget = findWidget('au', 'expire_date');
+ function found(items) {
+ if(items.length == 0) return;
+ var item = items[0];
+ var interval = self.store.getValue(item, 'perm_interval');
+ expireWidget.widget.attr('value', dojo.date.add(new Date(),
+ 'second', openils.Util.intervalToSeconds(interval)));
}
- );
+ self.store.fetch({onComplete:found, query:{id:self.attr('value')}});
+ }
+
+ // Force the handler to run if a profile was set on the
+ // staged user. Otherwise it won't run unless the profile
+ // is manually altered. Run it in a timeout so the expire
+ // widget has a chance to render before we reference it.
+ if (stageUser && stageUser.profile) {
+ setTimeout(function() {
+ profileChangedHandler(widget.widget)}, 300);
+ }
+
+ dojo.connect(widget.widget, 'onChange',
+ function() {profileChangedHandler(this) });
return;
case 'dob':
function uEditDupeSearch(type, value) {
if(!value) return;
var search;
+
+ console.debug('running dupe search for ' + type + ' : ' + value);
+
switch(type) {
case 'name':