This is an automated email from the git hooks/post-receive script. New commit to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git commit a5b20ba0ab8753ea6133750b37f2a26f4aad3091 Author: Yannick Martel <martel@©odelutin.com> Date: Wed Dec 10 10:58:13 2014 +0100 prepare full edit of question --- .../coselmar/services/v1/QuestionsWebService.java | 5 + .../src/main/webapp/js/coselmar-controllers.js | 140 +++++++++++++++++++-- .../main/webapp/js/coselmar-questions-services.js | 4 +- .../main/webapp/views/questions/editquestion.html | 9 +- .../main/webapp/views/questions/newquestion.html | 6 + .../src/main/webapp/views/questions/question.html | 10 +- 6 files changed, 154 insertions(+), 20 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java index 61e1b2e..e00230c 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/QuestionsWebService.java @@ -346,6 +346,11 @@ public class QuestionsWebService extends CoselmarWebServiceSupport { // Retrieve all documents Collection<Document> questionDocuments = question.getRelatedDocuments(); if (documents != null && documents.length > 0) { + // now with expert documents, question is in progress + if (question.getStatus() == Status.OPEN) { + question.setStatus(Status.IN_PROGRESS); + } + List<Document> documentEntities = retrieveDocuments(Lists.newArrayList(documents)); // Manage restriction list for document with Privacy.RESTRICTED for (Document document : documentEntities) { diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 0150ba5..793cd38 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -430,25 +430,103 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam $scope.isCurrentParticipant = false; $scope.question = { 'newRelatedDocuments': []}; + //to enter in edit mode from view $scope.edit = function() { $location.search("edit"); } + // Participants, clients and supervisors management for ui-select + $scope.participantsIndex = {}; + $scope.clientsIndex = {}; + $scope.supervisorsIndex = {}; + + $scope.users = { 'participants' : [], 'clients': [], 'supervisors' : []}; + + $scope.refreshExperts = function(searchKeyword) { + + questionsService.findUsers({'role': 'EXPERT', 'active': 'true'}, searchKeyword, function(users) { + $scope.users.participants = users; + $scope.participantsIndex = {}; + angular.forEach($scope.users.participants, function(participant) { + $scope.participantsIndex[participant.id] = participant; + }); + bindUsers($scope.question.participants, $scope.participantsIndex); + }); + } + + $scope.refreshClients = function(searchKeyword) { + + questionsService.findUsers({'role': 'CLIENT', 'active': 'true'}, searchKeyword, function(users) { + $scope.users.clients = users; + $scope.clientsIndex = {}; + angular.forEach($scope.users.clients, function(client) { + $scope.clientsIndex[client.id] = client; + }); + bindUsers($scope.question.clients, $scope.clientsIndex); + }); + } + + $scope.refreshSupervisors = function(searchKeyword) { + + questionsService.findUsers({'role': 'SUPERVISOR', 'active': 'true'}, searchKeyword, function(users) { + $scope.users.supervisors = users; + $scope.supervisorsIndex = {}; + angular.forEach($scope.users.supervisors, function(supervisor) { + $scope.supervisorsIndex[supervisor.id] = supervisor; + }); + bindUsers($scope.question.supervisors, $scope.supervisorsIndex); + }); + } + + // call refresh for init + $scope.refreshExperts(""); + $scope.refreshClients(""); + $scope.refreshSupervisors(""); + + // function to be sure to have same user objects in list + var bindUsers = function(toDeal, index) { + if (toDeal) { + for(var i = 0; i < toDeal.length; i++) { + var user = toDeal[i]; + if (index[user.id]) { + toDeal[i] = index[user.id]; + } + } + } + + }; + + questionsService.getQuestion($routeParams.questionId, function(question) { // success : just get the questions $scope.question = question; // update scope about current user : if he is participant, more option enable in ui - for (var i = 0; i < $scope.question.participants.length; i++) { - if ($scope.question.participants[i].id == $scope.currentUser.userId) { - $scope.isCurrentParticipant = true; - // Should be able to put new documents in question - $scope.question.newRelatedDocuments = []; - break; + if ($scope.question.participants) { + for (var i = 0; i < $scope.question.participants.length; i++) { + if ($scope.question.participants[i].id == $scope.currentUser.userId) { + $scope.isCurrentParticipant = true; + // Should be able to put new documents in question + $scope.question.newRelatedDocuments = []; + break; + } } } + if (question.participants) { + $scope.users.participants = question.participants; + bindUsers($scope.question.participants, $scope.participantsIndex); + } + if (question.clients) { + $scope.users.clients = question.clients; + bindUsers($scope.question.clients, $scope.clientsIndex); + } + if (question.supervisors) { + $scope.users.supervisors = question.supervisors; + bindUsers($scope.question.supervisors, $scope.supervisorsIndex); + } + }, function(error) { // Fail function : TODO console.log("error during request"); @@ -468,7 +546,42 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam }; $scope.saveQuestion = function(isValidForm){ - //TODO + if (angular.isDate($scope.question.deadline)) { + $scope.question.deadline = $scope.question.deadline.getTime(); + } + + // Call service to create a new user + if(isValidForm) { +// questionsService.saveQuestion($scope.question, function() { + $location.search(""); +// },function(error) { +// //TODO ymartel 20141118 : deal with error.status or statusText +// console.log("error occurs"); +// console.log(error.s); +// }); + } + }; + + $scope.closeQuestion = function(){ + $scope.question.status = "CLOSED"; + questionsService.saveQuestion($scope.question, function() { + $location.search(""); + },function(error) { + //TODO ymartel 20141118 : deal with error.status or statusText + console.log("error occurs"); + console.log(error.s); + }); + }; + + $scope.adjournQuestion = function(){ + $scope.question.status = "ADJOURNED"; + questionsService.saveQuestion($scope.question, function() { + $location.search(""); + },function(error) { + //TODO ymartel 20141118 : deal with error.status or statusText + console.log("error occurs"); + console.log(error.s); + }); }; // New documents added @@ -487,6 +600,19 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam } }; + $scope.addTheme = function(theme) { + if (theme && $scope.question.themes.indexOf(theme) == -1) { + $scope.question.themes.push(theme); + } + } + + $scope.removeTheme = function(theme) { + var position = $scope.question.themes.indexOf(theme); + if (theme && position != -1) { + $scope.question.themes.splice(position, 1); + } + } + // Modals part for documents $scope.modalSearchDocuments = function (documentList) { diff --git a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js index 5aa3448..873c215 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js @@ -32,8 +32,8 @@ function Question(resource, config){ questionResource.save(null, formData, successFunction, failFunction); }; - this.findUsers = function(example, successFunction) { - var userResource = resource(usersURL, {'like': example}); + this.findUsers = function(example, searchKeyword, successFunction) { + var userResource = resource(usersURL, {'like': example, 'fullSearch': searchKeyword}); userResource.query(successFunction); }; diff --git a/coselmar-ui/src/main/webapp/views/questions/editquestion.html b/coselmar-ui/src/main/webapp/views/questions/editquestion.html index c42e8e2..b8e5f70 100644 --- a/coselmar-ui/src/main/webapp/views/questions/editquestion.html +++ b/coselmar-ui/src/main/webapp/views/questions/editquestion.html @@ -131,7 +131,9 @@ </ui-select-match> <ui-select-choices - repeat="expert in users.participants track by expert.id | propsFilter: {name: $select.search, firstName: $select.search, organization: $select.search}"> + repeat="expert in users.participants track by expert.id | propsFilter: {name: $select.search, firstName: $select.search, organization: $select.search}" + refresh="refreshExperts($select.search)" + refresh-delay="1000"> {{expert.firstName}} {{expert.name}} ({{expert.organization}}) </ui-select-choices> </ui-select> @@ -250,10 +252,5 @@ <!-- End Line with Related Document --> - <div class="form-group" ng-if="questionForm.$valid && question.themes.length > 0"> - <div style="padding-left: 200px"> - <input type="submit" value="Validate" class="btn btn-primary" ng-click="saveQuestion(questionForm.$valid)"/> - </div> - </div> </form> </div> \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/questions/newquestion.html b/coselmar-ui/src/main/webapp/views/questions/newquestion.html index b05689b..7518ede 100644 --- a/coselmar-ui/src/main/webapp/views/questions/newquestion.html +++ b/coselmar-ui/src/main/webapp/views/questions/newquestion.html @@ -5,6 +5,12 @@ <div style="padding-bottom: 50px" ng-include="src='views/questions/editquestion.html'" ng-if="currentUser.role == 'SUPERVISOR'"> + + <div class="form-group" ng-if="questionForm.$valid && question.themes.length > 0"> + <div style="padding-left: 200px"> + <input type="submit" value="Validate" class="btn btn-primary" ng-click="saveQuestion(questionForm.$valid)"/> + </div> + </div> </div> <div style="padding-bottom: 50px" ng-if="currentUser.role != 'SUPERVISOR'"> diff --git a/coselmar-ui/src/main/webapp/views/questions/question.html b/coselmar-ui/src/main/webapp/views/questions/question.html index d5e53b8..28351c4 100644 --- a/coselmar-ui/src/main/webapp/views/questions/question.html +++ b/coselmar-ui/src/main/webapp/views/questions/question.html @@ -2,9 +2,9 @@ <div class="page-header" style="margin: 0"> <h2> {{question.title}} - <!--<a class="btn btn-action btn-edit pull-right" ng-click="edit()" ng-if="editMode != true">--> - <!--<span class="fa fa-edit" aria-hidden="true"></span>Edit--> - <!--</a>--> + <a class="btn btn-action btn-edit pull-right" ng-click="edit()" ng-if="editMode != true"> + <span class="fa fa-edit" aria-hidden="true"></span>Edit + </a> </h2> </div> @@ -15,8 +15,8 @@ <div style="padding-bottom: 50px" ng-if="editMode == true"> <div ng-include="src='views/questions/editquestion.html'"></div> - <div><a class="btn btn-action btn-success" ng-click="saveQuestion()"> - <span class="fa fa-check-square-o" aria-hidden="true"></span>Close + <div class="form-group"><a class="btn btn-action btn-success" ng-click="saveQuestion()"> + <span class="fa fa-check-square-o" aria-hidden="true"></span>Validate changes </a></div> </div> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.