From bccc0c7b745c571a56c5f58a26771a303a7e8b2a Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sun, 26 Jun 2016 16:54:08 +0200 Subject: [PATCH] fixes #138: if the ticket has the "cancelled" property, it is not considered valid --- angular_app/event-tickets.html | 4 ++-- angular_app/events-list.html | 4 ++-- angular_app/js/app.js | 2 +- angular_app/js/controllers.js | 21 ++++++++++++++++++--- angular_app/js/filters.js | 32 ++++++++++++++++++++++++++++---- angular_app/ticket-edit.html | 31 +++++++++++++++++++++++++++---- static/css/eventman.css | 4 ++++ 7 files changed, 82 insertions(+), 16 deletions(-) diff --git a/angular_app/event-tickets.html b/angular_app/event-tickets.html index c91d119..f21162c 100644 --- a/angular_app/event-tickets.html +++ b/angular_app/event-tickets.html @@ -14,7 +14,7 @@ -->
-

{{'Registered:' | translate}} {{event.persons.length || 0}}

+

{{'Registered:' | translate}} {{((event.persons || []) | registeredFilter).length}}

{{'Attendees:' | translate}} {{countAttendees}}

@@ -49,7 +49,7 @@ - + {{$index+1}}  {{person.name}} {{person.surname}}{{person.name}} {{person.surname}} <{{person.email}}> diff --git a/angular_app/events-list.html b/angular_app/events-list.html index 497a753..8029053 100644 --- a/angular_app/events-list.html +++ b/angular_app/events-list.html @@ -47,10 +47,10 @@ {{'Ends:' | translate}} {{event['end-date'] | date:'fullDate' }} {{event['end-time'] | date:'HH:mm'}}

-

{{attendeesNr}} / {{event.persons.length || 0}} ({{((attendeesNr / (event.persons.length || 0) * 100) || 0).toFixed()}}%)

+

{{attendeesNr}} / {{((event.persons || []) | registeredFilter).length}} ({{((attendeesNr / ((event.persons || []) | registeredFilter).length * 100) || 0).toFixed()}}%)

- + diff --git a/angular_app/js/app.js b/angular_app/js/app.js index d3a3028..25ba094 100644 --- a/angular_app/js/app.js +++ b/angular_app/js/app.js @@ -25,7 +25,7 @@ var eventManApp = angular.module('eventManApp', [ 'angularFileUpload', 'angular-websocket', 'eda.easyFormViewer', - 'eda.easyformGen.stepway' + 'eda.easyformGen.stepway' ]); diff --git a/angular_app/js/controllers.js b/angular_app/js/controllers.js index 0ac0d77..014493f 100644 --- a/angular_app/js/controllers.js +++ b/angular_app/js/controllers.js @@ -206,7 +206,7 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', } var attendees = 0; angular.forEach($scope.event.persons, function(value, key) { - if (value.attended) { + if (value.attended && !value.cancelled) { attendees += 1; } }); @@ -370,6 +370,7 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event', $scope.ticket = {}; $scope.formSchema = {}; $scope.formData = {}; + $scope.dangerousActionsEnabled = false; $scope.formFieldsMap = {}; $scope.formFieldsMapRev = {}; @@ -429,11 +430,15 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event', }); }; - $scope.updateTicket = function(ticket) { + $scope.updateTicket = function(ticket, cb) { var data = angular.copy(ticket); data.ticket_id = data._id; data._id = $state.params.id; - EventTicket.update(data, function(t) {}); + EventTicket.update(data, function(t) { + if (cb) { + cb(t); + } + }); }; $scope.submitForm = function(dataModelSubmitted) { @@ -448,6 +453,16 @@ eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event', } }; + $scope.toggleTicket = function() { + if (!$scope.ticket._id) { + return; + } + $scope.ticket.cancelled = !$scope.ticket.cancelled; + $scope.updateTicket($scope.ticket, function() { + $scope.dangerousActionsEnabled = false; + }); + }; + $scope.cancelForm = function() { $state.go('events'); }; diff --git a/angular_app/js/filters.js b/angular_app/js/filters.js index 1315ede..2c79f76 100644 --- a/angular_app/js/filters.js +++ b/angular_app/js/filters.js @@ -37,6 +37,9 @@ eventManApp.filter('personRegistered', ['$filter', return inputArray; } for (var x=0; x < data.event.persons.length; x++) { + if (!data.includeCancelled && data.event.persons[x].cancelled) { + continue; + } registeredIDs.push(data.event.persons[x].person_id); } for (var x=0; x < inputArray.length; x++) { @@ -65,13 +68,34 @@ eventManApp.filter('splittedFilter', ['$filter', ); -/* Filter that returns only the attendees at an event. */ -eventManApp.filter('attendeesFilter', ['$filter', +/* Filter that returns only the (not) registered persons at an event. */ +eventManApp.filter('registeredFilter', ['$filter', function($filter) { - return function(inputArray) { + return function(inputArray, data) { + if (!data) { + data = {}; + } var returnArray = []; for (var x=0; x < inputArray.length; x++) { - if (inputArray[x]['attended']) { + if ((!data.onlyCancelled && !inputArray[x]['cancelled']) || + (data.onlyCancelled && inputArray[x]['cancelled']) || + data.all) { + returnArray.push(inputArray[x]); + } + } + return returnArray; + }; + }] +); + + +/* Filter that returns only the attendees at an event. */ +eventManApp.filter('attendeesFilter', ['$filter', + function($filter) { + return function(inputArray) { + var returnArray = []; + for (var x=0; x < inputArray.length; x++) { + if (inputArray[x]['attended'] && !inputArray[x]['cancelled']) { returnArray.push(inputArray[x]); } } diff --git a/angular_app/ticket-edit.html b/angular_app/ticket-edit.html index e36da0f..67cba8d 100644 --- a/angular_app/ticket-edit.html +++ b/angular_app/ticket-edit.html @@ -4,16 +4,16 @@
-

{{event.title}} - {{'new ticket' | translate}}

+

{{event.title}} - {{'new ticket' | translate}}

-
+
-
{{'Register to this event' | translate}}
+
{{'Join this event' | translate}}
- {{'Save this URL if you want to modify your order later:'}} {{getLocation()}} + {{'Save this URL if you want to modify your order later:'}} {{getLocation()}}
@@ -32,4 +32,27 @@
+ +
+
+
+
+
{{'Dangerous stuff' | translate}}
+
+ +   + + +
+
+
+
+
diff --git a/static/css/eventman.css b/static/css/eventman.css index dd3b58a..78d0ac8 100644 --- a/static/css/eventman.css +++ b/static/css/eventman.css @@ -8,6 +8,10 @@ body { padding-top: 70px; } padding-bottom: 0px; } +a:focus a:hover { + color: #23527c; +} + a:hover { color: #23527c; }