From da82a53d2f456987b9b7babf24c7b93da9960108 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 7 Nov 2017 09:06:51 -0500 Subject: [PATCH] Work on add registrant to more than one time slot. Now can add a registrant to more than one time slot. Also setting up comparator function for the times and the registrant collections. This will keep them sorted. --- js/adminRegApp.js | 2 +- js/collections/admin/regRates.js | 2 +- js/collections/front/regRequestRegistrants.js | 11 +++++++-- js/collections/front/regTimes.js | 12 +++++++++- js/frontRegApp.js | 24 ++++++++++++++++--- js/views/front/regClass.js | 1 + models/admin/ajax/regFront/registrant.php | 6 +++-- 7 files changed, 48 insertions(+), 10 deletions(-) diff --git a/js/adminRegApp.js b/js/adminRegApp.js index 39f7f88..4a41417 100644 --- a/js/adminRegApp.js +++ b/js/adminRegApp.js @@ -97,7 +97,7 @@ app.Collections.Admin.RegRates = Backbone.Collection.extend({ if ( r1 > r2 ) { return -1; } else if ( r1 == r2 ) { - return 0 + return 0; } else { return 1; } diff --git a/js/collections/admin/regRates.js b/js/collections/admin/regRates.js index 52fc1ec..da3bbf6 100644 --- a/js/collections/admin/regRates.js +++ b/js/collections/admin/regRates.js @@ -10,7 +10,7 @@ app.Collections.Admin.RegRates = Backbone.Collection.extend({ if ( r1 > r2 ) { return -1; } else if ( r1 == r2 ) { - return 0 + return 0; } else { return 1; } diff --git a/js/collections/front/regRequestRegistrants.js b/js/collections/front/regRequestRegistrants.js index 2e4e218..1485022 100644 --- a/js/collections/front/regRequestRegistrants.js +++ b/js/collections/front/regRequestRegistrants.js @@ -1,6 +1,13 @@ app.Collections.Front.RegRequestRegistrants = Backbone.Collection.extend({ model: app.Models.Front.RegRequestRegistrant, - url: ajaxUrl+'&glm_action=regFront&collection=registrant=', - + comparator: function(reg1, reg2){ + if ( reg1.get('lname') < reg2.get('lname') ) { + return -1; + } else if ( reg1.get('lname') == reg2.get('lname') ) { + return 0; + } else { + return 1; + } + }, }); diff --git a/js/collections/front/regTimes.js b/js/collections/front/regTimes.js index 3ef9dab..93dd379 100644 --- a/js/collections/front/regTimes.js +++ b/js/collections/front/regTimes.js @@ -3,6 +3,16 @@ // reg time collection app.Collections.Front.RegTimes = Backbone.Collection.extend({ model: app.Models.Front.RegTime, - url: ajaxUrl+'&glm_action=regFront&collection=regTime=', + comparator: function(regTime1, regTime2){ + var time1 = regTime1.get('start_datetime'); + var time2 = regTime2.get('start_datetime'); + if ( time1.timestamp < time2.timestamp ) { + return -1; + } else if ( time1.timestamp == time2.timestamp ) { + return 0; + } else { + return 1; + } + }, }); diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 3e7c602..2fffb04 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -373,9 +373,16 @@ app.Collections.Front.RegRates = Backbone.Collection.extend({ app.Collections.Front.RegRequestRegistrants = Backbone.Collection.extend({ model: app.Models.Front.RegRequestRegistrant, - url: ajaxUrl+'&glm_action=regFront&collection=registrant=', - + comparator: function(reg1, reg2){ + if ( reg1.get('lname') < reg2.get('lname') ) { + return -1; + } else if ( reg1.get('lname') == reg2.get('lname') ) { + return 0; + } else { + return 1; + } + }, }); // js/collections/regTimes.js @@ -383,8 +390,18 @@ app.Collections.Front.RegRequestRegistrants = Backbone.Collection.extend({ // reg time collection app.Collections.Front.RegTimes = Backbone.Collection.extend({ model: app.Models.Front.RegTime, - url: ajaxUrl+'&glm_action=regFront&collection=regTime=', + comparator: function(regTime1, regTime2){ + var time1 = regTime1.get('start_datetime'); + var time2 = regTime2.get('start_datetime'); + if ( time1.timestamp < time2.timestamp ) { + return -1; + } else if ( time1.timestamp == time2.timestamp ) { + return 0; + } else { + return 1; + } + }, }); // js/views/account.js @@ -504,6 +521,7 @@ app.Views.Front.RegClass = Backbone.View.extend({ this.$el.html( this.template( this.model.toJSON() ) ); // Go through the RegTimes Collection and render those // var view = this.model. + // this.model.regTimes.sort(); var view = this.model.regTimes.map(function(item){ return (new app.Views.Front.RegTime({ model: item })).render().el; }); diff --git a/js/views/front/regClass.js b/js/views/front/regClass.js index 34f1ab9..7a8bd04 100644 --- a/js/views/front/regClass.js +++ b/js/views/front/regClass.js @@ -55,6 +55,7 @@ app.Views.Front.RegClass = Backbone.View.extend({ this.$el.html( this.template( this.model.toJSON() ) ); // Go through the RegTimes Collection and render those // var view = this.model. + // this.model.regTimes.sort(); var view = this.model.regTimes.map(function(item){ return (new app.Views.Front.RegTime({ model: item })).render().el; }); diff --git a/models/admin/ajax/regFront/registrant.php b/models/admin/ajax/regFront/registrant.php index 469af88..6f6d75c 100644 --- a/models/admin/ajax/regFront/registrant.php +++ b/models/admin/ajax/regFront/registrant.php @@ -399,11 +399,13 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations WHERE reg_request = %d AND account = %d AND reg_request_event = %d - AND reg_request_class = %d", + AND reg_request_class = %d + AND reg_time = %d", $modelData['reg_request'], $accountId, $regRequestEventId, - $regRequestClassId + $regRequestClassId, + $modelData['reg_time'] ) ); } -- 2.17.1