2015-03-14 17:32:16 +01:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/* Controllers */
|
2015-03-15 18:00:08 +01:00
|
|
|
var eventManControllers = angular.module('eventManControllers', []);
|
2015-03-14 17:32:16 +01:00
|
|
|
|
2015-03-21 20:31:36 +01:00
|
|
|
|
2015-03-22 09:19:30 +01:00
|
|
|
/* A controller that can be used to navigate. */
|
2015-03-20 22:47:21 +01:00
|
|
|
eventManControllers.controller('navigation', ['$location',
|
|
|
|
function ($location) {
|
|
|
|
this.go = function(url) {
|
|
|
|
$location.url(url);
|
|
|
|
};
|
|
|
|
}]
|
|
|
|
);
|
|
|
|
|
2015-03-14 17:32:16 +01:00
|
|
|
|
2015-03-21 11:34:55 +01:00
|
|
|
eventManControllers.controller('EventsListCtrl', ['$scope', 'Event',
|
|
|
|
function ($scope, Event) {
|
|
|
|
$scope.events = Event.all();
|
2015-03-15 18:00:08 +01:00
|
|
|
$scope.orderProp = 'begin-datetime';
|
|
|
|
}]
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2015-03-21 11:34:55 +01:00
|
|
|
eventManControllers.controller('EventDetailsCtrl', ['$scope', 'Event', '$routeParams',
|
|
|
|
function ($scope, Event, $routeParams) {
|
2015-03-21 15:33:17 +01:00
|
|
|
if ($routeParams.id) {
|
|
|
|
$scope.event = Event.get($routeParams);
|
|
|
|
}
|
2015-03-22 09:19:30 +01:00
|
|
|
// store a new Event or update an existing one
|
2015-03-21 15:45:40 +01:00
|
|
|
$scope.save = function() {
|
|
|
|
if ($scope.event.id === undefined) {
|
2015-03-22 00:07:05 +01:00
|
|
|
$scope.event = Event.save($scope.event);
|
2015-03-21 15:45:40 +01:00
|
|
|
} else {
|
2015-03-22 00:07:05 +01:00
|
|
|
$scope.event = Event.update($scope.event);
|
2015-03-21 15:45:40 +01:00
|
|
|
}
|
|
|
|
};
|
2015-03-15 23:05:59 +01:00
|
|
|
}]
|
|
|
|
);
|
|
|
|
|
|
|
|
|
2015-03-21 11:34:55 +01:00
|
|
|
eventManControllers.controller('PersonsListCtrl', ['$scope', 'Person',
|
|
|
|
function ($scope, Person) {
|
|
|
|
$scope.persons = Person.all();
|
2015-03-15 18:00:08 +01:00
|
|
|
$scope.orderProp = 'name';
|
2015-03-14 17:32:16 +01:00
|
|
|
}]
|
|
|
|
);
|
|
|
|
|
2015-03-15 23:05:59 +01:00
|
|
|
|
2015-03-21 11:34:55 +01:00
|
|
|
eventManControllers.controller('PersonDetailsCtrl', ['$scope', 'Person', '$routeParams',
|
|
|
|
function ($scope, Person, $routeParams) {
|
2015-03-21 16:48:00 +01:00
|
|
|
if ($routeParams.id) {
|
|
|
|
$scope.person = Person.get($routeParams);
|
|
|
|
}
|
2015-03-22 09:19:30 +01:00
|
|
|
// store a new Person or update an existing one
|
|
|
|
$scope.save = function() {
|
2015-03-21 16:48:00 +01:00
|
|
|
$scope.save = function() {
|
2015-03-21 18:29:19 +01:00
|
|
|
if ($scope.person.id === undefined) {
|
2015-03-22 00:07:05 +01:00
|
|
|
$scope.person = Person.save($scope.person);
|
2015-03-21 16:48:00 +01:00
|
|
|
} else {
|
2015-03-22 00:07:05 +01:00
|
|
|
$scope.person = Person.update($scope.person);
|
2015-03-21 16:48:00 +01:00
|
|
|
}
|
|
|
|
};
|
2015-03-15 23:05:59 +01:00
|
|
|
}]
|
|
|
|
);
|
|
|
|
|