From 88fd3daf18ce4b916a310bd7c4b6be0fbe0bfb4e Mon Sep 17 00:00:00 2001 From: Davide Alberani Date: Sun, 24 Apr 2016 14:51:05 +0200 Subject: [PATCH] #108: avoid local add of already present person --- angular_app/js/controllers.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/angular_app/js/controllers.js b/angular_app/js/controllers.js index 89e3c76..1e363bb 100644 --- a/angular_app/js/controllers.js +++ b/angular_app/js/controllers.js @@ -204,6 +204,13 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', if (!$scope.event.persons) { $scope.event.persons = []; } + var person_idx = $scope.event.persons.findIndex(function(el, idx, array) { + return person.person_id == el.person_id; + }); + if (person_idx != -1) { + $log.debug('person already present: not added'); + return false; + } $scope.event.persons.push(person); $scope.setPersonAttribute(person, 'attended', true, function() { var all_person_idx = $scope.allPersons.findIndex(function(el, idx, array) {