frontend: display issues related to the team
This commit is contained in:
parent
7bec409ab8
commit
a3ffdeae17
12 changed files with 238 additions and 12 deletions
|
|
@ -3,6 +3,9 @@ package api
|
|||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"path"
|
||||
"time"
|
||||
|
||||
"srs.epita.fr/fic-server/libfic"
|
||||
|
|
@ -11,6 +14,11 @@ import (
|
|||
)
|
||||
|
||||
func init() {
|
||||
router.GET("/api/teams/:tid/issue.json", apiHandler(teamHandler(
|
||||
func(team fic.Team, _ []byte) (interface{}, error) {
|
||||
return team.MyIssueFile()
|
||||
})))
|
||||
|
||||
// Tasks
|
||||
router.GET("/api/claims", apiHandler(getClaims))
|
||||
router.POST("/api/claims", apiHandler(newClaim))
|
||||
|
|
@ -24,6 +32,8 @@ func init() {
|
|||
router.POST("/api/claims/:cid", apiHandler(claimHandler(addClaimDescription)))
|
||||
router.DELETE("/api/claims/:cid", apiHandler(claimHandler(deleteClaim)))
|
||||
|
||||
router.PUT("/api/claims/:cid/descriptions", apiHandler(claimHandler(updateClaimDescription)))
|
||||
|
||||
// Assignees
|
||||
router.GET("/api/claims-assignees", apiHandler(getAssignees))
|
||||
router.POST("/api/claims-assignees", apiHandler(newAssignee))
|
||||
|
|
@ -157,6 +167,17 @@ func clearClaims(_ httprouter.Params, _ []byte) (interface{}, error) {
|
|||
return fic.ClearClaims()
|
||||
}
|
||||
|
||||
func generateTeamIssuesFile(team fic.Team) error {
|
||||
if my, err := team.MyIssueFile(); err != nil {
|
||||
return err
|
||||
} else if j, err := json.Marshal(my); err != nil {
|
||||
return err
|
||||
} else if err = ioutil.WriteFile(path.Join(TeamsDir, fmt.Sprintf("%d", team.Id), "issues.json"), j, 0644); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func addClaimDescription(claim fic.Claim, body []byte) (interface{}, error) {
|
||||
var ud fic.ClaimDescription
|
||||
if err := json.Unmarshal(body, &ud); err != nil {
|
||||
|
|
@ -165,8 +186,31 @@ func addClaimDescription(claim fic.Claim, body []byte) (interface{}, error) {
|
|||
|
||||
if assignee, err := fic.GetAssignee(ud.IdAssignee); err != nil {
|
||||
return nil, err
|
||||
} else if description, err := claim.AddDescription(ud.Content, assignee, ud.Publish); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return claim.AddDescription(ud.Content, assignee)
|
||||
if team, _ := claim.GetTeam(); team != nil {
|
||||
err = generateTeamIssuesFile(*team)
|
||||
}
|
||||
|
||||
return description, err
|
||||
}
|
||||
}
|
||||
|
||||
func updateClaimDescription(claim fic.Claim, body []byte) (interface{}, error) {
|
||||
var ud fic.ClaimDescription
|
||||
if err := json.Unmarshal(body, &ud); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if _, err := ud.Update(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
if team, _ := claim.GetTeam(); team != nil {
|
||||
err = generateTeamIssuesFile(*team)
|
||||
}
|
||||
|
||||
return ud, err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -181,7 +225,11 @@ func updateClaim(claim fic.Claim, body []byte) (interface{}, error) {
|
|||
if _, err := uc.Update(); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
return uc, nil
|
||||
if team, _ := claim.GetTeam(); team != nil {
|
||||
err = generateTeamIssuesFile(*team)
|
||||
}
|
||||
|
||||
return uc, err
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1133,13 +1133,26 @@ angular.module("FICApp")
|
|||
$scope.changeState = function(state) {
|
||||
this.claim.state = state;
|
||||
if (this.claim.id)
|
||||
this.saveClaim(false);
|
||||
this.saveClaim(state == "invalid" || state == "closed");
|
||||
}
|
||||
$scope.assignToMe = function() {
|
||||
this.claim.id_assignee = $scope.whoami;
|
||||
if (this.claim.id)
|
||||
this.saveClaim(false);
|
||||
}
|
||||
$scope.updateDescription = function(description) {
|
||||
$http({
|
||||
url: "/api/claims/" + $scope.claim.id + "/descriptions",
|
||||
method: "PUT",
|
||||
data: description
|
||||
}).then(function(response) {
|
||||
$scope.claim = Claim.get({ claimId: $routeParams.claimId }, function(v) {
|
||||
v.id_team = "" + v.id_team;
|
||||
if (!v.priority)
|
||||
v.priority = "medium";
|
||||
});
|
||||
});
|
||||
}
|
||||
$scope.saveDescription = function() {
|
||||
$http({
|
||||
url: "/api/claims/" + $scope.claim.id,
|
||||
|
|
@ -1152,7 +1165,7 @@ angular.module("FICApp")
|
|||
$location.url("/claims/" + $scope.claim.id + "/");
|
||||
});
|
||||
}
|
||||
$scope.saveClaim = function(backToList) {
|
||||
$scope.saveClaim = function(backToList) {
|
||||
if (this.claim.id_team) {
|
||||
this.claim.id_team = parseInt(this.claim.id_team, 10);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -62,6 +62,11 @@
|
|||
</div>
|
||||
|
||||
<div ng-repeat="description in claim.descriptions | orderBy:'id':true" class="alert" ng-class="{'alert-info': '' + description.id_assignee != whoami, 'alert-dark': '' + description.id_assignee == whoami}">
|
||||
<div class="float-right btn-group-toggle" data-toggle="buttons">
|
||||
<label class="btn btn-sm" ng-class="{'btn-outline-secondary':!description.publish, 'btn-success':description.publish}">
|
||||
<input type="checkbox" ng-model="description.publish" ng-change="updateDescription(description)"><i class="glyphicon" ng-class="{'glyphicon-eye-open':description.publish,'glyphicon-eye-close':!description.publish}"></i>
|
||||
</label>
|
||||
</div>
|
||||
<strong>Par <span ng-repeat="assignee in assignees" ng-if="assignee.id == description.id_assignee">{{ assignee.name }}</span> le {{ description.date | date:"mediumTime" }} :</strong>
|
||||
<span style="white-space: pre-line">{{ description.content }}</span>
|
||||
</div>
|
||||
|
|
|
|||
Reference in a new issue