aimbidders.js
Summary
Collection of application level classes.
This collection implements the rich-internet-application tier of
the Bidders Module for AIM (Auction Inventory Management),
which is a demonstration of the Gravey framework.
Version: 2.0
Requires:
Author: Bruce Wallace (PolyGlotInc.com)
|
Class Summary
|
| Bidder |
This class encapsulates an Auction Bidder record. |
| BidderModel |
This class encapsulates the data model of a particular Bidder. |
| BidderModelView |
This class produces the view of the entire data panel. |
| BidderSelectionModel |
This class encapsulates the data model for
"which Bidder is currently selected". |
| BidderSummary |
This class encapsulates the identifying attributes of an Auction Bidder. |
| BidderView |
This class produces a view of a Bidder. |
| BSCEDO |
This is the abstract base class for Bidder/Shipping/Contact EDOs. |
| BSCIndex |
This class encapsulates an EDO index for Bidder/Shipping/Contact. |
| Contact |
This class encapsulates a Bidder "contact" record. |
| ContactListView |
This class produces a view of a List of Contact EDOs. |
| ContactView |
This class produces a view of a Contact. |
| Shipping |
This class encapsulates a Bidder "Shipping" record. |
| ShippingListView |
This class produces a view of a List of Shipping EDOs. |
| ShippingView |
This class produces a view of a Shipping. |
Class(BidderSummary,["unique Key","Company Name","FICO Code","lot count","inactive flag"])
.Extends(EDOHolderSelectionItem);
function BidderSummary()
{
this.konstructor = function( theKey, coName, fico, lotCount, inactive )
{
this.key = theKey;
this.coName = coName;
this.fico = fico;
this.count = lotCount;
this.dead = inactive;
}
this.getDescription = function() {
return grvDiamond(!this.dead)+this.coName;
}
this.toString = function()
{
var s = new Array();
s.push( this.key );
s.push( this.coName );
s.push( this.fico );
s.push( this.dead );
return s.join( "-" );
}
this.updateProperties = function( bsum ){
this.key = bsum.key;
this.coName = bsum.coName;
this.fico = bsum.fico;
this.count = bsum.count;
this.dead = bsum.dead;
}
}
Class(BSCIndex).Extends(EDOIndex);
function BSCIndex()
{
if (!BSCIndex.Bidder){
BSCIndex.Bidder = function() {
return new BSCIndex(0,null,null);
}
BSCIndex.Shipping = function( index ) {
return new BSCIndex(0,index,null);
}
BSCIndex.Contact = function( index ) {
return new BSCIndex(0,null,index);
}
}
this.konstructor = function( optB,optS,optC )
{
this.b = optB===undefined ? null : optB;
this.s = optS===undefined ? null : optS;
this.c = optC===undefined ? null : optC;
}
this.asEventArgs = function() {
return " new BSCIndex("+this.b+","+this.s+","+this.c+") ";
}
this.asString = function() {
return this.invoke( this, this._noString, this._shpString, this._conString )
+ this._bidString( this.b );
}
this._noString = function(){ return ""; }
this._bidString = function( bindex ){
var b = gBidderData._getBidder( bindex );
return (b && b[ kStrIdCompany ]) ? b[ kStrIdCompany ] : "New Bidder";
}
this._conString = function( cindex ){
cindex -= 0;
return "Contact["+(cindex+1)+"] of ";
}
this._shpString = function( sindex ){
sindex -= 0;
return "Shipping["+(sindex+1)+"] of ";
}
this.hasSelection = function(){ return this.b!=null
|| this.s!=null
|| this.c!=null; }
this.equals = function(x){
return x ? (this.b==x.b && this.s==x.s && this.c==x.c) : false;
}
this.invoke = function(self,bMethod,sMethod,cMethod,optArg){
var aMethod;
var i;
if (this.s!=null) { aMethod = sMethod; i = this.s; } else
if (this.c!=null) { aMethod = cMethod; i = this.c; } else
{ aMethod = bMethod; i = this.b; }
return aMethod.call( self, i, optArg );
}
}
var kStrIdCompany = 'Company';
var kCodeIdFICO = 'FICO';
var kBoolInactive = 'Inactive?';
var kStrIdName = 'Contact Person';
var kStrIdWireInst = 'Wiring Instructions';
var kAddrIdStreet = 'Street';
var kAddrIdState = 'State';
var kAddrIdCity = 'City';
var kAddrIdZip = 'Zip';
var kPhoneIdMain = 'Phone';
var kPhoneIdFax = 'Fax';
var kEMailIdAddr = 'EMail Address';
Class(BSCEDO,["parent BidderModel","lot count",
"edo Class","property values array",
"edit Date","edit User","unique Key"])
.Extends(EDO);
function BSCEDO()
{
this.konstructor = function
(
holder,
lotcount,
CLAZZ,
propValues,
editDate,
editUser,
theKey,
optEditStatus,
optName
){
this.souper( CLAZZ, holder, propValues, editDate, editUser,
theKey, optEditStatus, optName );
this.lotCount = lotcount;
}
this.toolTip = function( xi ){
return this.edoToolTip(xi) + " Lots="+this.lotCount;
}
this.toString = function() {
return this[ kStrIdCompany ];
}
this.canDelete = function()
{
if (!this.isActive())
return "This is already deleted.";
var c = this.lotCount;
if (c>0)
return "This can't be deleted. It is referenced by "
+c+" Lot"+(c==1?".":"s.");
return null;
}
this.pushUpdateFields = function( uFields )
{
uFields.push( encodeURIComponent(this.holder.getName()) );
this.pushEncodedValues( uFields );
}
}
Class(Bidder,["property values array","edit Date","edit User",
"unique Key","parent Bidder","lot count"])
.Extends(BSCEDO);
function Bidder()
{
if (!Bidder.Properties) {
Bidder.Factory = function(index,holder) {
var x = new Bidder( null, grvGetTodayAsMMDDYYYY(),kUserID,null,holder,0 );
x[ kCodeIdFICO ] = 0;
return x;
}
Bidder.UpdateID = "Bidder";
Bidder.Properties = [ kStrIdCompany, kCodeIdFICO, kBoolInactive ];
Bidder.EditRules = [ MVCEditRule.kReqd, MVCEditRule.kAlNo, MVCEditRule.kBOOL ];
}
this.konstructor = function
( propArray, editDate, editUser, theKey, holder, lotcount, optEditStatus, optName )
{
this.souper( holder, lotcount, Bidder,
propArray, editDate, editUser, theKey, optEditStatus, optName );
}
this.clone = function() {
return new Bidder( this.propValues(), this.date, this.whom,
this.key, this.holder, this.lotCount, this.editStatus );
}
this.canCreate = function(appendFlag) {
return this.holder.isTrue()
? "Can't add a new Bidder until pending changes have been saved"
: null;
}
this.canUncreate = function(appendFlag){ return false; }
}
Class(Contact,["property values array","edit Date","edit User",
"unique Key","parent Bidder","lot count"])
.Extends(BSCEDO);
function Contact()
{
if (!Contact.Properties) {
Contact.Factory = function(index,holder) {
return new Contact( null,grvGetTodayAsMMDDYYYY(),kUserID,null,holder,0 );
}
Contact.UpdateID = "Contact";
Contact.Properties = [
kStrIdName, kPhoneIdMain, kPhoneIdFax, kAddrIdStreet,
kAddrIdCity, kAddrIdState, kAddrIdZip, kEMailIdAddr,
kStrIdWireInst ];
Contact.EditRules = [
MVCEditRule.kEdit, MVCEditRule.kFone, MVCEditRule.kFone, MVCEditRule.kEdit,
MVCEditRule.kAlfa, MVCEditRule.kAlfa, MVCEditRule.kZip, MVCEditRule.kEdit,
MVCEditRule.kEdit ];
}
this.konstructor = function
( propArray, editDate, editUser, theKey, holder, lotcount, optEditStatus, optName )
{
this.souper( holder, lotcount, Contact,
propArray, editDate, editUser, theKey, optEditStatus, optName );
}
this.clone = function() {
return new Contact( this.propValues(), this.date, this.whom,
this.key, this.holder, this.lotCount, this.editStatus );
}
this.toString = function() {
return this[ kStrIdName ];
}
}
Class(Shipping,["property values array","edit Date","edit User",
"unique Key","parent Bidder","lot count"])
.Extends(BSCEDO);
function Shipping()
{
if (!Shipping.Properties) {
Shipping.Factory = function(index,holder) {
return new Shipping( null,grvGetTodayAsMMDDYYYY(),kUserID,null,holder,0 );
}
Shipping.UpdateID = "Shipping";
Shipping.Properties = [
kStrIdName, kPhoneIdMain, kPhoneIdFax, kAddrIdStreet,
kAddrIdCity, kAddrIdState, kAddrIdZip, kEMailIdAddr,
kStrIdCompany ];
Shipping.EditRules = [
MVCEditRule.kEdit, MVCEditRule.kFone, MVCEditRule.kFone, MVCEditRule.kEdit,
MVCEditRule.kAlfa, MVCEditRule.kAlfa, MVCEditRule.kZip, MVCEditRule.kEdit,
MVCEditRule.kEdit ];
}
this.konstructor = function
( propArray, editDate, editUser, theKey, holder, lotcount, optEditStatus, optName )
{
this.souper( holder, lotcount, Shipping,
propArray, editDate, editUser, theKey, optEditStatus, optName );
}
this.clone = function() {
return new Shipping( this.propValues(), this.date, this.whom,
this.key, this.holder, this.lotCount, this.editStatus );
}
}
Class(BidderModel,["Bidder Selection Model"]).Extends(EDOHolderModel);
function BidderModel()
{
this.konstructor = function( BidderSelectionModel, optName )
{
if (!BidderModel.LoadXslDOM) BidderModel.LoadXslDOM = grvLoadXslDOM( kXSLPath+"AIMbidToJS.xsl" );
var holderName = optName ? optName : "Bidder";
this.souper( BidderSelectionModel, BidderModel.LoadXslDOM, holderName );
this._resetEDOs();
}
this.getName = function(){
return this.bidder ? this.bidder[kStrIdCompany] : null;
}
this.inactive = function(){
return this.bidder ? this.bidder[kBoolInactive] : null;
}
this.isDirty = function()
{
if (this.bidder && this.bidder.inEdit()) return true;
if (this.cList.isDirty()) return true;
if (this.sList.isDirty()) return true;
return false;
}
this.isValid = function()
{
if (!this.bidder || !this.bidder.isValid()) return false;
if (this.bidder.isDeleted()) return true;
if (!this.cList.isValid()) return false;
if (!this.sList.isValid()) return false;
return true;
}
this._resetEDOs = function( optBidder )
{
this.bidder = optBidder ? optBidder : null;
if ( this.cList ) this.cList.reset();
else this.cList = new EDOListModel( Contact );
if ( this.sList ) this.sList.reset();
else this.sList = new EDOListModel( Shipping );
}
this._setBidder = function(o){ this.bidder = o; }
this._newContacts = function(){ return this.cList.reset(); }
this._newShipping = function(){ return this.sList.reset(); }
this.dump = function()
{
var dStr = new Array();
dStr.push( "BidderModel>>>[" );
dStr.push( "Bidder="+(this.bidder?this.bidder.dump():"null") );
dStr.push( "conts=" +(this.cList ?this.cList .dump():"null") );
dStr.push( "ships=" +(this.sList ?this.sList .dump():"null") );
dStr.push( "]" );
return dStr.join("\n");
}
this.createSelectionItem = function() {
return new BidderSummary( this.bidder.key,
this.bidder[kStrIdCompany],
this.bidder[kCodeIdFICO],
0,
this.bidder[kBoolInactive] );
}
this.getUpdatedProperty = function() {
return this.createSelectionItem();
}
this.hasEDO = function(){ return this.bidder!=null; }
this.keysMatch = function(item){ return this.bidder.key==item.key; }
this.propMatch = function(item){ return this.getName ()==item.coName
&& this.inactive()==item.dead; }
this.pushPosts = function( posts )
{
this.bidder.pushPosts( posts );
this.cList.pushPosts( posts );
this.sList.pushPosts( posts );
}
this._newEDO = function(xi) {
return xi.invoke( this, Bidder.Factory, Shipping.Factory, Contact.Factory, this );
}
this._getContact = function( i ) {
return (i!=null && i>=0
&& i<this.cList.getCount())
? this.cList.getItem( i ) : null;
}
this._getShipping = function( i ) {
return (i!=null && i>=0
&& i<this.sList.getCount())
? this.sList.getItem( i ) : null;
}
this._getBidder = function( i ) {
return (i==0 && this.bidder)
? this.bidder : null;
}
this.getEDO = function(xi){
return xi.invoke( this, this._getBidder, this._getShipping, this._getContact );
}
this._insertContact = function( i, edo ) {
this.cList.addBefore( i, edo );
}
this._insertShipping = function( xi ) {
this.sList.addBefore( i, edo );
}
this.createEDO = function(xi){
xi.invoke( this, this._newBidder, this._insertShipping, this._insertContact, this.newEDO(xi) );
return xi;
}
this._appendContact = function( i, edo ) {
return BSCIndex.Contact( this.cList.addItem( edo ) );
}
this._appendShipping = function( i, edo ) {
return BSCIndex.Shipping( this.sList.addItem( edo ) );
}
this._newBidder = function( i, edo ) {
this._resetEDOs( edo );
this.updateStamp();
return BSCIndex.Bidder();
}
this.appendEDO = function(xi){
return xi.invoke( this, this._newBidder, this._appendShipping, this._appendContact, this.newEDO(xi) );
}
this.toggleExpand = function( doAllFlag, xi )
{
var edo = this.getEDO(xi);
if (doAllFlag)
{
var newVal = !edo.isExpanded();
this.cList.toggleExpandAll( newVal );
this.sList.toggleExpandAll( newVal );
this.bidder.toggleExpand ( newVal );
}
else edo.toggleExpand();
this.updateStamp();
}
}
Class(BidderSelectionModel,["BidderSummary List Model"]).Extends(EDOHolderSelectionModel);
function BidderSelectionModel()
{
this.konstructor = function( listModel ){
this.souper( listModel, "Bidder " );
}
this.findBidder = function( bidderName, bidderKey )
{
var list = this.model;
var N = list.getCount();
if (N<1) return -2;
for (var i=0; i<N; ++i)
if (list.getItem(i).coName == bidderName
|| list.getItem(i).key == bidderKey) return i;
return -1;
}
this.selectInitial = function( selectFirst )
{
var i = this.findBidder( kBidderName, kBidderKey );
if (i==-2){ this.selectNothing(); return; }
if (i>= 0){ this.select(i); return; }
if (selectFirst) this.select(0);
}
}
Class(BidderView,["Bidder object"])
.Extends(EDOView);
function BidderView()
{
this.konstructor = function( bidder ) {
this.souper( bidder, BSCIndex.Bidder() );
}
this.preSelect = function() {
this.sharedMenuSelect( gFICOSelected, kCodeIdFICO );
}
this.buildFields = function( HTML )
{
HTML.push( this.buildStrField( kStrIdCompany, 50, 50, false ) );
HTML.push( this.buildPopField( kCodeIdFICO , false, gFICOSelected ) );
HTML.push( this.buildBoxField( kBoolInactive, false ) );
}
}
Class(ContactView,["Contact object","EDOIndex of Contact"])
.Extends(EDOView);
function ContactView()
{
this.konstructor = function( edo, edoIndex ) {
this.souper( edo, edoIndex );
}
this.buildFields = function( HTML )
{
HTML.push( this.buildStrField( kStrIdName ,50,50,false) );
HTML.push( this.buildStrField( kAddrIdStreet,50,80,true ) );
HTML.push( this.buildStrField( kPhoneIdMain ,20,20,false) );
HTML.push( this.buildStrField( kAddrIdCity ,20,50,true ) );
HTML.push( this.buildStrField( kPhoneIdFax ,20,20,false) );
HTML.push( this.buildUprField( kAddrIdState , 2, 2,true ) );
HTML.push( this.buildStrField( kEMailIdAddr ,50,80,false) );
HTML.push( this.buildStrField( kAddrIdZip ,10,10,true ) );
HTML.push( this.buildTxtField( kStrIdWireInst,2,100,255,false,2 ) );
}
}
Class(ShippingView,["Shipping object","EDOIndex of Shipping"])
.Extends(EDOView);
function ShippingView()
{
this.konstructor = function( edo, edoIndex ) {
this.souper( edo, edoIndex );
}
this.buildFields = function( HTML )
{
HTML.push( this.buildStrField( kStrIdCompany,50,50,true ) );
HTML.push( this.buildStrField( kStrIdName ,50,50,false ) );
HTML.push( this.buildStrField( kAddrIdStreet,50,80,true ) );
HTML.push( this.buildStrField( kPhoneIdMain ,20,20,false ) );
HTML.push( this.buildStrField( kAddrIdCity ,20,50,true ) );
HTML.push( this.buildStrField( kPhoneIdFax ,20,20,false ) );
HTML.push( this.buildUprField( kAddrIdState , 2, 2,true ) );
HTML.push( this.buildStrField( kEMailIdAddr ,50,80,false ) );
HTML.push( this.buildStrField( kAddrIdZip ,10,10,false ) );
}
}
Class(ContactListView,["EDO ListModel"])
.Extends(EDOListView);
function ContactListView()
{
this.konstructor = function( edoListModel ) {
this.souper( edoListModel, ContactView );
}
this.itemEDOIndex = function( index ) {
return BSCIndex.Contact( index );
}
}
Class(ShippingListView,["EDO ListModel"])
.Extends(EDOListView);
function ShippingListView()
{
this.konstructor = function( edoListModel ) {
this.souper( edoListModel, ShippingView );
}
this.itemEDOIndex = function( index ) {
return BSCIndex.Shipping( index );
}
}
Class(BidderModelView,["Bidder data model"])
.Extends(EDOHolderView);
function BidderModelView()
{
this.konstructor = function( bidModel ) {
this.souper( bidModel );
}
this.buildFields = function( HTML )
{
var vwID = this.getWidgetID();
if ( !this.model.bidder || this.model.bidder.inLimbo() )
{
if (!grvWAITING())
HTML.push( EDOView.ShellHTML( BSCIndex.Bidder(), Bidder ) );
}
else if ( this.model.bidder.isActive() )
{
HTML.push( this.embedHTML( vwID+".bidWdgt",
new BidderView( this.model.bidder ) ) );
HTML.push( this.embedHTML( vwID+".coWdgt",
new ContactListView( this.model.cList ) ) );
HTML.push( this.embedHTML( vwID+".svWdgt",
new ShippingListView( this.model.sList ) ) );
}
else HTML.push( '<thead>This Bidder is deleted. You must Cancel, Save, or Undo.</thead>' );
}
}
Documentation generated by
JSDoc on Thu Jan 6 12:46:39 2011