frontend: allow players to respond to issues

This commit is contained in:
nemunaire 2020-01-24 20:04:46 +01:00
commit edbac43423
8 changed files with 85 additions and 12 deletions

View file

@ -57,11 +57,15 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
controller: "MyTeamController",
templateUrl: "views/team-edit.html"
})
.when("/issue", {
.when("/issue/:eid", {
controller: "IssueController",
templateUrl: "views/issue.html"
})
.when("/issue/:eid", {
.when("/issues", {
controller: "IssueController",
templateUrl: "views/issue.html"
})
.when("/issues/:iid", {
controller: "IssueController",
templateUrl: "views/issue.html"
})
@ -227,10 +231,12 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
refreshIssuesInterval = $interval(refreshIssues, Math.floor(Math.random() * 24000) + 32000);
$http.get("issues.json").then(function(response) {
$rootScope.issues_idx = {};
$rootScope.issues_nb_responses = 0;
$rootScope.issues_need_info = 0;
$rootScope.issues = response.data;
$rootScope.issues.forEach(function(issue) {
$rootScope.issues_idx[issue.id] = issue;
$rootScope.issues_nb_responses += issue.texts.length;
if (issue.state == 'need-info') $rootScope.issues_need_info++;
})
@ -468,6 +474,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
}
refreshMy();
}
$rootScope.refreshIssues = refreshIssues;
$rootScope.refresh();
})
.controller("ExerciceController", function($scope, $routeParams, $http, $rootScope, $timeout) {
@ -669,6 +676,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
$rootScope.issues_known_responses = $rootScope.issues_nb_responses;
$scope.issue = {
id: parseInt($routeParams.iid, 10),
id_exercice: parseInt($routeParams.eid, 10),
subject: "",
description: "",
@ -676,9 +684,9 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
$scope.isubmit = function() {
$rootScope.sberr = "";
if ($scope.issue.subject.length < 3) {
if (!$scope.issue.id && $scope.issue.subject.length < 3) {
$rootScope.messageClass = {"text-danger": true};
$rootScope.sberr = "L'object de votre rapport d'anomalie est trop court !";
$rootScope.sberr = "L'objet de votre rapport d'anomalie est trop court !";
return false;
}
@ -691,6 +699,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
$rootScope.message = response.data.errmsg;
$scope.issue.subject = "";
$scope.issue.description = "";
setTimeout($rootScope.refreshIssues, 1750);
}, function(response) {
$rootScope.messageClass = {"text-danger": true};
$rootScope.message = response.data.errmsg;