diff --git a/admin/api/claim.go b/admin/api/claim.go index 9618b12e..f171c622 100644 --- a/admin/api/claim.go +++ b/admin/api/claim.go @@ -32,6 +32,7 @@ func init() { router.POST("/api/claims/:cid", apiHandler(claimHandler(addClaimDescription))) router.DELETE("/api/claims/:cid", apiHandler(claimHandler(deleteClaim))) + router.GET("/api/claims/:cid/last_update", apiHandler(claimHandler(getClaimLastUpdate))) router.PUT("/api/claims/:cid/descriptions", apiHandler(claimHandler(updateClaimDescription))) // Assignees @@ -55,6 +56,10 @@ func getExerciceClaims(exercice fic.Exercice, _ []byte) (interface{}, error) { return exercice.GetClaims() } +func getClaimLastUpdate(claim fic.Claim, _ []byte) (interface{}, error) { + return claim.GetLastUpdate() +} + type ClaimExported struct { Id int64 `json:"id"` Subject string `json:"subject"` diff --git a/admin/static/js/app.js b/admin/static/js/app.js index f74ecc24..08d4bae8 100644 --- a/admin/static/js/app.js +++ b/admin/static/js/app.js @@ -1092,7 +1092,7 @@ angular.module("FICApp") $scope.assignees = ClaimAssignee.query(); $scope.whoami = getCookie("myassignee"); $scope.teams = Teams.get(); - $scope.fields = ["subject", "id_team", "state", "id_assignee", "creation", "id"]; + $scope.fields = ["subject", "id_team", "state", "id_assignee", "last_update", "id"]; $scope.order = "priority"; $scope.chOrder = function(no) { @@ -1108,6 +1108,19 @@ angular.module("FICApp") $location.url("/claims/" + id); }; }) + .controller("ClaimLastUpdateController", function($scope, $http) { + $scope.init = function(claim) { + $http.get("/api/claims/" + claim.id + "/last_update").then(function(response) { + if (response.data) + $scope.last_update = response.data; + else + $scope.last_update = claim.creation; + claim.last_update = $scope.last_update; + }, function(response) { + $scope.last_update = claim.creation; + }) + } + }) .controller("ClaimController", function($scope, Claim, ClaimAssignee, Teams, Exercice, $routeParams, $location, $http, $rootScope) { $scope.claim = Claim.get({ claimId: $routeParams.claimId }, function(v) { v.id_team = "" + v.id_team; diff --git a/admin/static/views/claim-list.html b/admin/static/views/claim-list.html index f66ea7e3..9e36e5a5 100644 --- a/admin/static/views/claim-list.html +++ b/admin/static/views/claim-list.html @@ -28,7 +28,7 @@ - + {{ claim[field] }} @@ -36,6 +36,11 @@ {{ assignee.name }} + + + {{ last_update }} + + {{ teams[claim.id_team].name }} diff --git a/libfic/todo.go b/libfic/todo.go index 8ed27205..7322a25d 100644 --- a/libfic/todo.go +++ b/libfic/todo.go @@ -193,6 +193,12 @@ type ClaimDescription struct { Publish bool `json:"publish"` } +// GetLastUpdate returns the date of the latest message written for the given Claim. +func (c Claim) GetLastUpdate() (res *time.Time, err error) { + err = DBQueryRow("SELECT MAX(date) FROM claim_descriptions WHERE id_claim = ? GROUP BY id_claim", c.Id).Scan(&res) + return +} + // GetDescriptions returns a list of all descriptions stored in the database for the Claim. func (c Claim) GetDescriptions() (res []ClaimDescription, err error) { var rows *sql.Rows