Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dashboard-project-app/client/app/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,8 @@ h3 {
.uncompress-text{
max-height: none !important;
}

.text-warning{
font-size: 11px;
font-weight: bolder;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down Expand Up @@ -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) {
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}

}]);
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,22 @@
<div class="col-xs-3">
<i class="fa fa-calendar" aria-hidden="true"></i>
<strong> Created on</strong> {{userStory.createdOn}}

<div class="text-warning" ng-show="warnings.createdOn">
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
{{warnings.createdOn.message}}
</div>

</div>
<div class="col-xs-3">
<i class="fa fa-calendar" aria-hidden="true"></i>
<strong>Updated on</strong> {{userStory.updatedOn}}

<div class="text-warning" ng-show="warnings.updatedOn">
<span class="glyphicon glyphicon-warning-sign" aria-hidden="true"></span>
{{warnings.updatedOn.message}}
</div>

</div>
</div>
<div class="row add-margin-top">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,77 @@

angular.module('dashboardProjectApp').controller('projectListCtrl', function(
$scope,
UserStory
UserStory,
DateService
){
var data = [];
var lastUpdate;
$scope.warnings = {};

function setWarning(key, message){

if(message){
$scope.warnings[key] = {
message:message
}
}else{
$scope.warnings[key] = message
}
}


function getTemplateWarning(key){
var template = '';
if($scope.warnings[key]){
template = '<div class="text-warning" uib-tooltip="On the tootll">'+
'<span class="glyphicon glyphicon-warning-sign" uib-tooltip="On the tootll"></span>'+
$scope.warnings[key].message+
'</div>';
}
return template;
}

function getFiles() {
UserStory.find(
function success(userStories, fillTable) {
new Promise(function(resolve, reject) {
var stringDate, realDate;


userStories.forEach(function each (story) {

console.log('userStories', story);
if(story.lastUpdate !== '') {
lastUpdate = moment(story.lastUpdate, "YYYY-MM-DD").format("MM-DD-YYYY");
} else {
lastUpdate = moment(story.dateCreated, "DD-MM-YYYY").format("MM-DD-YYYY");
console.log('story', story);

story.dateCreated = DateService.validateDate(
story.dateCreated,
'dateCreated', setWarning);

if(story.lastUpdate !=='') {
story.lastUpdate = moment(story.lastUpdate,
"YYYY-MM-DD").format("MM-DD-YYYY");
} else {
story.lastUpdate = story.dateCreated;
}

if(!$scope.warnings['dateCreated']
&& !$scope.warnings['lastUpdate']){
DateService.compareDates(story.dateCreated,
story.lastUpdate, 'dateCreated', setWarning);
}


data.push(
{
userStory: story.id+'-'+story.userStory,
dateCreated: moment(story.dateCreated, "DD-MM-YYYY").format("MM-DD-YYYY"),
lastUpdate: lastUpdate,
dateCreated: story.dateCreated + getTemplateWarning('dateCreated'),
lastUpdate: story.lastUpdate + getTemplateWarning('lastUpdate'),
progressPercentage: story.completed.percentage,
progressLabel: story.completed.completed + ' / ' + story.completed.total
}
)

console.log('data', data);
resolve(data);
resolve(data);
});

})
.then(function(result) {
$(function () {
Expand Down
1 change: 1 addition & 0 deletions dashboard-project-app/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
<script src="components/util/util.module.js"></script>
<script src="components/footer/footer.directive.js"></script>
<script src="app/projectDetail/projectDetail.js"></script>
<script src="app/projectDetail/services/dateService.js"></script>
<script src="app/projectDetail/services/userStoryService.js"></script>
<script src="app/projectList/controllers/projectList.controller.js"></script>
<script src="app/projectList/projectList.js"></script>
Expand Down