2015-02-08 14:57:02 +01:00
|
|
|
angular.module('OpenSlidesApp.assignments', [])
|
|
|
|
|
|
|
|
.config(function($stateProvider) {
|
|
|
|
$stateProvider
|
|
|
|
.state('assignments', {
|
|
|
|
url: '/assignment',
|
|
|
|
abstract: true,
|
|
|
|
template: "<ui-view/>",
|
|
|
|
})
|
|
|
|
.state('assignments.assignment', {
|
|
|
|
abstract: true,
|
|
|
|
template: "<ui-view/>",
|
|
|
|
})
|
|
|
|
.state('assignments.assignment.list', {
|
|
|
|
resolve: {
|
|
|
|
assignments: function(Assignment) {
|
|
|
|
return Assignment.findAll();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('assignments.assignment.create', {})
|
|
|
|
.state('assignments.assignment.detail', {
|
|
|
|
controller: 'AssignmentDetailCtrl',
|
|
|
|
resolve: {
|
|
|
|
assignment: function(Assignment, $stateParams) {
|
|
|
|
return Assignment.find($stateParams.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.state('assignments.assignment.detail.update', {
|
|
|
|
views: {
|
|
|
|
'@assignments.assignment': {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
.factory('Assignment', function(DS) {
|
|
|
|
return DS.defineResource({
|
|
|
|
name: 'assignment/assignment',
|
|
|
|
endpoint: '/rest/assignment/assignment/'
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
.controller('AssignmentListCtrl', function($scope, Assignment) {
|
2015-03-01 08:42:47 +01:00
|
|
|
Assignment.bindAll({}, $scope, 'assignments');
|
2015-02-08 14:57:02 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
.controller('AssignmentDetailCtrl', function($scope, Assignment, assignment) {
|
2015-03-01 08:42:47 +01:00
|
|
|
Assignment.bindOne(assignment.id, $scope, 'assignment')
|
2015-02-08 14:57:02 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
.controller('AssignmentCreateCtrl', function($scope, Assignment) {
|
|
|
|
$scope.assignment = {};
|
|
|
|
$scope.save = function(assignment) {
|
2015-03-01 08:42:47 +01:00
|
|
|
assignment.open_posts = 1;
|
2015-02-08 14:57:02 +01:00
|
|
|
assignment.tags = []; // TODO: the rest_api should do this
|
|
|
|
Assignment.create(assignment);
|
|
|
|
// TODO: redirect to list-view
|
|
|
|
};
|
|
|
|
})
|
|
|
|
|
|
|
|
.controller('AssignmentUpdateCtrl', function($scope, Assignment, assignment) {
|
|
|
|
$scope.assignment = assignment; // do not use .binOne(...) so autoupdate is not activated
|
|
|
|
$scope.save = function (assignment) {
|
|
|
|
Assignment.save(assignment);
|
|
|
|
// TODO: redirect to list-view
|
|
|
|
};
|
|
|
|
});
|
|
|
|
|