Updating the front end to use the limit for attendee per reg.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 16 May 2018 15:18:08 +0000 (11:18 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 16 May 2018 15:22:38 +0000 (11:22 -0400)
Using the attendee_max_per_reg. if not 0.

js/frontRegApp.js
js/models/front/regEvent.js
js/views/front/regRequestRegistrant.js
js/views/front/regTime.js
views/front/registrations/registration.html

index ac1067b..c7bc321 100644 (file)
@@ -185,7 +185,7 @@ app.Models.Front.RegEvent = Backbone.Model.extend({
                     nRegTime.save();
                     // console.log(nRegTime);
                     // console.log('total registrants: ' + nRegTime.registrants.length);
-
+                    app.attendeeCount++;
                 }
 
             }
@@ -887,6 +887,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
         // Need to release the lock if they want to delete the attendee
         app.regEventLock = false;
 
+        // Delete the count
+        app.attendeeCount--;
+
         this.remove();
     },
 
@@ -940,6 +943,10 @@ app.Views.Front.RegTime = Backbone.View.extend({
 
     // add new account
     addNewAccount: function(){
+        if ( app.checkForMaxAttendees() === true ) {
+            alert( 'You\'re only allowed to have ' + app.attendeeMaxPerReg + ' ' + app.attendeePlurCapTerm + ' per Registration!' );
+            return;
+        }
         // check for the lock
         if ( app.checkForEditLock() === true ) {
             return;
@@ -996,12 +1003,12 @@ app.Views.Front.RegTime = Backbone.View.extend({
             return;
         }
         if ( email === '' ) {
-            var confAnsw = confirm( 'You did not supply an Email address! Are you sure you want to add this registrant?' );
-            if ( !confAnsw ) {
-                // Hide the loading graphic
-                this.$('#loading-' + this.model.get('id') ).hide();
-                return;
-            }
+            // var confAnsw = confirm( 'You did not supply and Email address! Are you sure you want to add this registrant?' );
+            // if ( !confAnsw ) {
+            //     // Hide the loading graphic
+            //     this.$('#loading-' + this.model.get('id') ).hide();
+            //     return;
+            // }
         } else {
             findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname});
             if ( findByEmail.length > 0 ) {
@@ -1046,6 +1053,9 @@ app.Views.Front.RegTime = Backbone.View.extend({
         this.newRegAccount.destroy();
         this.newRegAccountView.remove();
         app.regEventLock = false;
+
+        // Add the count
+        app.attendeeCount++;
     },
 
     successCallback: function( collection, repsonse ){
index e6d181d..ed7ec23 100644 (file)
@@ -69,7 +69,7 @@ app.Models.Front.RegEvent = Backbone.Model.extend({
                     nRegTime.save();
                     // console.log(nRegTime);
                     // console.log('total registrants: ' + nRegTime.registrants.length);
-
+                    app.attendeeCount++;
                 }
 
             }
index 296cbdf..bb13ba6 100644 (file)
@@ -141,6 +141,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
         // Need to release the lock if they want to delete the attendee
         app.regEventLock = false;
 
+        // Delete the count
+        app.attendeeCount--;
+
         this.remove();
     },
 
index c4e9392..c10f18f 100644 (file)
@@ -46,6 +46,10 @@ app.Views.Front.RegTime = Backbone.View.extend({
 
     // add new account
     addNewAccount: function(){
+        if ( app.checkForMaxAttendees() === true ) {
+            alert( 'You\'re only allowed to have ' + app.attendeeMaxPerReg + ' ' + app.attendeePlurCapTerm + ' per Registration!' );
+            return;
+        }
         // check for the lock
         if ( app.checkForEditLock() === true ) {
             return;
@@ -102,12 +106,12 @@ app.Views.Front.RegTime = Backbone.View.extend({
             return;
         }
         if ( email === '' ) {
-            var confAnsw = confirm( 'You did not supply and Email address! Are you sure you want to add this registrant?' );
-            if ( !confAnsw ) {
-                // Hide the loading graphic
-                this.$('#loading-' + this.model.get('id') ).hide();
-                return;
-            }
+            // var confAnsw = confirm( 'You did not supply and Email address! Are you sure you want to add this registrant?' );
+            // if ( !confAnsw ) {
+            //     // Hide the loading graphic
+            //     this.$('#loading-' + this.model.get('id') ).hide();
+            //     return;
+            // }
         } else {
             findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname});
             if ( findByEmail.length > 0 ) {
@@ -152,6 +156,9 @@ app.Views.Front.RegTime = Backbone.View.extend({
         this.newRegAccount.destroy();
         this.newRegAccountView.remove();
         app.regEventLock = false;
+
+        // Add the count
+        app.attendeeCount++;
     },
 
     successCallback: function( collection, repsonse ){
index 2cea7db..0c963c8 100644 (file)
             {$reg_bulletin}
         </div>
     {/if}
-    
+
   {if $settings.reg_not_submitted_dialog}
     <div id="regNotSubmittedDialog" title="PLEASE NOTE!">
         <p class="glm-reg-warning">
@@ -485,6 +485,21 @@ var app = {
         return regex.test(email);
     },
     regEventLock: false,
+    attendeeCount: 0,
+    attendeeMaxPerReg: parseInt( {$regEvent.attendee_max_per_reg} ),
+    attendeePlurCapTerm: '{$terms.reg_term_attendee_plur_cap}',
+    checkForMaxAttendees: function(){
+        if ( app.attendeeMaxPerReg ) {
+            // Here we need to see how many registrants total in each class.
+            if ( app.attendeeCount >= app.attendeeMaxPerReg ) {
+                return true;
+            } else {
+                return false;
+            }
+        } else {
+            return false;
+        }
+    },
     checkForEditLock: function(){
         if ( app.regEventLock === true ) {
             alert('Please complete your other edit first.');
@@ -661,7 +676,7 @@ jQuery(function($){
 
 
     // Registration not submitted Dialog actions
-    {if $settings.reg_not_submitted_dialog}    
+    {if $settings.reg_not_submitted_dialog}
 
       var notSubmittedTimer;
       notSubmittedDialog = $( "#regNotSubmittedDialog" ).dialog({
@@ -670,7 +685,7 @@ jQuery(function($){
           open: function(event,ui) {
               clearInterval(notSubmittedTimer);
           },
-          close: function(event,ui) { 
+          close: function(event,ui) {
               resetNotSubmittedTimer();
           },
           buttons: [
@@ -703,7 +718,7 @@ jQuery(function($){
       });
       startNotSubmittedTimer();
 
-    {/if}  
-   
+    {/if}
+
 });
 </script>