Skip to content

Instantly share code, notes, and snippets.

@shunya
Created November 18, 2012 02:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shunya/4102987 to your computer and use it in GitHub Desktop.
Save shunya/4102987 to your computer and use it in GitHub Desktop.
, showAccountView: function(account) {
if(this.accountsWatchId){
Services.Accounts.get.unwatch(this.accountsWatchId);
delete this.accountsWatchId;
}
if (!_.isUndefined(this.previousAccount) && _.isEqual(account.attributes, this.previousAccount.attributes)) {
return;
}
var productType = account.get('productType');
if (!_.isUndefined(this.currentProductType) && this.currentProductType == productType) {
this.currentProductView.changeAccount(account);
} else {
if (typeof this.currentProductView != 'undefined') {
this.currentProductView.close();
}
this.$el.find('.detailsSection').append('<div class="content"></div>');
var childDiv = this.$el.find('.content');
switch (productType) {
case 'BANK':
this.currentProductView = new CashView({el: childDiv, model: account});
break;
case 'CREDIT_CARD':
this.currentProductView = new CreditCardView({el: childDiv, model: account});
break;
case 'INVESTMENT':
this.currentProductView = new InvestmentView({el: childDiv, model: account});
break;
case 'LOAN':
case 'MORTGAGE':
this.currentProductView = new LoanMortgageView({el: childDiv, model: account});
break;
}
this.currentProductType = productType;
}
if (!this.holdingsView){
this.holdingsView = new HoldingsDatagridView({el: this.$el.find('.holdingsSection'), userAccountId: account.get('userAccountId')});
}
if (typeof this.transactonDatagrid == 'undefined') {
this.transactonDatagrid = new TransactionsDatagridView({el: this.$el.find('.datagridSection'), userAccountId: account.get('userAccountId')});
} else {
this.transactonDatagrid.changeUserAccount(account.get('userAccountId'));
}
this.previousAccount = account;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment