fixes #138: if the ticket has the "cancelled" property, it is not considered valid
This commit is contained in:
parent
cab3df7c29
commit
bccc0c7b74
7 changed files with 82 additions and 16 deletions
|
@ -14,7 +14,7 @@
|
|||
--><div class="col-md-5 col-xs-5 vcenter">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h2><div class="label label-warning vcenter">{{'Registered:' | translate}} {{event.persons.length || 0}}</div></h2>
|
||||
<h2><div class="label label-warning vcenter">{{'Registered:' | translate}} {{((event.persons || []) | registeredFilter).length}}</div></h2>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h2><div class="label label-info vcenter">{{'Attendees:' | translate}} {{countAttendees}}</div></h2>
|
||||
|
@ -49,7 +49,7 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr ng-repeat="person in event.persons | splittedFilter:query | orderBy:personsOrder">
|
||||
<tr ng-repeat="person in event.persons | splittedFilter:query | registeredFilter | orderBy:personsOrder">
|
||||
<td class="text-right">{{$index+1}}</td>
|
||||
<td>
|
||||
<span><strong><a ui-sref="person.info({id: person.person_id})"><span class="fa fa-lg fa-user"></span></a> <a ui-sref="event.ticket.edit({id: event._id, ticket_id: person._id})" ng-if="person._id"><span>{{person.name}}</span> <span>{{person.surname}}</span></a></strong></span><span ng-if="!person._id"><span>{{person.name}}</span> <span>{{person.surname}}</span></a></strong></span></span><span ng-if="person.email"> <{{person.email}}></span>
|
||||
|
|
|
@ -47,10 +47,10 @@
|
|||
{{'Ends:' | translate}} {{event['end-date'] | date:'fullDate' }} {{event['end-time'] | date:'HH:mm'}}</p>
|
||||
</td>
|
||||
<td ng-if="hasPermission('persons|read')" class="hcenter">
|
||||
<p><span ng-init="attendeesNr = ((event.persons || []) | attendeesFilter).length">{{attendeesNr}}</span> / {{event.persons.length || 0}} ({{((attendeesNr / (event.persons.length || 0) * 100) || 0).toFixed()}}%)</p>
|
||||
<p><span ng-init="attendeesNr = ((event.persons || []) | attendeesFilter).length">{{attendeesNr}}</span> / {{((event.persons || []) | registeredFilter).length}} ({{((attendeesNr / ((event.persons || []) | registeredFilter).length * 100) || 0).toFixed()}}%)</p>
|
||||
</td>
|
||||
<td>
|
||||
<button ng-if="hasPermission('event:tickets|create')" ng-click="$state.go('event.ticket.new', {id: event._id})" class="btn btn-link fa fa-user-plus" type="button" title="{{'Register' | translate}}"></button>
|
||||
<button ng-if="hasPermission('event:tickets|create')" ng-click="$state.go('event.ticket.new', {id: event._id})" class="btn btn-link fa fa-user-plus" type="button" title="{{'Join this event' | translate}}"></button>
|
||||
<button ng-if="hasPermission('persons|update')" ng-click="$state.go('event.tickets', {id: event._id})" class="btn btn-link fa fa-list" type="button" title="{{'Manage attendees' | translate}}"></button>
|
||||
<button ng-if="hasPermission('event|update')" ng-click="$state.go('event.edit', {id: event._id})" type="button" class="btn btn-link fa fa-cog fa-lg" title="{{'Edit' | translate}}"></button>
|
||||
<button ng-if="hasPermission('event|delete')" ng-click="remove(event._id)" type="button" class="btn btn-link fa fa-trash fa-lg" title="{{'Delete' | translate}}"></button>
|
||||
|
|
2
angular_app/js/app.js
vendored
2
angular_app/js/app.js
vendored
|
@ -25,7 +25,7 @@ var eventManApp = angular.module('eventManApp', [
|
|||
'angularFileUpload',
|
||||
'angular-websocket',
|
||||
'eda.easyFormViewer',
|
||||
'eda.easyformGen.stepway'
|
||||
'eda.easyformGen.stepway'
|
||||
]);
|
||||
|
||||
|
||||
|
|
21
angular_app/js/controllers.js
vendored
21
angular_app/js/controllers.js
vendored
|
@ -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');
|
||||
};
|
||||
|
|
32
angular_app/js/filters.js
vendored
32
angular_app/js/filters.js
vendored
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,16 +4,16 @@
|
|||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-xs-7 vcenter">
|
||||
<h1>{{event.title}} - {{'new ticket' | translate}}</h1>
|
||||
<h1><a ui-sref="event.view({id: event._id})" ng-if="event._id">{{event.title}}</a> - {{'new ticket' | translate}}</h1>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="container" ng-if="ticket._id && !ticket.cancelled">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-info table-striped top5">
|
||||
<div class="panel-heading">{{'Register to this event' | translate}}</div>
|
||||
<div class="panel-heading">{{'Join this event' | translate}}</div>
|
||||
<div class="panel-body">
|
||||
<eda-easy-form-viewer
|
||||
eda-easy-form-viewer-data-model="formData"
|
||||
|
@ -24,7 +24,7 @@
|
|||
</eda-easy-form-viewer>
|
||||
<div ng-if="ticket._id">
|
||||
<div ng-controller="NavigationCtrl">
|
||||
<span><strong>{{'Save this URL if you want to modify your order later:'}} <a href="getLocation()">{{getLocation()}}</a></strong></span>
|
||||
<span><strong>{{'Save this URL if you want to modify your order later:'}} <a ng-href="{{getLocation()}}">{{getLocation()}}</a></strong></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -32,4 +32,27 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container" ng-if="ticket._id">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div class="panel panel-danger table-striped top5">
|
||||
<div class="panel-heading">{{'Dangerous stuff' | translate}}</div>
|
||||
<div class="panel-body">
|
||||
<button ng-click="dangerousActionsEnabled = !dangerousActionsEnabled" class="btn btn-warning">
|
||||
<span class="fa fa-exclamation-triangle vcenter"></span>
|
||||
{{'Toggle dangerous actions' | translate}}
|
||||
</button>
|
||||
|
||||
<button ng-disabled="!dangerousActionsEnabled" ng-click="toggleTicket({id: ticket._id})" class="btn btn-danger">
|
||||
<span ng-class="{fa: true, 'fa-sign-out': !ticket.cancelled, 'fa-sign-in': ticket.cancelled, vcenter: true}"></span>
|
||||
<span ng-if="!ticket.cancelled">{{'Leave this event' | translate}}</span>
|
||||
<span ng-if="ticket.cancelled">{{'Join again this event' | translate}}</span>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -8,6 +8,10 @@ body { padding-top: 70px; }
|
|||
padding-bottom: 0px;
|
||||
}
|
||||
|
||||
a:focus a:hover {
|
||||
color: #23527c;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #23527c;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue