admin: claims now reference exercices
This commit is contained in:
parent
56b79cae2d
commit
2e3f7c6894
6 changed files with 76 additions and 20 deletions
|
|
@ -38,6 +38,8 @@ type ClaimExported struct {
|
|||
Subject string `json:"subject"`
|
||||
IdTeam *int64 `json:"id_team"`
|
||||
Team *fic.Team `json:"team"`
|
||||
IdExercice *int64 `json:"id_exercice"`
|
||||
Exercice *fic.Exercice `json:"exercice"`
|
||||
IdAssignee *int64 `json:"id_assignee"`
|
||||
Assignee *fic.ClaimAssignee `json:"assignee"`
|
||||
Creation time.Time `json:"creation"`
|
||||
|
|
@ -53,6 +55,9 @@ func showClaim(claim fic.Claim, _ []byte) (interface{}, error) {
|
|||
if e.Team, err = claim.GetTeam(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if e.Exercice, err = claim.GetExercice(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if e.Assignee, err = claim.GetAssignee(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
@ -70,6 +75,7 @@ func showClaim(claim fic.Claim, _ []byte) (interface{}, error) {
|
|||
e.Id = claim.Id
|
||||
e.IdAssignee = claim.IdAssignee
|
||||
e.IdTeam = claim.IdTeam
|
||||
e.IdExercice = claim.IdExercice
|
||||
e.Subject = claim.Subject
|
||||
e.Creation = claim.Creation
|
||||
e.State = claim.State
|
||||
|
|
@ -80,6 +86,7 @@ func showClaim(claim fic.Claim, _ []byte) (interface{}, error) {
|
|||
type ClaimUploaded struct {
|
||||
Subject string `json:"subject"`
|
||||
Team *int64 `json:"id_team"`
|
||||
Exercice *int64 `json:"id_exercice"`
|
||||
Assignee *int64 `json:"id_assignee"`
|
||||
Priority string `json:"priority"`
|
||||
}
|
||||
|
|
@ -101,6 +108,17 @@ func newClaim(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
t = nil
|
||||
}
|
||||
|
||||
var e *fic.Exercice
|
||||
if uc.Exercice != nil {
|
||||
if exercice, err := fic.GetExercice(*uc.Exercice); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
e = &exercice
|
||||
}
|
||||
} else {
|
||||
e = nil
|
||||
}
|
||||
|
||||
var a *fic.ClaimAssignee
|
||||
if uc.Assignee != nil {
|
||||
if assignee, err := fic.GetAssignee(*uc.Assignee); err != nil {
|
||||
|
|
@ -112,7 +130,7 @@ func newClaim(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
a = nil
|
||||
}
|
||||
|
||||
return fic.NewClaim(uc.Subject, t, a, uc.Priority)
|
||||
return fic.NewClaim(uc.Subject, t, e, a, uc.Priority)
|
||||
}
|
||||
|
||||
func clearClaims(_ httprouter.Params, _ []byte) (interface{}, error) {
|
||||
|
|
|
|||
|
|
@ -1056,24 +1056,26 @@ angular.module("FICApp")
|
|||
$location.url("/claims/" + id);
|
||||
};
|
||||
})
|
||||
.controller("ClaimController", function($scope, Claim, ClaimAssignee, Teams, $routeParams, $location, $http) {
|
||||
.controller("ClaimController", function($scope, Claim, ClaimAssignee, Teams, Exercice, $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"];
|
||||
$scope.fields = ["id_team", "subject", "priority", "id_exercice", "id_assignee"];
|
||||
else
|
||||
$scope.fields = ["state", "subject", "priority", "id_assignee", "id_team", "creation"];
|
||||
$scope.fields = ["state", "subject", "priority", "id_exercice", "id_assignee", "id_team", "creation"];
|
||||
$scope.assignees = ClaimAssignee.query();
|
||||
$scope.whoami = Math.floor(getCookie("myassignee"));
|
||||
$scope.teams = Teams.get();
|
||||
$scope.namedFields = {
|
||||
$scope.exercices = Exercice.query();
|
||||
$scope.namedFields = {
|
||||
"subject": "Objet",
|
||||
"id_assignee": "Assigné a",
|
||||
"state": "État",
|
||||
"id_team": "Équipe",
|
||||
"id_exercice": "Challenge",
|
||||
"creation": "Création",
|
||||
"priority": "Priorité",
|
||||
"description": "Description",
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@
|
|||
</span>
|
||||
</span>
|
||||
<span ng-if="field == 'id_team'">
|
||||
{{ teams[claim.id_team].name }}
|
||||
<a ng-href="teams/{{ claim.id_team }}">{{ teams[claim.id_team].name }}</a>
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
|||
|
|
@ -6,16 +6,22 @@
|
|||
<div class="form-group row" ng-repeat="field in fields">
|
||||
<label for="{{ field }}" class="col-2 col-form-label col-form-label-sm">{{ namedFields[field] }}</label>
|
||||
<div class="col-10">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="claim[field]" ng-if="field != 'state' && field != 'priority' && field != 'creation' && field != 'id_team' && field != 'id_assignee' && field != 'description'">
|
||||
<input type="text" class="form-control form-control-sm" id="{{ field }}" ng-model="claim[field]" ng-if="field != 'state' && field != 'priority' && field != 'creation' && field != 'id_team' && field != 'id_exercice' && field != 'id_assignee' && field != 'description'">
|
||||
<input type="datetime" class="form-control form-control-sm" id="{{ field }}" ng-model="claim[field]" ng-if="field == 'creation' && claim.id">
|
||||
<select class="custom-select custom-select-sm" id="{{ field }}" ng-model="claim[field]" ng-options="k as v for (k, v) in states" ng-if="field == 'state'"></select>
|
||||
<select class="custom-select custom-select-sm" id="{{ field }}" ng-model="claim[field]" ng-options="k as v for (k, v) in priorities" ng-if="field == 'priority'"><option value="medium">Par défaut</option></select>
|
||||
<select class="custom-select custom-select-sm" id="{{ field }}" ng-model="claim[field]" ng-options="ex.id as ex.title group by ex.path.split('/')[0] for ex in exercices" ng-if="field == 'id_exercice'"><option></option></select>
|
||||
<select class="custom-select custom-select-sm" id="{{ field }}" ng-model="claim[field]" ng-options="k as t.name for (k, t) in teams" ng-if="field == 'id_team' && !claim.id"><option></option></select>
|
||||
<select class="custom-select custom-select-sm" id="{{ field }}" ng-model="claim[field]" ng-options="k as t.name for (k, t) in teams" ng-if="field == 'id_team' && claim.id"><option></option></select>
|
||||
<div class="input-group" ng-if="field == 'id_team' && claim.id">
|
||||
<select class="custom-select custom-select-sm" id="{{ field }}" ng-model="claim[field]" ng-options="k as t.name for (k, t) in teams"><option></option></select>
|
||||
<div class="input-group-append" ng-if="claim.id_team">
|
||||
<a type="button" class="btn btn-sm btn-outline-secondary" ng-href="teams/{{ claim.id_team }}">Aller à l'équipe</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="input-group" ng-if="field == 'id_assignee'">
|
||||
<select class="custom-select custom-select-sm" id="{{ field }}" ng-model="claim[field]" ng-options="a.id as a.name for a in assignees"><option></option></select>
|
||||
<div class="input-group-append" ng-if="whoami">
|
||||
<button type="button" class="btn btn-sm" ng-class="{'disabled': whoami == claim[field]}" ng-click="assignToMe()">Me l'assigner</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-primary" ng-class="{'disabled': whoami == claim[field]}" ng-click="assignToMe()">Me l'assigner</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -36,7 +42,11 @@
|
|||
<textarea class="form-control form-control-sm" placeholder="Ajouter un commentaire" rows="1" id="ndescription" ng-model="ndescription" autofocus></textarea>
|
||||
</div>
|
||||
|
||||
<div ng-repeat="description in claim.descriptions | orderBy:'id':true" class="alert text-light" ng-class="{'alert-info': '' + description.id_assignee != whoami, 'alert-dark': '' + description.id_assignee == whoami}">
|
||||
<div class="form-group text-right" ng-show="claim.id && ndescription.length">
|
||||
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-save" aria-hidden="true"></span> Ajouter commentaire</button>
|
||||
</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}">
|
||||
<strong>Par <em ng-if="!description.id_assignee">anonymous</em> <span ng-repeat="assignee in assignees" ng-if="assignee.id == description.id_assignee">{{ assignee.name }}</span> le {{ description.date | date:"mediumTime" }} :</strong>
|
||||
{{ description.content }}
|
||||
</div>
|
||||
|
|
|
|||
Reference in a new issue