model: app.Models.Front.Account,
initialize: function( parent ){
- console.log( 'initialize called with ' + parent );
this.parent = parent;
},
- localStorage: new Backbone.LocalStorage( 'Accounts-' ),
-
- sync: function( method, model, options ){
- return;
- //console.log('sync called on collection. method: ' + method );
- //console.log( method );
- switch( method ){
- case 'create':
- console.log('Create called on Accounts' + model);
- break;
- case 'read':
- console.log('Read called on Accounts' + model);
- break;
- case 'update':
- console.log('Update called on Accounts' + model);
- break;
- case 'delete':
- console.log('Delete called on Accounts' + model);
- break;
- }
+ //localStorage: new Backbone.LocalStorage( 'Accounts-' ),
+ urlBase: function(){
+ return appAccountUrl;
},
+ // sync: function( method, model, options ){
+ // console.log('sync called on collection. method: ' + method );
+ // //console.log( method );
+ // switch( method ){
+ // case 'create':
+ // console.log('Create called on Accounts' + model);
+ // break;
+ // case 'read':
+ // console.log('Read called on Accounts' + model);
+ // break;
+ // case 'update':
+ // console.log('Update called on Accounts' + model);
+ // break;
+ // case 'delete':
+ // console.log('Delete called on Accounts' + model);
+ // break;
+ // }
+ //
+ // },
+
create: function( model ){
localStorage.setItem('Account-' + model.parent + '-'+ model.id, JSON.stringify( model ) );
+ this.add( model );
+ },
+
+ remove: function( model ){
+ localStorage.removeItem( localStorage.key('Account-' + model.parent + '-'+ model.id ) );
+ console.log( 'Delete called in collection ' );
},
+ read: function(){
+ console.log( 'Read called' );
+ },
+
+ // save: function(){
+ // console.log('Update Called');
+ // },
+
fetch: function(){
var newModels = [];
for ( var i = 0; i < localStorage.length; i++ ) {
--- /dev/null
+app.Collections.Front.RegEvents = Backbone.Collection.extend({
+ model: app.Models.Front.RegEvent,
+
+ initialize: function(){
+ // something here
+ },
+
+ urlBase: function(){
+ return appAccountUrl;
+ },
+
+ create: function( model ){},
+
+ remove: function( model ){},
+
+ read: function(){},
+
+ update: function(){},
+
+ fetch: function(){
+ // something here for the fetch
+ },
+});
parent: '',
},
+ url: function(){
+ return appAccountUrl + '?model=' + this.id;
+ },
+
+ sync: function( method, model ){
+ // console.log( 'sync in model' );
+ // console.log( method );
+ // console.log( model );
+ switch ( method ) {
+ case 'delete':
+ console.log( 'Delete called in account model' );
+ break;
+ }
+ return false; //Backbone.sync.apply(this, arguments);
+
+ },
+
initialize: function(){
this.on( 'invalid', function( model, error ){
console.log( error );
}
},
+ // save: function( model, options ){
+ // console.log( 'Save called on model account' );
+ // console.log( this );
+ // console.log( model );
+ // console.log( options );
+ // get the localStorage item and update it
+ // localStorage.setItem(
+ // 'Account-' + this.parent + '-'+ this.id,
+ // JSON.stringify({id: this.id, email: this.email, parent: this.parent})
+ // );
+ // },
+
});
// js/models/accountDetail.js
}
});
+app.Models.Front.Cart = Backbone.Model.extend({
+ defaults: {
+ name: 'cart',
+ },
+
+ initialize: function(){
+ this.events = new app.Collections.Front.RegEvents;
+ },
+});
+
// js/models/login.js
// Login Model
model: app.Models.Front.Account,
initialize: function( parent ){
- console.log( 'initialize called with ' + parent );
this.parent = parent;
},
- localStorage: new Backbone.LocalStorage( 'Accounts-' ),
+ //localStorage: new Backbone.LocalStorage( 'Accounts-' ),
+
+ urlBase: function(){
+ return appAccountUrl;
+ },
+
+ // sync: function( method, model, options ){
+ // console.log('sync called on collection. method: ' + method );
+ // //console.log( method );
+ // switch( method ){
+ // case 'create':
+ // console.log('Create called on Accounts' + model);
+ // break;
+ // case 'read':
+ // console.log('Read called on Accounts' + model);
+ // break;
+ // case 'update':
+ // console.log('Update called on Accounts' + model);
+ // break;
+ // case 'delete':
+ // console.log('Delete called on Accounts' + model);
+ // break;
+ // }
+ //
+ // },
- sync: function( method, model, options ){
- return;
- //console.log('sync called on collection. method: ' + method );
- //console.log( method );
- switch( method ){
- case 'create':
- console.log('Create called on Accounts' + model);
- break;
- case 'read':
- console.log('Read called on Accounts' + model);
- break;
- case 'update':
- console.log('Update called on Accounts' + model);
- break;
- case 'delete':
- console.log('Delete called on Accounts' + model);
- break;
- }
+ create: function( model ){
+ localStorage.setItem('Account-' + model.parent + '-'+ model.id, JSON.stringify( model ) );
+ this.add( model );
+ },
+ remove: function( model ){
+ localStorage.removeItem( localStorage.key('Account-' + model.parent + '-'+ model.id ) );
+ console.log( 'Delete called in collection ' );
},
- create: function( model ){
- localStorage.setItem('Account-' + model.parent + '-'+ model.id, JSON.stringify( model ) );
+ read: function(){
+ console.log( 'Read called' );
},
+ // save: function(){
+ // console.log('Update Called');
+ // },
+
fetch: function(){
var newModels = [];
for ( var i = 0; i < localStorage.length; i++ ) {
});
+app.Collections.Front.RegEvents = Backbone.Collection.extend({
+ model: app.Models.Front.RegEvent,
+
+ initialize: function(){
+ // something here
+ },
+
+ urlBase: function(){
+ return appAccountUrl;
+ },
+
+ create: function( model ){},
+
+ remove: function( model ){},
+
+ read: function(){},
+
+ update: function(){},
+
+ fetch: function(){
+ // something here for the fetch
+ },
+});
+
// js/collections/regRates.js
// Registration Rate Collection
initialize: function(){
this.listenTo( this.model, 'change', this.render );
- this.listenTo( this.model, 'destroy', this.remove );
+ //this.listenTo( this.model, 'destroy', this.remove );
return this;
},
deleteOne: function(){
//console.log( this.model );
- var regClass = this.model.get('parent');
- console.log( regClass );
this.model.destroy();
- //regClass.trigger('change');
+ this.remove();
},
edit: function(){
});
// js/views/regClass.js
-
+var newId = 0;
app.Views.Front.RegClass = Backbone.View.extend({
tagName: 'div',
this.listenTo( this.model.accounts, 'create', this.addOne );
this.listenTo( this.model.accounts, 'reset', this.addAll );
this.listenTo( this.model, 'change', this.updateCount );
- //this.listenTo( this.model, 'change', this.render );
- //this.listenTo( this.model, 'change:accounts', this.render );
this.model.accounts.fetch();
return this;
},
+ deleteOne: function(){
+ console.log( 'Delete called' );
+ //console.log( event );
+ },
+
events: {
'click .addRegistrant': 'newEntry',
+ //'click .glm-reg-level-registrant-delete': 'deleteOne',
},
// For the new entry check the email from the server and see
this.model.trigger('change');
this.$newEmail.val('');
} else if ( account.email !== undefined ) {
+ // use the dummy id
+ newId++;
this.model.accounts.create({
+ id: 'new_' + newId,
email: account.email,
parent: this.model.id
});
},
render: function(){
+ this.model.set({ reg_count: this.model.accounts.length });
this.$el.html( this.template( this.model.toJSON() ) );
// Need to see if this class has attendees and render them
var view = this.model.accounts.map(function(item){
parent: '',
},
+ url: function(){
+ return appAccountUrl + '?model=' + this.id;
+ },
+
+ sync: function( method, model ){
+ // console.log( 'sync in model' );
+ // console.log( method );
+ // console.log( model );
+ switch ( method ) {
+ case 'delete':
+ console.log( 'Delete called in account model' );
+ break;
+ }
+ return false; //Backbone.sync.apply(this, arguments);
+
+ },
+
initialize: function(){
this.on( 'invalid', function( model, error ){
console.log( error );
}
},
- delete: function( model ){
- console.log( 'Model delete called ' );
- console.log( model );
- },
+ // save: function( model, options ){
+ // console.log( 'Save called on model account' );
+ // console.log( this );
+ // console.log( model );
+ // console.log( options );
+ // get the localStorage item and update it
+ // localStorage.setItem(
+ // 'Account-' + this.parent + '-'+ this.id,
+ // JSON.stringify({id: this.id, email: this.email, parent: this.parent})
+ // );
+ // },
});
--- /dev/null
+app.Models.Front.Cart = Backbone.Model.extend({
+ defaults: {
+ name: 'cart',
+ },
+
+ initialize: function(){
+ this.events = new app.Collections.Front.RegEvents;
+ },
+});
initialize: function(){
this.listenTo( this.model, 'change', this.render );
- this.listenTo( this.model, 'destroy', this.remove );
+ //this.listenTo( this.model, 'destroy', this.remove );
return this;
},
deleteOne: function(){
//console.log( this.model );
- var regClass = this.model.get('parent');
- console.log( regClass );
this.model.destroy();
- //regClass.trigger('change');
+ this.remove();
},
edit: function(){
// js/views/regClass.js
-
+var newId = 0;
app.Views.Front.RegClass = Backbone.View.extend({
tagName: 'div',
this.listenTo( this.model.accounts, 'create', this.addOne );
this.listenTo( this.model.accounts, 'reset', this.addAll );
this.listenTo( this.model, 'change', this.updateCount );
- //this.listenTo( this.model, 'change', this.render );
- //this.listenTo( this.model, 'change:accounts', this.render );
this.model.accounts.fetch();
return this;
},
+ deleteOne: function(){
+ console.log( 'Delete called' );
+ //console.log( event );
+ },
+
events: {
'click .addRegistrant': 'newEntry',
+ //'click .glm-reg-level-registrant-delete': 'deleteOne',
},
// For the new entry check the email from the server and see
this.model.trigger('change');
this.$newEmail.val('');
} else if ( account.email !== undefined ) {
+ // use the dummy id
+ newId++;
this.model.accounts.create({
+ id: 'new_' + newId,
email: account.email,
parent: this.model.id
});
},
render: function(){
+ this.model.set({ reg_count: this.model.accounts.length });
this.$el.html( this.template( this.model.toJSON() ) );
// Need to see if this class has attendees and render them
var view = this.model.accounts.map(function(item){
public function modelAction($actionData = false)
{
$scripts = array(
- 'backbone-local' => 'js/lib/backbone.localStorage.min.js',
+ //'backbone-local' => 'js/lib/backbone.localStorage.min.js',
'regApp' => 'js/frontRegApp.js',
);
foreach ( $scripts as $scriptName => $scriptPath ) {
{* And create the RegClasses collection *}
<script>
var appLoginUrl = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=login';
+var appAccountUrl = '{$ajaxUrl}?action=glm_members_admin_ajax&glm_action=account';
var ajaxUrl = '{$ajaxUrl}?action=glm_members_admin_ajax';
var app = {
Models: { Front: {}, Admin: {} },