admin: can sort claim by last_update
This commit is contained in:
parent
83b7df7e69
commit
d8584a8a31
@ -32,6 +32,7 @@ func init() {
|
|||||||
router.POST("/api/claims/:cid", apiHandler(claimHandler(addClaimDescription)))
|
router.POST("/api/claims/:cid", apiHandler(claimHandler(addClaimDescription)))
|
||||||
router.DELETE("/api/claims/:cid", apiHandler(claimHandler(deleteClaim)))
|
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)))
|
router.PUT("/api/claims/:cid/descriptions", apiHandler(claimHandler(updateClaimDescription)))
|
||||||
|
|
||||||
// Assignees
|
// Assignees
|
||||||
@ -55,6 +56,10 @@ func getExerciceClaims(exercice fic.Exercice, _ []byte) (interface{}, error) {
|
|||||||
return exercice.GetClaims()
|
return exercice.GetClaims()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getClaimLastUpdate(claim fic.Claim, _ []byte) (interface{}, error) {
|
||||||
|
return claim.GetLastUpdate()
|
||||||
|
}
|
||||||
|
|
||||||
type ClaimExported struct {
|
type ClaimExported struct {
|
||||||
Id int64 `json:"id"`
|
Id int64 `json:"id"`
|
||||||
Subject string `json:"subject"`
|
Subject string `json:"subject"`
|
||||||
|
@ -1092,7 +1092,7 @@ angular.module("FICApp")
|
|||||||
$scope.assignees = ClaimAssignee.query();
|
$scope.assignees = ClaimAssignee.query();
|
||||||
$scope.whoami = getCookie("myassignee");
|
$scope.whoami = getCookie("myassignee");
|
||||||
$scope.teams = Teams.get();
|
$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.order = "priority";
|
||||||
$scope.chOrder = function(no) {
|
$scope.chOrder = function(no) {
|
||||||
@ -1108,6 +1108,19 @@ angular.module("FICApp")
|
|||||||
$location.url("/claims/" + id);
|
$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) {
|
.controller("ClaimController", function($scope, Claim, ClaimAssignee, Teams, Exercice, $routeParams, $location, $http, $rootScope) {
|
||||||
$scope.claim = Claim.get({ claimId: $routeParams.claimId }, function(v) {
|
$scope.claim = Claim.get({ claimId: $routeParams.claimId }, function(v) {
|
||||||
v.id_team = "" + v.id_team;
|
v.id_team = "" + v.id_team;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
<tbody>
|
<tbody>
|
||||||
<tr ng-repeat="claim in claims | filter: query | orderBy:order" ng-click="show(claim.id)" ng-class="{'table-info': claim.priority == 'medium', 'table-warning': claim.priority == 'high', 'table-danger': claim.priority == 'critical'}" ng-if="(showClosed || (claim.state != 'closed' && claim.state != 'invalid')) && (!showOnlyMines || claim.id_assignee == whoami) && (!showOnlyUnassigned || !claim.id_assignee)">
|
<tr ng-repeat="claim in claims | filter: query | orderBy:order" ng-click="show(claim.id)" ng-class="{'table-info': claim.priority == 'medium', 'table-warning': claim.priority == 'high', 'table-danger': claim.priority == 'critical'}" ng-if="(showClosed || (claim.state != 'closed' && claim.state != 'invalid')) && (!showOnlyMines || claim.id_assignee == whoami) && (!showOnlyUnassigned || !claim.id_assignee)">
|
||||||
<td ng-repeat="field in fields">
|
<td ng-repeat="field in fields">
|
||||||
<span ng-if="field != 'id_assignee' && field != 'id_team'">
|
<span ng-if="field != 'id_assignee' && field != 'id_team' && field != 'last_update'">
|
||||||
{{ claim[field] }}
|
{{ claim[field] }}
|
||||||
</span>
|
</span>
|
||||||
<span ng-if="field == 'id_assignee'">
|
<span ng-if="field == 'id_assignee'">
|
||||||
@ -36,6 +36,11 @@
|
|||||||
{{ assignee.name }}
|
{{ assignee.name }}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
<span ng-if="field == 'last_update'">
|
||||||
|
<span ng-controller="ClaimLastUpdateController" ng-init="init(claim)">
|
||||||
|
{{ last_update }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
<span ng-if="field == 'id_team'">
|
<span ng-if="field == 'id_team'">
|
||||||
<a ng-href="teams/{{ claim.id_team }}">{{ teams[claim.id_team].name }}</a>
|
<a ng-href="teams/{{ claim.id_team }}">{{ teams[claim.id_team].name }}</a>
|
||||||
</span>
|
</span>
|
||||||
|
@ -193,6 +193,12 @@ type ClaimDescription struct {
|
|||||||
Publish bool `json:"publish"`
|
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.
|
// GetDescriptions returns a list of all descriptions stored in the database for the Claim.
|
||||||
func (c Claim) GetDescriptions() (res []ClaimDescription, err error) {
|
func (c Claim) GetDescriptions() (res []ClaimDescription, err error) {
|
||||||
var rows *sql.Rows
|
var rows *sql.Rows
|
||||||
|
Loading…
Reference in New Issue
Block a user