admin: new form to update history coefficient

This commit is contained in:
nemunaire 2019-07-12 19:17:17 +02:00
parent 2b75287d16
commit ba5642da8f
5 changed files with 174 additions and 4 deletions

View file

@ -1289,6 +1289,28 @@ angular.module("FICApp")
.controller("ExerciceHistoryController", function($scope, ExerciceHistory, $routeParams, $http, $rootScope) {
$scope.history = ExerciceHistory.query({ exerciceId: $routeParams.exerciceId });
$scope.updHistory = function() {
var target = {
team_id: $("#updHistory").data("idteam"),
kind: $("#updHistory").data("kind"),
time: $("#updHistory").data("time"),
secondary: $("#updHistory").data("secondary") != "" ? $("#updHistory").data("secondary") : null,
coeff: parseFloat($('#historycoeff').val()),
};
if (target) {
$http({
url: "/api/exercices/" + $routeParams.exerciceId + "/history.json",
method: "PATCH",
data: target
}).then(function(response) {
$rootScope.staticFilesNeedUpdate++;
$scope.history = ExerciceHistory.query({ exerciceId: $routeParams.exerciceId });
$('#updHistory').modal('hide');
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when updating history item: ', response.data.errmsg);
});
}
}
$scope.delHistory = function(row) {
$http({
url: "/api/exercices/" + $routeParams.exerciceId + "/history.json",
@ -1594,6 +1616,28 @@ angular.module("FICApp")
})
.controller("TeamHistoryController", function($scope, TeamHistory, $routeParams, $http, $rootScope) {
$scope.history = TeamHistory.query({ teamId: $routeParams.teamId });
$scope.updHistory = function() {
var target = {
team_id: parseInt($routeParams.teamId),
kind: $("#updHistory").data("kind"),
time: $("#updHistory").data("time"),
secondary: $("#updHistory").data("secondary") != "" ? $("#updHistory").data("secondary") : null,
coeff: parseFloat($('#historycoeff').val()),
};
if (target) {
$http({
url: "/api/exercices/" + $("#updHistory").data("primary") + "/history.json",
method: "PATCH",
data: target
}).then(function(response) {
$rootScope.staticFilesNeedUpdate++;
$scope.history = TeamHistory.query({ teamId: $routeParams.teamId });
$('#updHistory').modal('hide');
}, function(response) {
$rootScope.newBox('danger', 'An error occurs when updating history item: ', response.data.errmsg);
});
}
}
$scope.delHistory = function(row) {
$http({
url: "/api/teams/" + $routeParams.teamId + "/history.json",