diff --git a/angular_app/js/app.js b/angular_app/js/app.js
index 0ee06f9..268c10e 100644
--- a/angular_app/js/app.js
+++ b/angular_app/js/app.js
@@ -139,12 +139,12 @@ eventManApp.config(['$stateProvider', '$urlRouterProvider',
.state('event.ticket.new', {
url: '/:id/ticket/new',
templateUrl: 'ticket-edit.html',
- controller: 'EventDetailsCtrl'
+ controller: 'EventTicketsCtrl'
})
.state('event.ticket.edit', {
url: '/:id/ticket/edit',
templateUrl: 'ticket-edit.html',
- controller: 'EventDetailsCtrl'
+ controller: 'EventTicketsCtrl'
})
.state('import', {
url: '/import',
diff --git a/angular_app/js/controllers.js b/angular_app/js/controllers.js
index 67291f2..10ddd5a 100644
--- a/angular_app/js/controllers.js
+++ b/angular_app/js/controllers.js
@@ -95,8 +95,8 @@ eventManControllers.controller('EventsListCtrl', ['$scope', 'Event', '$modal', '
);
-eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope',
- function ($scope, $state, Event, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope) {
+eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event', 'EventTicket', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope',
+ function ($scope, $state, Event, EventTicket, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope) {
$scope.personsOrder = ["name", "surname"];
$scope.countAttendees = 0;
$scope.message = {};
@@ -359,6 +359,33 @@ eventManControllers.controller('EventDetailsCtrl', ['$scope', '$state', 'Event',
);
+eventManControllers.controller('EventTicketsCtrl', ['$scope', '$state', 'Event', 'EventTicket', 'Person', 'EventUpdates', '$stateParams', 'Setting', '$log', '$translate', '$rootScope',
+ function ($scope, $state, Event, EventTicket, Person, EventUpdates, $stateParams, Setting, $log, $translate, $rootScope) {
+ $scope.message = {};
+ $scope.event = {};
+
+ $scope.newTicket = $state.is('event.ticket.new');
+
+ if ($stateParams.id) {
+ $scope.event = Event.get($stateParams, function() {
+ });
+ }
+
+ $scope.addTicket = function(person) {
+ var personObj = new Person(person);
+ personObj.$save(function(p) {
+ person.person_id = person._id;
+ person._id = $stateParams.id; // that's the id of the event, not the person.
+ EventTicket.addTicket(person, function(p) {
+ $log.debug(p);
+ });
+ $scope.newPerson = {};
+ });
+ };
+ }]
+);
+
+
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person', 'Setting', '$modal', '$translate', '$rootScope',
function ($scope, Person, Setting, $modal, $translate, $rootScope) {
$scope.persons = Person.all();
diff --git a/angular_app/js/services.js b/angular_app/js/services.js
index c2fcea4..1e6d552 100644
--- a/angular_app/js/services.js
+++ b/angular_app/js/services.js
@@ -97,6 +97,47 @@ eventManServices.factory('Event', ['$resource', '$rootScope',
);
+eventManServices.factory('EventTicket', ['$resource', '$rootScope',
+ function($resource, $rootScope) {
+ return $resource('events/:id/tickets', {id: '@_id', person_id: '@person_id'}, {
+
+ updateTicket: {
+ method: 'PUT',
+ interceptor : {responseError: $rootScope.errorHandler},
+ isArray: false,
+ url: 'events/:id/ticketss/:person_id',
+ params: {uuid: $rootScope.app_uuid},
+ transformResponse: function(data, headers) {
+ return angular.fromJson(data);
+ }
+ },
+
+ addTicket: {
+ method: 'POST',
+ interceptor : {responseError: $rootScope.errorHandler},
+ isArray: false,
+ url: 'events/:id/tickets/:person_id',
+ params: {uuid: $rootScope.app_uuid},
+ transformResponse: function(data, headers) {
+ return angular.fromJson(data);
+ }
+ },
+
+ deleteTicket: {
+ method: 'DELETE',
+ interceptor : {responseError: $rootScope.errorHandler},
+ isArray: false,
+ url: 'events/:_id/tickets/:person_id',
+ params: {uuid: $rootScope.app_uuid},
+ transformResponse: function(data, headers) {
+ return angular.fromJson(data);
+ }
+ }
+ });
+ }]
+);
+
+
eventManServices.factory('Person', ['$resource', '$rootScope',
function($resource, $rootScope) {
return $resource('persons/:id', {id: '@_id'}, {
diff --git a/angular_app/ticket-edit.html b/angular_app/ticket-edit.html
index e5f31c9..169cf3e 100644
--- a/angular_app/ticket-edit.html
+++ b/angular_app/ticket-edit.html
@@ -37,7 +37,7 @@
-