admin: improve claims with menu

This commit is contained in:
Pierre-Olivier Mercier 2020-01-20 15:57:26 +01:00
parent 9186bbc229
commit 6f64eaed95
3 changed files with 32 additions and 11 deletions

View File

@ -1068,7 +1068,7 @@ angular.module("FICApp")
if ($routeParams.claimId == "new")
$scope.fields = ["id_team", "id_exercice", "subject", "priority", "id_assignee"];
else
$scope.fields = ["state", "subject", "priority", "id_exercice", "id_assignee", "id_team", "creation"];
$scope.fields = ["subject", "priority", "id_exercice", "id_assignee", "id_team", "creation", "state"];
$scope.assignees = ClaimAssignee.query();
$scope.whoami = Math.floor(getCookie("myassignee"));
$scope.teams = Teams.get();
@ -1099,10 +1099,15 @@ angular.module("FICApp")
"critical": "Critique",
};
$scope.changeState = function(state) {
this.claim.state = state;
if (this.claim.id)
this.saveClaim(false);
}
$scope.assignToMe = function() {
this.claim.id_assignee = $scope.whoami;
if (this.claim.id)
this.saveClaim();
this.saveClaim(false);
}
$scope.saveDescription = function() {
$http({
@ -1116,9 +1121,9 @@ angular.module("FICApp")
$location.url("/claims/" + $scope.claim.id + "/");
});
}
$scope.saveClaim = function() {
$scope.saveClaim = function(backToList) {
if (this.claim.id_team) {
this.claim.id_team = Math.floor(this.claim.id_team);
this.claim.id_team = parseInt(this.claim.id_team, 10);
} else {
this.claim.id_team = null;
}
@ -1127,13 +1132,19 @@ angular.module("FICApp")
v.id_team = "" + v.id_team;
if ($scope.ndescription)
$scope.saveDescription();
else
else if (backToList)
$location.url("/claims/");
else
$scope.claim = Claim.get({ claimId: $routeParams.claimId }, function(v) {
v.id_team = "" + v.id_team;
if (!v.priority)
v.priority = "medium";
});
});
} else {
this.claim.$save(function() {
if (!this.ndescription)
this.ndescription = "Création de la tâche";
if (!$scope.ndescription)
$scope.ndescription = "Création de la tâche";
$scope.saveDescription();
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when trying to save claim:', response.data.errmsg);

View File

@ -60,7 +60,7 @@
</tr>
</thead>
<tbody>
<tr ng-repeat="a in assignees" ng-click="edit(a)">
<tr ng-repeat="a in assignees" ng-click="edit(a)" ng-if="a.id !== 0">
<td>
{{ a.id }}
</td>

View File

@ -1,3 +1,13 @@
<div class="float-right btn-group ml-1" role="group" ng-if="claim.id">
<button class="btn btn-secondary" ng-if="claim.state != 'new'" ng-click="changeState('new')"><span class="glyphicon glyphicon-repeat" aria-hidden="true"></span> Nouveau</button>
<button class="btn btn-warning" ng-if="claim.state != 'need-info' && (claim.state == 'new' || claim.state == 'confirmed' || claim.state == 'in-progress')" ng-click="changeState('need-info')"><span class="glyphicon glyphicon-question-sign" aria-hidden="true"></span> Besoin d'infos</button>
<button class="btn btn-danger" ng-if="claim.state != 'confirmed'" ng-click="changeState('confirmed')"><span class="glyphicon glyphicon-ok-sign" aria-hidden="true"></span> Confirmer</button>
<button class="btn btn-info" ng-if="claim.state != 'in-progress' && (claim.state == 'need-info' || claim.state == 'confirmed' || claim.state == 'need-review')" ng-click="changeState('in-progress')"><span class="glyphicon glyphicon-hourglass" aria-hidden="true"></span> En cours</button>
<button class="btn btn-success" ng-if="claim.state != 'need-review' && (claim.state == 'in-progress' || claim.state == 'confirmed' || claim.state == 'need-info')" ng-click="changeState('need-review')"><span class="glyphicon glyphicon-saved" aria-hidden="true"></span> Fait</button>
<button class="btn btn-success" ng-if="claim.state != 'closed' && claim.state == 'need-review'" ng-click="changeState('closed')"><span class="glyphicon glyphicon-thumbs-down" aria-hidden="true"></span> Clore</button>
<button class="btn btn-dark" ng-if="claim.state != 'invalid' && (claim.state == 'new' || claim.state == 'need-info')" ng-click="changeState('invalid')"><span class="glyphicon glyphicon-save" aria-hidden="true"></span> Invalide</button>
</div>
<button class="float-right btn btn-primary" ng-if="claim.id && whoami && whoami != claim.id_assignee" ng-click="assignToMe()">Me l'assigner</button>
<h2>Tâche</h2>
<form ng-submit="saveClaim()" class="row">
@ -31,7 +41,7 @@
</div>
</div>
</div>
<div class="text-right" ng-show="claim.id">
<div class="text-right mb-3" ng-show="claim.id">
<button type="submit" class="btn btn-primary"><span class="glyphicon glyphicon-save" aria-hidden="true"></span> Save</button>
<button type="button" class="btn btn-danger" ng-click="deleteClaim()"><span class="glyphicon glyphicon-remove" aria-hidden="true"></span> Delete</button>
</div>
@ -52,8 +62,8 @@
</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 }}
<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>
</div>