admin: new interface to manage claims
This commit is contained in:
parent
3932bba83d
commit
1eef71923a
10 changed files with 791 additions and 0 deletions
|
@ -61,12 +61,46 @@ angular.module("FICApp", ["ngRoute", "ngResource", "ngSanitize"])
|
|||
controller: "EventController",
|
||||
templateUrl: "views/event.html"
|
||||
})
|
||||
.when("/claims", {
|
||||
controller: "ClaimsListController",
|
||||
templateUrl: "views/claim-list.html"
|
||||
})
|
||||
.when("/claims/:claimId", {
|
||||
controller: "ClaimController",
|
||||
templateUrl: "views/claim.html"
|
||||
})
|
||||
.when("/", {
|
||||
templateUrl: "views/home.html"
|
||||
});
|
||||
$locationProvider.html5Mode(true);
|
||||
});
|
||||
|
||||
function setCookie(name, value, days) {
|
||||
var expires;
|
||||
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
|
||||
expires = "; expires=" + date.toGMTString();
|
||||
} else {
|
||||
expires = "";
|
||||
}
|
||||
document.cookie = encodeURIComponent(name) + "=" + encodeURIComponent(value) + expires + "; path=/";
|
||||
}
|
||||
|
||||
function getCookie(name) {
|
||||
var nameEQ = encodeURIComponent(name) + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for (var i = 0; i < ca.length; i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0) === ' ')
|
||||
c = c.substring(1, c.length);
|
||||
if (c.indexOf(nameEQ) === 0)
|
||||
return decodeURIComponent(c.substring(nameEQ.length, c.length));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
angular.module("FICApp")
|
||||
.directive('autofocus', ['$timeout', function($timeout) {
|
||||
return {
|
||||
|
@ -88,6 +122,16 @@ angular.module("FICApp")
|
|||
'update': {method: 'PUT'},
|
||||
})
|
||||
})
|
||||
.factory("Claim", function($resource) {
|
||||
return $resource("/api/claims/:claimId", { claimId: '@id' }, {
|
||||
'update': {method: 'PUT'},
|
||||
})
|
||||
})
|
||||
.factory("ClaimAssignee", function($resource) {
|
||||
return $resource("/api/claims-assignees/:assigneeId", { assigneeId: '@id' }, {
|
||||
'update': {method: 'PUT'},
|
||||
})
|
||||
})
|
||||
.factory("File", function($resource) {
|
||||
return $resource("/api/files/:fileId", { fileId: '@id' })
|
||||
})
|
||||
|
@ -616,6 +660,134 @@ angular.module("FICApp")
|
|||
}
|
||||
})
|
||||
|
||||
.controller("AssigneesListController", function($scope, ClaimAssignee, $location) {
|
||||
$scope.assignees = ClaimAssignee.query();
|
||||
|
||||
$scope.setMyAId = function(aid) {
|
||||
setCookie("myassignee", aid, 5);
|
||||
$location.url("/claims/");
|
||||
}
|
||||
$scope.whoami = getCookie("myassignee");
|
||||
$scope.newAssignee = function() {
|
||||
$scope.assignees.push(new ClaimAssignee());
|
||||
}
|
||||
$scope.edit = function(a) {
|
||||
a.edit = true;
|
||||
}
|
||||
$scope.updateAssignee = function(a) {
|
||||
if (a.id) {
|
||||
a.$update(function() { $location.url("/claims/");});
|
||||
} else {
|
||||
a.$save()
|
||||
}
|
||||
}
|
||||
$scope.removeAssignee = function(a) {
|
||||
a.$remove(function() { $location.url("/claims/");});
|
||||
}
|
||||
})
|
||||
.controller("ClaimsListController", function($scope, Claim, ClaimAssignee, Teams, $location) {
|
||||
$scope.claims = Claim.query();
|
||||
$scope.assignees = ClaimAssignee.query();
|
||||
$scope.whoami = getCookie("myassignee");
|
||||
$scope.teams = Teams.get();
|
||||
$scope.fields = ["id", "state", "subject", "creation", "id_team", "id_assignee"];
|
||||
|
||||
$scope.order = "priority";
|
||||
$scope.chOrder = function(no) {
|
||||
$scope.order = no;
|
||||
};
|
||||
|
||||
$scope.clearClaims = function(id) {
|
||||
Claim.delete(function() {
|
||||
$scope.claims = [];
|
||||
});
|
||||
};
|
||||
$scope.show = function(id) {
|
||||
$location.url("/claims/" + id);
|
||||
};
|
||||
})
|
||||
.controller("ClaimController", function($scope, Claim, ClaimAssignee, Teams, $routeParams, $location, $http) {
|
||||
$scope.claim = Claim.get({ claimId: $routeParams.claimId }, function(v) {
|
||||
v.id_team = "" + v.id_team;
|
||||
if (!v.priority)
|
||||
v.priority = "medium";
|
||||
});
|
||||
if ($routeParams.claimId == "new")
|
||||
$scope.fields = ["id_team", "subject", "priority", "id_assignee"];
|
||||
else
|
||||
$scope.fields = ["state", "subject", "priority", "id_assignee", "id_team", "creation"];
|
||||
$scope.assignees = ClaimAssignee.query();
|
||||
$scope.whoami = Math.floor(getCookie("myassignee"));
|
||||
$scope.teams = Teams.get();
|
||||
$scope.namedFields = {
|
||||
"subject": "Objet",
|
||||
"id_assignee": "Assigné a",
|
||||
"state": "État",
|
||||
"id_team": "Équipe",
|
||||
"creation": "Création",
|
||||
"priority": "Priorité",
|
||||
"description": "Description",
|
||||
};
|
||||
$scope.states = {
|
||||
"new": "Nouveau",
|
||||
"need-info": "Besoin d'infos",
|
||||
"confirmed": "Confirmé",
|
||||
"in-progress": "En cours",
|
||||
"need-review": "Fait",
|
||||
"closed": "Clos",
|
||||
"invalid": "Invalide",
|
||||
};
|
||||
$scope.priorities = {
|
||||
"low": "Basse",
|
||||
"medium": "Moyenne",
|
||||
"high": "Haute",
|
||||
"critical": "Critique",
|
||||
};
|
||||
|
||||
$scope.assignToMe = function() {
|
||||
this.claim.id_assignee = $scope.whoami;
|
||||
if (this.claim.id)
|
||||
this.saveClaim();
|
||||
}
|
||||
$scope.saveDescription = function() {
|
||||
$http({
|
||||
url: "/api/claims/" + $scope.claim.id,
|
||||
method: "POST",
|
||||
data: {
|
||||
"id_assignee": $scope.whoami,
|
||||
"content": $scope.ndescription
|
||||
}
|
||||
}).then(function() {
|
||||
$location.url("/claims/" + $scope.claim.id);
|
||||
});
|
||||
}
|
||||
$scope.saveClaim = function() {
|
||||
if (this.claim.id_team) {
|
||||
this.claim.id_team = Math.floor(this.claim.id_team);
|
||||
} else {
|
||||
this.claim.id_team = null;
|
||||
}
|
||||
if (this.claim.id) {
|
||||
this.claim.$update(function(v) {
|
||||
v.id_team = "" + v.id_team;
|
||||
if ($scope.ndescription)
|
||||
$scope.saveDescription();
|
||||
else
|
||||
$location.url("/claims/");
|
||||
});
|
||||
} else {
|
||||
this.claim.$save(function() {
|
||||
if (!this.ndescription)
|
||||
this.ndescription = "Création de la tâche";
|
||||
$scope.saveDescription();
|
||||
});
|
||||
}
|
||||
}
|
||||
$scope.deleteClaim = function() {
|
||||
this.claim.$remove(function() { $location.url("/claims/");});
|
||||
}
|
||||
})
|
||||
|
||||
.controller("ThemesListController", function($scope, Theme, $location, $rootScope, $http) {
|
||||
$scope.themes = Theme.query();
|
||||
$scope.fields = ["id", "name"];
|
||||
|
|
Reference in a new issue