this._drawCopies = function(li) {
var self = this;
+ self.firstItemLibSelector = null;
// this button sets the total number of copies for a given lineitem
acqLitAddCopyCount.onClick = function() {
acqLitCopyCountInput.attr('value', self.copyCount()+'');
}
}
+
+ // KCLS -- after adding new copies, focus the library
+ // selector of the first copy in the list. Add the timeout
+ // so prevent focus shifting before the onKeyUp handler fires.
+ // Otherwise, onKeyUp is called on the lib selector instead
+ // of acqLitAddCopyCount, causing focus to jump to the
+ // second selector.
+ setTimeout(function() {
+ if (self.firstItemLibSelector)
+ self.firstItemLibSelector.focus();
+ }, 100);
}
} else {
self.addCopy(li);
}
+
+ // KCLS: select the Item Count value for easier modification.
+ setTimeout(function() {
+ var node = acqLitCopyCountInput
+ .domNode.getElementsByTagName('input')[0];
+ if (node) node.select();
+ }, 500);
};
this.copyCount = function() {
parentNode : dojo.query('[name='+field+']', row)[0],
orgLimitPerms : ['CREATE_PICKLIST', 'CREATE_PURCHASE_ORDER'],
readOnly : readOnly,
- orgDefaultsToWs : true
+ //orgDefaultsToWs : true // KCLS wants empty lib selector
});
widget.build(
}
}
);
+
+ // KCLS ---
+ if (field == 'owning_lib') {
+ var nodeId = w.id.replace(/.*(\d+)$/,'$1');
+
+ // track the first library selector so we can
+ // focus it after generating new copies
+ if (nodeId == 1) self.firstItemLibSelector = w;
+
+ // User pressing Enter on the ownling library
+ // selector causes focus to jump to the next
+ // owning library selector in the list of copies.
+ dojo.connect(w, 'onKeyUp', function(key) {
+ if (key.keyCode != 13) return // 13 = Enter
+ // ID's for like dijits increment by 1.
+ var nextId = w.id.replace(
+ /(.*)\d+$/, '$1' + (Number(nodeId) + 1));
+ if (dijit.byId(nextId))
+ dijit.byId(nextId).focus();
+ });
+ }
}
);
}