| 
				
			 | 
			
			
				@@ -13,55 +13,55 @@ function setup_handlers() 
			 | 
		
	
		
			
			| 
				13
			 | 
			
				13
			 | 
			
			
				 // Creates an AJAX-request and registers the appropriate handlers once it is done. 
			 | 
		
	
		
			
			| 
				14
			 | 
			
				14
			 | 
			
			
				 function change_presence(e) 
			 | 
		
	
		
			
			| 
				15
			 | 
			
				15
			 | 
			
			
				 { 
			 | 
		
	
		
			
			| 
				16
			 | 
			
				
			 | 
			
			
				-	// Gather data 
			 | 
		
	
		
			
			| 
				17
			 | 
			
				
			 | 
			
			
				-	var group, person, activity, state; 
			 | 
		
	
		
			
			| 
				18
			 | 
			
				
			 | 
			
			
				-	group 	 = this.dataset["groupId"]; 
			 | 
		
	
		
			
			| 
				19
			 | 
			
				
			 | 
			
			
				-	person   = this.dataset["personId"]; 
			 | 
		
	
		
			
			| 
				20
			 | 
			
				
			 | 
			
			
				-	activity = this.dataset["activityId"]; 
			 | 
		
	
		
			
			| 
				21
			 | 
			
				
			 | 
			
			
				-	rstate 	 = this.dataset["newState"]; 
			 | 
		
	
		
			
			| 
				22
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				23
			 | 
			
				
			 | 
			
			
				-	var state; 
			 | 
		
	
		
			
			| 
				24
			 | 
			
				
			 | 
			
			
				-	switch (rstate) 
			 | 
		
	
		
			
			| 
				25
			 | 
			
				
			 | 
			
			
				-	{ 
			 | 
		
	
		
			
			| 
				26
			 | 
			
				
			 | 
			
			
				-		case "present": 
			 | 
		
	
		
			
			| 
				27
			 | 
			
				
			 | 
			
			
				-			state = true; 
			 | 
		
	
		
			
			| 
				28
			 | 
			
				
			 | 
			
			
				-			break; 
			 | 
		
	
		
			
			| 
				29
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				30
			 | 
			
				
			 | 
			
			
				-		case "absent": 
			 | 
		
	
		
			
			| 
				31
			 | 
			
				
			 | 
			
			
				-			state = false; 
			 | 
		
	
		
			
			| 
				32
			 | 
			
				
			 | 
			
			
				-			break; 
			 | 
		
	
		
			
			| 
				33
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				34
			 | 
			
				
			 | 
			
			
				-		case "unknown": 
			 | 
		
	
		
			
			| 
				35
			 | 
			
				
			 | 
			
			
				-			state = null; 
			 | 
		
	
		
			
			| 
				36
			 | 
			
				
			 | 
			
			
				-			break; 
			 | 
		
	
		
			
			| 
				37
			 | 
			
				
			 | 
			
			
				-	} 
			 | 
		
	
		
			
			| 
				38
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				39
			 | 
			
				
			 | 
			
			
				-	// Make request 
			 | 
		
	
		
			
			| 
				40
			 | 
			
				
			 | 
			
			
				-	var req; 
			 | 
		
	
		
			
			| 
				41
			 | 
			
				
			 | 
			
			
				-	req = $.ajax(`/groups/${group}/activities/${activity}/presence`, 
			 | 
		
	
		
			
			| 
				42
			 | 
			
				
			 | 
			
			
				-		{ 
			 | 
		
	
		
			
			| 
				43
			 | 
			
				
			 | 
			
			
				-		  method: 'PUT', 
			 | 
		
	
		
			
			| 
				44
			 | 
			
				
			 | 
			
			
				-		  data: {person_id: person, attending: state}, 
			 | 
		
	
		
			
			| 
				45
			 | 
			
				
			 | 
			
			
				-		  statusCode: { 
			 | 
		
	
		
			
			| 
				46
			 | 
			
				
			 | 
			
			
				-			423: function() { 
			 | 
		
	
		
			
			| 
				47
			 | 
			
				
			 | 
			
			
				-				alert( "De deadline is al verstreken! Vraag orgi of bestuur of het nog kan."); 
			 | 
		
	
		
			
			| 
				48
			 | 
			
				
			 | 
			
			
				-			}, 
			 | 
		
	
		
			
			| 
				49
			 | 
			
				
			 | 
			
			
				-			403: function() { 
			 | 
		
	
		
			
			| 
				50
			 | 
			
				
			 | 
			
			
				-				alert( "Je hebt geen rechten om iemand anders aan te passen!"); 
			 | 
		
	
		
			
			| 
				51
			 | 
			
				
			 | 
			
			
				-			} 
			 | 
		
	
		
			
			| 
				52
			 | 
			
				
			 | 
			
			
				-		  } 
			 | 
		
	
		
			
			| 
				53
			 | 
			
				
			 | 
			
			
				-		} 
			 | 
		
	
		
			
			| 
				54
			 | 
			
				
			 | 
			
			
				-	) 
			 | 
		
	
		
			
			| 
				55
			 | 
			
				
			 | 
			
			
				-	.done( activity_changed ); 
			 | 
		
	
		
			
			| 
				56
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				57
			 | 
			
				
			 | 
			
			
				-	// Pack data for success 
			 | 
		
	
		
			
			| 
				58
			 | 
			
				
			 | 
			
			
				-	req.aardbei_activity_data = 
			 | 
		
	
		
			
			| 
				59
			 | 
			
				
			 | 
			
			
				-		{ 
			 | 
		
	
		
			
			| 
				60
			 | 
			
				
			 | 
			
			
				-			group: group, 
			 | 
		
	
		
			
			| 
				61
			 | 
			
				
			 | 
			
			
				-			person: person, 
			 | 
		
	
		
			
			| 
				62
			 | 
			
				
			 | 
			
			
				-			activity: activity, 
			 | 
		
	
		
			
			| 
				63
			 | 
			
				
			 | 
			
			
				-			state: state 
			 | 
		
	
		
			
			| 
				64
			 | 
			
				
			 | 
			
			
				-		}; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				16
			 | 
			
			
				+    // Gather data 
			 | 
		
	
		
			
			| 
				
			 | 
			
				17
			 | 
			
			
				+    var group, person, activity, state; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				18
			 | 
			
			
				+    group    = this.dataset["groupId"]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				19
			 | 
			
			
				+    person   = this.dataset["personId"]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				20
			 | 
			
			
				+    activity = this.dataset["activityId"]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				21
			 | 
			
			
				+    rstate   = this.dataset["newState"]; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				22
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				23
			 | 
			
			
				+    var state; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				24
			 | 
			
			
				+    switch (rstate) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				25
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				26
			 | 
			
			
				+        case "present": 
			 | 
		
	
		
			
			| 
				
			 | 
			
				27
			 | 
			
			
				+            state = true; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				28
			 | 
			
			
				+            break; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				29
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				30
			 | 
			
			
				+        case "absent": 
			 | 
		
	
		
			
			| 
				
			 | 
			
				31
			 | 
			
			
				+            state = false; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				32
			 | 
			
			
				+            break; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				33
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				34
			 | 
			
			
				+        case "unknown": 
			 | 
		
	
		
			
			| 
				
			 | 
			
				35
			 | 
			
			
				+            state = null; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				36
			 | 
			
			
				+            break; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				37
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				38
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				39
			 | 
			
			
				+    // Make request 
			 | 
		
	
		
			
			| 
				
			 | 
			
				40
			 | 
			
			
				+    var req; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				41
			 | 
			
			
				+    req = $.ajax(`/groups/${group}/activities/${activity}/presence`, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				42
			 | 
			
			
				+        { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				43
			 | 
			
			
				+          method: 'PUT', 
			 | 
		
	
		
			
			| 
				
			 | 
			
				44
			 | 
			
			
				+          data: {person_id: person, attending: state}, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				45
			 | 
			
			
				+          statusCode: { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				46
			 | 
			
			
				+            423: function() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				47
			 | 
			
			
				+                alert( "De deadline is al verstreken! Vraag orgi of bestuur of het nog kan."); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				48
			 | 
			
			
				+            }, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				49
			 | 
			
			
				+            403: function() { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				50
			 | 
			
			
				+                alert( "Je hebt geen rechten om iemand anders aan te passen!"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				51
			 | 
			
			
				+            } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				52
			 | 
			
			
				+          } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				53
			 | 
			
			
				+        } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				54
			 | 
			
			
				+    ) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				55
			 | 
			
			
				+    .done( activity_changed ); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				56
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				57
			 | 
			
			
				+    // Pack data for success 
			 | 
		
	
		
			
			| 
				
			 | 
			
				58
			 | 
			
			
				+    req.aardbei_activity_data = 
			 | 
		
	
		
			
			| 
				
			 | 
			
				59
			 | 
			
			
				+        { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				60
			 | 
			
			
				+            group: group, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				61
			 | 
			
			
				+            person: person, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				62
			 | 
			
			
				+            activity: activity, 
			 | 
		
	
		
			
			| 
				
			 | 
			
				63
			 | 
			
			
				+            state: state 
			 | 
		
	
		
			
			| 
				
			 | 
			
				64
			 | 
			
			
				+        }; 
			 | 
		
	
		
			
			| 
				65
			 | 
			
				65
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				66
			 | 
			
				66
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				67
			 | 
			
				67
			 | 
			
			
				 // Update all references on the page to this activity: 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -69,40 +69,40 @@ function change_presence(e) 
			 | 
		
	
		
			
			| 
				69
			 | 
			
				69
			 | 
			
			
				 // 2. The present/absent buttons 
			 | 
		
	
		
			
			| 
				70
			 | 
			
				70
			 | 
			
			
				 function activity_changed(data, textStatus, xhr) 
			 | 
		
	
		
			
			| 
				71
			 | 
			
				71
			 | 
			
			
				 { 
			 | 
		
	
		
			
			| 
				72
			 | 
			
				
			 | 
			
			
				-	// Unpack activity-data 
			 | 
		
	
		
			
			| 
				73
			 | 
			
				
			 | 
			
			
				-	var target; 
			 | 
		
	
		
			
			| 
				74
			 | 
			
				
			 | 
			
			
				-	target = xhr.aardbei_activity_data; 
			 | 
		
	
		
			
			| 
				75
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				76
			 | 
			
				
			 | 
			
			
				-	// Determine what color and icons we're going to use 
			 | 
		
	
		
			
			| 
				77
			 | 
			
				
			 | 
			
			
				-	var new_rowclass; 
			 | 
		
	
		
			
			| 
				78
			 | 
			
				
			 | 
			
			
				-	var new_confirm_icon, new_decline_icon; 
			 | 
		
	
		
			
			| 
				79
			 | 
			
				
			 | 
			
			
				-	switch (target.state) 
			 | 
		
	
		
			
			| 
				80
			 | 
			
				
			 | 
			
			
				-	{ 
			 | 
		
	
		
			
			| 
				81
			 | 
			
				
			 | 
			
			
				-		case true: 
			 | 
		
	
		
			
			| 
				82
			 | 
			
				
			 | 
			
			
				-			new_rowclass = "success"; 
			 | 
		
	
		
			
			| 
				83
			 | 
			
				
			 | 
			
			
				-			new_confirm_icon = check_selected; 
			 | 
		
	
		
			
			| 
				84
			 | 
			
				
			 | 
			
			
				-			new_decline_icon = times_unselected; 
			 | 
		
	
		
			
			| 
				85
			 | 
			
				
			 | 
			
			
				-			break; 
			 | 
		
	
		
			
			| 
				86
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				87
			 | 
			
				
			 | 
			
			
				-		case false: 
			 | 
		
	
		
			
			| 
				88
			 | 
			
				
			 | 
			
			
				-			new_rowclass = "danger"; 
			 | 
		
	
		
			
			| 
				89
			 | 
			
				
			 | 
			
			
				-			new_confirm_icon = check_unselected; 
			 | 
		
	
		
			
			| 
				90
			 | 
			
				
			 | 
			
			
				-			new_decline_icon = times_selected; 
			 | 
		
	
		
			
			| 
				91
			 | 
			
				
			 | 
			
			
				-			break; 
			 | 
		
	
		
			
			| 
				92
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				93
			 | 
			
				
			 | 
			
			
				-		case null: 
			 | 
		
	
		
			
			| 
				94
			 | 
			
				
			 | 
			
			
				-			new_rowclass = "warning"; 
			 | 
		
	
		
			
			| 
				95
			 | 
			
				
			 | 
			
			
				-			new_confirm_icon = check_unselected; 
			 | 
		
	
		
			
			| 
				96
			 | 
			
				
			 | 
			
			
				-			new_decline_icon = times_unselected; 
			 | 
		
	
		
			
			| 
				97
			 | 
			
				
			 | 
			
			
				-			break; 
			 | 
		
	
		
			
			| 
				98
			 | 
			
				
			 | 
			
			
				-	} 
			 | 
		
	
		
			
			| 
				99
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				100
			 | 
			
				
			 | 
			
			
				-	// Update all tr's containing this person's presence 
			 | 
		
	
		
			
			| 
				101
			 | 
			
				
			 | 
			
			
				-	$(`tr[data-person-id=${target.person}][data-activity-id=${target.activity}]`) 
			 | 
		
	
		
			
			| 
				102
			 | 
			
				
			 | 
			
			
				-	  .removeClass('success danger warning') 
			 | 
		
	
		
			
			| 
				103
			 | 
			
				
			 | 
			
			
				-	  .addClass(new_rowclass); 
			 | 
		
	
		
			
			| 
				104
			 | 
			
				
			 | 
			
			
				- 
			 | 
		
	
		
			
			| 
				105
			 | 
			
				
			 | 
			
			
				-	// Update all buttons for this person's presence 
			 | 
		
	
		
			
			| 
				
			 | 
			
				72
			 | 
			
			
				+    // Unpack activity-data 
			 | 
		
	
		
			
			| 
				
			 | 
			
				73
			 | 
			
			
				+    var target; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				74
			 | 
			
			
				+    target = xhr.aardbei_activity_data; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				75
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				76
			 | 
			
			
				+    // Determine what color and icons we're going to use 
			 | 
		
	
		
			
			| 
				
			 | 
			
				77
			 | 
			
			
				+    var new_rowclass; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				78
			 | 
			
			
				+    var new_confirm_icon, new_decline_icon; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				79
			 | 
			
			
				+    switch (target.state) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				80
			 | 
			
			
				+    { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				81
			 | 
			
			
				+        case true: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				82
			 | 
			
			
				+            new_rowclass = "success"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				83
			 | 
			
			
				+            new_confirm_icon = check_selected; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				84
			 | 
			
			
				+            new_decline_icon = times_unselected; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				85
			 | 
			
			
				+            break; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				86
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				87
			 | 
			
			
				+        case false: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				88
			 | 
			
			
				+            new_rowclass = "danger"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				89
			 | 
			
			
				+            new_confirm_icon = check_unselected; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				90
			 | 
			
			
				+            new_decline_icon = times_selected; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				91
			 | 
			
			
				+            break; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				92
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				93
			 | 
			
			
				+        case null: 
			 | 
		
	
		
			
			| 
				
			 | 
			
				94
			 | 
			
			
				+            new_rowclass = "warning"; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				95
			 | 
			
			
				+            new_confirm_icon = check_unselected; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				96
			 | 
			
			
				+            new_decline_icon = times_unselected; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				97
			 | 
			
			
				+            break; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				98
			 | 
			
			
				+    } 
			 | 
		
	
		
			
			| 
				
			 | 
			
				99
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				100
			 | 
			
			
				+    // Update all tr's containing this person's presence 
			 | 
		
	
		
			
			| 
				
			 | 
			
				101
			 | 
			
			
				+    $(`tr[data-person-id=${target.person}][data-activity-id=${target.activity}]`) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				102
			 | 
			
			
				+      .removeClass('success danger warning') 
			 | 
		
	
		
			
			| 
				
			 | 
			
				103
			 | 
			
			
				+      .addClass(new_rowclass); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				104
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				105
			 | 
			
			
				+    // Update all buttons for this person's presence 
			 | 
		
	
		
			
			| 
				106
			 | 
			
				106
			 | 
			
			
				     $(`.btn-present[data-person-id=${target.person}][data-activity-id=${target.activity}]`) 
			 | 
		
	
		
			
			| 
				107
			 | 
			
				107
			 | 
			
			
				       .html(new_confirm_icon); 
			 | 
		
	
		
			
			| 
				108
			 | 
			
				108
			 | 
			
			
				     $(`.btn-absent[data-person-id=${target.person}][data-activity-id=${target.activity}]`) 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -113,11 +113,14 @@ function activity_changed(data, textStatus, xhr) 
			 | 
		
	
		
			
			| 
				113
			 | 
			
				113
			 | 
			
			
				       .append(" Present"); 
			 | 
		
	
		
			
			| 
				114
			 | 
			
				114
			 | 
			
			
				     $(`.btn-absent[data-person-id=${target.person}][data-activity-id=${target.activity}][data-wide=1]`) 
			 | 
		
	
		
			
			| 
				115
			 | 
			
				115
			 | 
			
			
				       .append(" Absent"); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				116
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				117
			 | 
			
			
				+    if (window.updatecounts != undefined) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				118
			 | 
			
			
				+        updatecounts(window.subgroupfilter); 
			 | 
		
	
		
			
			| 
				116
			 | 
			
				119
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				117
			 | 
			
				120
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				118
			 | 
			
				121
			 | 
			
			
				 function alert_failure(data, textStatus, xhr) 
			 | 
		
	
		
			
			| 
				119
			 | 
			
				122
			 | 
			
			
				 { 
			 | 
		
	
		
			
			| 
				120
			 | 
			
				
			 | 
			
			
				-	alert(`Something broke! We got a ${textStatus}, (${data}).`); 
			 | 
		
	
		
			
			| 
				
			 | 
			
				123
			 | 
			
			
				+    alert(`Something broke! We got a ${textStatus}, (${data}).`); 
			 | 
		
	
		
			
			| 
				121
			 | 
			
				124
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				122
			 | 
			
				125
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				123
			 | 
			
				126
			 | 
			
			
				 var check_unselected = '<i class="fa fa-check"></i>'; 
			 |