diff --git a/dashboard-project-app/client/app/app.css b/dashboard-project-app/client/app/app.css index 7a97efc..aaafed3 100755 --- a/dashboard-project-app/client/app/app.css +++ b/dashboard-project-app/client/app/app.css @@ -133,3 +133,8 @@ h3 { .uncompress-text{ max-height: none !important; } + +.text-warning{ + font-size: 11px; + font-weight: bolder; +} diff --git a/dashboard-project-app/client/app/projectDetail/controllers/projectDetail.controller.js b/dashboard-project-app/client/app/projectDetail/controllers/projectDetail.controller.js index e00724a..04d8f1c 100755 --- a/dashboard-project-app/client/app/projectDetail/controllers/projectDetail.controller.js +++ b/dashboard-project-app/client/app/projectDetail/controllers/projectDetail.controller.js @@ -2,12 +2,13 @@ (function () { angular.module('dashboardProjectApp') - .controller('projectDetailController', ['$scope','$state', 'UserStory', '$location', - function($scope, $state, UserStory, $location) { + .controller('projectDetailController', ['$scope','$state', 'UserStory', '$location', 'DateService', + function($scope, $state, UserStory, $location, DateService) { $scope.taskId = $state.params.id; $scope.openTasks = {}; - $scope.showText = {} + $scope.showText = {}; + $scope.warnings = {}; $scope.closeTask = function(task){ $scope.openTasks[task] = !$scope.openTasks[task]; @@ -35,9 +36,20 @@ return 'fa fa-cog'; } - $scope.actualProject = {}; + function setWarning(key, message){ + + if(message){ + $scope.warnings[key] = { + message:message + } + }else{ + $scope.warnings[key] = message + } + + } + function getFile() { UserStory.findById({id:$scope.taskId}, function success(userStory) { @@ -53,16 +65,26 @@ description; } - $scope.userStory.createdOn = moment($scope.userStory. - createdOn, "DD-MM-YYYY").format("MM-DD-YYYY"); - if($scope.userStory.updatedOn !=='') { - $scope.userStory.updatedOn = moment($scope.userStory. - updatedOn, "YYYY-MM-DD").format("MM-DD-YYYY"); + $scope.userStory.createdOn = DateService.validateDate( + $scope.userStory.createdOn, + 'createdOn', setWarning); + + + if($scope.userStory.updatedOn !=='') { + $scope.userStory.updatedOn = moment($scope.userStory.updatedOn, + "YYYY-MM-DD").format("MM-DD-YYYY"); } else { $scope.userStory.updatedOn = $scope.userStory.createdOn; } + + if(!$scope.warnings['createdOn'] + && !$scope.warnings['updatedOn']){ + DateService.compareDates($scope.userStory.createdOn, + $scope.userStory.updatedOn, 'createdOn', setWarning); + } + for(var key in $scope.userStory.tasks_status) { $scope.actualProject[key] = $scope.userStory. tasks_status[key].projects[0] diff --git a/dashboard-project-app/client/app/projectDetail/services/dateService.js b/dashboard-project-app/client/app/projectDetail/services/dateService.js new file mode 100644 index 0000000..779988e --- /dev/null +++ b/dashboard-project-app/client/app/projectDetail/services/dateService.js @@ -0,0 +1,42 @@ +angular.module('dashboardProjectApp') + .service('DateService', ['$http', function($http) { + + + this.validateDate = function(date, field, setWarning){ + var newDate = date; + + var format = null; + + + if(moment(newDate, 'MM-DD-YYYY', true).isValid()){ + format = 'MM-DD-YYYY'; + } + + if(moment(newDate, 'YYYY-MM-DD', true).isValid()){ + format = 'YYYY-MM-DD'; + } + + if(moment(newDate, 'DD-MM-YYYY', true).isValid()){ + format = 'DD-MM-YYYY'; + } + + if(format){ + newDate = moment(newDate, format).format("MM-DD-YYYY"); + setWarning(field, null); + }else{ + setWarning(field, 'Warning: The date is not valid'); + } + return newDate; + } + + this.compareDates = function(craetedOn, updatedOn, field, setWarning){ + + //If both valid date, compare + if (moment(craetedOn).isAfter(updatedOn)){ + setWarning(field, "Warning: This date can't be bigger"); + }else{ + setWarning(field, null); + } + } + + }]); diff --git a/dashboard-project-app/client/app/projectDetail/views/quickResume.html b/dashboard-project-app/client/app/projectDetail/views/quickResume.html index 6d50670..931d164 100755 --- a/dashboard-project-app/client/app/projectDetail/views/quickResume.html +++ b/dashboard-project-app/client/app/projectDetail/views/quickResume.html @@ -38,10 +38,22 @@