counter of attendees
This commit is contained in:
parent
02767d44ae
commit
6940534d49
5 changed files with 51 additions and 55 deletions
|
@ -1,11 +1,27 @@
|
|||
<!-- show details of an Event -->
|
||||
<div class="container">
|
||||
<h1>{{event.title}}
|
||||
<button ng-if="event._id" ng-click="$state.go('event.edit', {id: event._id})" class="btn btn-success">
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
{{'Edit' | translate}}
|
||||
</button>
|
||||
</h1>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-3 col-xs-3 vcenter">
|
||||
<h1>{{event.title}}
|
||||
<button ng-if="event._id" ng-click="$state.go('event.edit', {id: event._id})" class="btn btn-success">
|
||||
<span class="glyphicon glyphicon-edit"></span>
|
||||
{{'Edit' | translate}}
|
||||
</button>
|
||||
</h1>
|
||||
</div><!--
|
||||
--><div class="col-md-9 col-xs-9 vcenter">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<h2><div class="label label-warning vcenter">{{'Registered:' | translate}} {{event.persons.length}}</div></h2>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<h2><div class="label label-info vcenter">{{'Attendees:' | translate}} {{countAttendees}}</div></h2>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
|
@ -57,7 +73,7 @@
|
|||
<div class="col-md-4">
|
||||
|
||||
<div class="panel panel-info table-striped top5">
|
||||
<div class="panel-heading">{{'Fast add' | translate}}</div>
|
||||
<div class="panel-heading">{{'Quick add' | translate}}</div>
|
||||
<div class="panel-body">
|
||||
<form>
|
||||
<div class="input-group input-group-sm">
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
<script src="/static/js/eventman.js"></script>
|
||||
<script src="/js/app.js"></script>
|
||||
<script src="/js/i18n.js"></script>
|
||||
<script src="/js/filters.js"></script>
|
||||
<script src="/js/services.js"></script>
|
||||
<script src="/js/controllers.js"></script>
|
||||
<link href="/static/css/normalize.css" rel="stylesheet">
|
||||
|
|
46
angular_app/js/app.js
vendored
46
angular_app/js/app.js
vendored
|
@ -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) {
|
||||
|
|
25
angular_app/js/controllers.js
vendored
25
angular_app/js/controllers.js
vendored
|
@ -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;
|
||||
|
|
|
@ -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; } */
|
||||
|
|
Loading…
Reference in a new issue