diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index b2dead7..d024ed4 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -67,6 +67,8 @@ events collection Stores information about events and persons registered for a given event. +Please notice that information about a person registered for a given event is solely taken from the event.persons entry, and not to the relative entry in the persons collection. This may change in the future (to integrate missing information), but in general it is correct that, editing (or deleting) a person, older information about the partecipation to an event is not changed. + Main field: - title diff --git a/angular_app/event-info.html b/angular_app/event-info.html index 3fab01a..7e5271c 100644 --- a/angular_app/event-info.html +++ b/angular_app/event-info.html @@ -1,11 +1,27 @@
-

{{event.title}} - -

+
+
+
+

{{event.title}} + +

+
+
+
+

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

+
+
+

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

+
+
+
+
+
@@ -34,7 +50,7 @@ {{'Person' | translate}} {{'Email' | translate}} {{'Attended' | translate}} - {{'Actions' | translate}} + {{'Delete' | translate}} @@ -57,7 +73,7 @@
-
{{'Fast add' | translate}}
+
{{'Quick add' | translate}}
diff --git a/angular_app/events-list.html b/angular_app/events-list.html index 4708559..87a81fb 100644 --- a/angular_app/events-list.html +++ b/angular_app/events-list.html @@ -29,7 +29,7 @@ {{'Event' | translate}} - {{'Actions' | translate}} + {{'Delete' | translate}} diff --git a/angular_app/index.html b/angular_app/index.html index dbe19c3..9e31fc2 100644 --- a/angular_app/index.html +++ b/angular_app/index.html @@ -15,6 +15,7 @@ + diff --git a/angular_app/js/app.js b/angular_app/js/app.js index f306a10..09e8a7d 100644 --- a/angular_app/js/app.js +++ b/angular_app/js/app.js @@ -49,52 +49,6 @@ eventManApp.filter('splittedFilter', ['$filter', ); -/* Filter for events that have (or not) information about a registered person. */ -eventManApp.filter('eventWithPersonData', ['$filter', - function($filter) { - return function(inputArray, mustBePresent) { - if (mustBePresent === undefined) { - mustBePresent = true; - } - inputArray = inputArray || []; - var returnArray = []; - for (var x=0; x < inputArray.length; x++) { - var found = inputArray[x].person_data && inputArray[x].person_data.person_id; - if ((found && mustBePresent) || (!found && !mustBePresent)) { - returnArray.push(inputArray[x]); - } - } - return returnArray; - }; - }] -); - -eventManApp.filter('personRegistered', ['$filter', - function($filter) { - return function(inputArray, data) { - if (data.present === undefined) { - data.present = true; - } - inputArray = inputArray || []; - var returnArray = []; - var registeredIDs = []; - if (!(data.event && data.event.persons && data.event.persons.length)) { - return inputArray; - } - for (var x=0; x < data.event.persons.length; x++) { - registeredIDs.push(data.event.persons[x].person_id); - } - for (var x=0; x < inputArray.length; x++) { - var found = registeredIDs.indexOf(inputArray[x]._id) != -1; - if ((found && data.present) || (!found && !data.present)) { - returnArray.push(inputArray[x]); - } - } - return returnArray; - } - }] -); - /* Directive that can be used to make an input field react to the press of Enter. */ eventManApp.directive('ngEnter', function () { return function (scope, element, attrs) { diff --git a/angular_app/js/controllers.js b/angular_app/js/controllers.js index 7f15e00..2e41917 100644 --- a/angular_app/js/controllers.js +++ b/angular_app/js/controllers.js @@ -1,7 +1,7 @@ 'use strict'; /* Controllers; their method are available where specified with the ng-controller - * directive or for a given route (see app.js). They use some services to + * directive or for a given route/state (see app.js). They use some services to * connect to the backend (see services.js). */ var eventManControllers = angular.module('eventManControllers', []); @@ -57,8 +57,15 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person', function ($scope, Event, Person, $stateParams, $log) { $scope.personsOrderProp = 'name'; $scope.eventsOrderProp = '-begin-date'; + $scope.countAttendees = 0; if ($stateParams.id) { - $scope.event = Event.get($stateParams); + $scope.event = Event.get($stateParams, function() { + $scope.$watchCollection(function() { + return $scope.event.persons; + }, function(prev, old) { + $scope.calcAttendees(); + }); + }); $scope.allPersons = Person.all(); } // store a new Event or update an existing one @@ -76,6 +83,20 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', 'Person', $scope.eventForm.$dirty = false; }; + $scope.calcAttendees = function() { + if (!($scope.event && $scope.event.persons)) { + return; + } + var attendees = 0; + $log.info($scope.event.persons.length); + angular.forEach($scope.event.persons, function(value, key) { + if (value.attended) { + attendees += 1; + } + }); + $scope.countAttendees = attendees; + }; + $scope._addAttendee = function(person_data) { person_data.person_id = person_data._id; person_data._id = $stateParams.id; diff --git a/angular_app/js/filters.js b/angular_app/js/filters.js new file mode 100644 index 0000000..bf5a483 --- /dev/null +++ b/angular_app/js/filters.js @@ -0,0 +1,52 @@ +'use strict'; + +/* Filters for EventMan(ager) lists of objects. */ + +/* Filter for events that have (or not) information about a registered person. */ +eventManApp.filter('eventWithPersonData', ['$filter', + function($filter) { + return function(inputArray, mustBePresent) { + if (mustBePresent === undefined) { + mustBePresent = true; + } + inputArray = inputArray || []; + var returnArray = []; + for (var x=0; x < inputArray.length; x++) { + var found = inputArray[x].person_data && inputArray[x].person_data.person_id; + if ((found && mustBePresent) || (!found && !mustBePresent)) { + returnArray.push(inputArray[x]); + } + } + return returnArray; + }; + }] +); + + +/* Filter for persons (not) registered for a given event. */ +eventManApp.filter('personRegistered', ['$filter', + function($filter) { + return function(inputArray, data) { + if (data.present === undefined) { + data.present = true; + } + inputArray = inputArray || []; + var returnArray = []; + var registeredIDs = []; + if (!(data.event && data.event.persons && data.event.persons.length)) { + return inputArray; + } + for (var x=0; x < data.event.persons.length; x++) { + registeredIDs.push(data.event.persons[x].person_id); + } + for (var x=0; x < inputArray.length; x++) { + var found = registeredIDs.indexOf(inputArray[x]._id) != -1; + if ((found && data.present) || (!found && !data.present)) { + returnArray.push(inputArray[x]); + } + } + return returnArray; + } + }] +); + diff --git a/angular_app/persons-list.html b/angular_app/persons-list.html index 9a93d88..93f22fc 100644 --- a/angular_app/persons-list.html +++ b/angular_app/persons-list.html @@ -33,7 +33,7 @@ {{'Name' | translate}} - {{'Actions' | translate}} + {{'Delete' | translate}} diff --git a/static/css/eventman.css b/static/css/eventman.css index 4c3dd67..16d6541 100644 --- a/static/css/eventman.css +++ b/static/css/eventman.css @@ -14,5 +14,9 @@ body { padding-top: 70px; } .vcenter { vertical-align: middle; + /* display: table-cell !important; */ + display: inline-block !important; + float: none; } +/* .row { display: table; } */