From 35df7cd3e3bb15d20d91bc80de6827f3b2c7bc9b Mon Sep 17 00:00:00 2001 From: Sagi Dayan Date: Sat, 25 Jul 2015 18:25:45 +0300 Subject: [PATCH] Tasks: More Improvements --- templates/js/controllers/taskController.js | 47 +++++++++++++++++----- templates/views/newTask.html | 2 +- templates/views/task.html | 36 ++++++++++------- 3 files changed, 59 insertions(+), 26 deletions(-) diff --git a/templates/js/controllers/taskController.js b/templates/js/controllers/taskController.js index bf45630..4133f05 100644 --- a/templates/js/controllers/taskController.js +++ b/templates/js/controllers/taskController.js @@ -1,7 +1,8 @@ angular.module('SeHub') .controller('taskController', ['$scope', '$rootScope', 'dataService', 'apiService', - '$cookies', '$location', '$routeParams', - function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams) { + '$cookies', '$location', '$routeParams', '$mdDialog', + + function($scope, $rootScope, dataService, apiService, $cookies, $location, $routeParams, $mdDialog) { var taskId = $routeParams.taskId; var submitterId = $routeParams.submitterId; @@ -13,7 +14,7 @@ angular.module('SeHub') $scope.readOnly = false; } - $scope.dateInit = function(date){ + $scope.dateInit = function(date) { d = moment(new Date(date.year, date.month - 1, date.day)); $scope.task.date = d.format("d MMMM YYYY"); } @@ -50,6 +51,30 @@ angular.module('SeHub') }; } + function validateComponents() { + for (var i = 0; i < $scope.task.components.length; i++) { + if ($scope.task.components[i].isMandatory && (!$scope.task.components[i].value || $scope.task.components[i].value == '')) + return false; + } + return true; + } + + $scope.submitTask = function(event) { //Dialog will pop-up if not all mandatory fields are filled + if (validateComponents()) { + alert('All Shit Are Filled'); + return; + } + $mdDialog.show( + $mdDialog.alert() + .title('Hey There...') + .content('You Must Fill All Mandatory Fields In Order To Submit The Task') + .ariaLabel('Not All Mandatory Are Filled') + .ok('Got it!') + .targetEvent(event) + ); + + } + /*================================= @@ -87,15 +112,15 @@ angular.module('SeHub') $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', '
'); + 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(); } - $scope.descriptionInit($scope.task.description); - $scope.dueTimeFromNow = moment(d).fromNow(); - } } ]); //End Controller \ No newline at end of file diff --git a/templates/views/newTask.html b/templates/views/newTask.html index e9ae941..0a7a855 100644 --- a/templates/views/newTask.html +++ b/templates/views/newTask.html @@ -87,7 +87,7 @@

{{task.task.title}}

Due At: {{ task.date }}

{{ dueTimeFromNow }}

-

{{task.task.description}}

+

{{task.task.description}}

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

diff --git a/templates/views/task.html b/templates/views/task.html index d987f25..760a2fb 100644 --- a/templates/views/task.html +++ b/templates/views/task.html @@ -1,19 +1,18 @@ -
-
- -
+
+
+
-

{{task.title}}

+

{{task.title}}

Due At: {{ task.date }}

{{ dueTimeFromNow }}

-

+

{{task.description}}

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

-
+
@@ -22,40 +21,49 @@
- +
- +
- + {{ component.label}}
- {{component.title}} + {{component.title}}
{{component.title}} - + {{option.text}}
+
+
+
+ Submit +
+
-
+ +
-
\ No newline at end of file +
+ + \ No newline at end of file