From 33003c048699dec7db4099f3cc3f106a026e9b80 Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Fri, 24 Jul 2015 00:57:14 +0300 Subject: [PATCH] Begining of the Task filling/viewing controller and html view --- templates/js/app.js | 8 ++ templates/js/controllers/taskController.js | 101 +++++++++++++++++++++ templates/views/index.html | 1 + templates/views/task.html | 61 +++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 templates/js/controllers/taskController.js create mode 100644 templates/views/task.html diff --git a/templates/js/app.js b/templates/js/app.js index 4940008..5f4777f 100644 --- a/templates/js/app.js +++ b/templates/js/app.js @@ -48,6 +48,14 @@ app.config(['$routeProvider', '$locationProvider', templateUrl: 'templates/views/newTask.html', controller: 'newTasksController' }) + .when('/tasks/overview/:taskId/:submitterId', { + templateUrl: 'templates/views/task.html', + controller: 'taskController' + }) + .when('/tasks/fill/:taskId', { + templateUrl: 'templates/views/task.html', + controller: 'taskController' + }) .when('/class/:classId/:className', { templateUrl: 'templates/views/class.html', controller: 'classController' diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js new file mode 100644 index 0000000..bf45630 --- /dev/null +++ b/templates/js/controllers/taskController.js @@ -0,0 +1,101 @@ +angular.module('SeHub') + .controller('taskController', ['$scope', '$rootScope', 'dataService', 'apiService', + '$cookies', '$location', '$routeParams', + function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) { + + var taskId = $routeParams.taskId; + var submitterId = $routeParams.submitterId; + + + 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; + } + + $scope.dateInit = function(date){ + d = moment(new Date(date.year, date.month - 1, date.day)); + $scope.task.date = d.format("d MMMM YYYY"); + } + + + $scope.dueTime = function() { + if (!$scope.task.date || $scope.task.date === '') + $scope.dueTimeFromNow = ""; + var d = new Date($scope.task.date); + $scope.dueTimeFromNow = moment(d).fromNow(); + } + + $scope.initLinkComp = function(component) { + var arr = component.label.split("|"); + for (var i = 0; i < arr.length - 1; i++) { + if (i == 0) + component.title = arr[i]; + else + component.href = arr[i]; + }; + } + + $scope.initRadioButtonsComp = function(component) { + var arr = component.label.split("|"); + component.values = []; + for (var i = 0; i < arr.length - 1; i++) { + if (i == 0) + component.title = arr[i]; + else + component.values.push({ + text: arr[i], + id: i + }); + }; + } + + + + /*================================= + = 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.dateInit($scope.task.dueDate); + + $scope.dueTime = function() { + if (!$scope.task.date || $scope.task.date === '') + $scope.dueTimeFromNow = ""; + var d = new Date($scope.task.date); + $scope.descriptionInit = function(desc){ + desc.replace('\n', '
'); + } + $scope.descriptionInit($scope.task.description); + $scope.dueTimeFromNow = moment(d).fromNow(); + } + + } + ]); //End Controller \ No newline at end of file diff --git a/templates/views/index.html b/templates/views/index.html index 0196f52..9c1d9bd 100644 --- a/templates/views/index.html +++ b/templates/views/index.html @@ -112,6 +112,7 @@ + diff --git a/templates/views/task.html b/templates/views/task.html new file mode 100644 index 0000000..d987f25 --- /dev/null +++ b/templates/views/task.html @@ -0,0 +1,61 @@ +
+
+ +
+ +

{{task.title}}

+

Due At: {{ task.date }}

+

{{ dueTimeFromNow }}

+

+

{{(task.isPersonal) ? "Personal" : "Project"}} Task

+ + + +
+ +
+ + + +
+ +
+ + + + +
+ +
+ + + + +
+ +
+ + {{ component.label}} + +
+ +
+ + {{component.title}} + +
+ +
+ {{component.title}} + + {{option.text}} + +
+
+
+
+
+
+ + +
\ No newline at end of file