diff --git a/templates/js/app.js b/templates/js/app.js index cb5558a..1bec6f8 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -48,11 +48,11 @@ app.config(['$routeProvider', '$locationProvider', templateUrl: 'templates/views/newTask.html', controller: 'newTasksController' }) - .when('/tasks/overview/:taskId/:submitterId', { + .when('/tasks/overview/:taskId/:submitterId/:gId', { templateUrl: 'templates/views/task.html', controller: 'taskController' }) - .when('/tasks/fill/:taskId', { + .when('/tasks/fill/:taskId/:gId', { templateUrl: 'templates/views/task.html', controller: 'taskController' }) diff --git a/templates/js/controllers/newTasksController.js b/templates/js/controllers/newTasksController.js index e634291..c348a31 100644 --- a/templates/js/controllers/newTasksController.js +++ b/templates/js/controllers/newTasksController.js @@ -51,7 +51,7 @@ angular.module('SeHub').controller('newTasksController', ['$scope', 'apiService' console.error(err); }) } else { - alert('Fill All Shit!'); + alert('Please Fill All Task info & At least one component'); } } @@ -64,6 +64,8 @@ angular.module('SeHub').controller('newTasksController', ['$scope', 'apiService' return false; if (!$scope.task.date) return false; + if ($scope.task.components.length < 1) + return false; return true; } diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js index 4133f05..979bfe2 100644 --- a/templates/js/controllers/taskController.js +++ b/templates/js/controllers/taskController.js @@ -6,12 +6,22 @@ angular.module('SeHub') var taskId = $routeParams.taskId; var submitterId = $routeParams.submitterId; + var token = $cookies['com.sehub.www']; + var groupId = $routeParams.gId; + apiService.getTaskById(token, taskId, groupId).success(function(data){ + $scope.task = data; + $scope.dateInit($scope.task.dueDate); + }).error(function(err){ + console.error('Error: ', err); + }) if (submitterId) { //In This Case we Only Want to show The Content of the Submitter $scope.readOnly = true; + } else { //In This Case We Need An Empty Task To Be Able To Fill It $scope.readOnly = false; + apiService.getTaskById(token, taskId, groupId); } $scope.dateInit = function(date) { @@ -81,35 +91,35 @@ angular.module('SeHub') = Mock Data = =================================*/ - $scope.task = { - "title": "task1", - "courseId": 1234567890, - "description": "one line\nsecondline\nthirdline", - "dueDate": { - "year": 2010, - "month": 2, - "day": 4 - }, - "isPersonal": true, - "components": [{ - "type": "radiobuttons", - "label": "pick One|this|orthis|MaybeThis", - "isMandatory": true, - "order": 1 - }, { - "type": "checkbox", - "label": "tick Me", - "isMandatory": true, - "order": 2 - }, { - "type": "textarea", - "label": "fill shit", - "isMandatory": false, - "order": 3 - }] - }; + // $scope.task = { + // "title": "task1", + // "courseId": 1234567890, + // "description": "one line\nsecondline\nthirdline", + // "dueDate": { + // "year": 2010, + // "month": 2, + // "day": 4 + // }, + // "isPersonal": true, + // "components": [{ + // "type": "radiobuttons", + // "label": "pick One|this|orthis|MaybeThis", + // "isMandatory": true, + // "order": 1 + // }, { + // "type": "checkbox", + // "label": "tick Me", + // "isMandatory": true, + // "order": 2 + // }, { + // "type": "textarea", + // "label": "fill shit", + // "isMandatory": false, + // "order": 3 + // }] + // }; - $scope.dateInit($scope.task.dueDate); + $scope.dueTime = function() { if (!$scope.task.date || $scope.task.date === '') diff --git a/templates/js/services/apiService.js b/templates/js/services/apiService.js index 505ed15..8e042fb 100644 --- a/templates/js/services/apiService.js +++ b/templates/js/services/apiService.js @@ -245,6 +245,15 @@ service.factory('apiService', ['$http', function($http) { url: url }; return $http(req); + }, + getTaskById: function(token, taskId, ownerId){ + var url = (DEBUG ? "http://localhost:8080" : "http://se-hub.appspot.com") + "/api/tasks/getTaskById/" + token + "/" + taskId + "/" + ownerId; + var req = { + method: 'GET', + url: url + }; + return $http(req); + } }; }]); \ No newline at end of file