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 a07d6d4bef75f896c25e9a76e89a94938f9c548b Author: Yannick Martel <martel@©odelutin.com> Date: Fri Jan 9 11:45:41 2015 +0100 enable search on referential page --- .../src/main/webapp/js/coselmar-controllers.js | 50 +++++++++++-------- .../src/main/webapp/js/coselmar-services.js | 15 ++---- .../main/webapp/views/referential/referential.html | 57 +++++++++++++++++----- 3 files changed, 78 insertions(+), 44 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index f2402cc..627db7d 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -83,7 +83,9 @@ coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routePara $scope.searchKeywords.push(keywords); } - documentService.getDocuments($scope); + documentService.getDocuments([], function(documents) { + $scope.documents = documents; + }); $scope.deleteDocument = function(documentId){ @@ -775,13 +777,15 @@ coselmarControllers.controller('ModalSearchDocumentsCtrl', function ($scope, $mo $scope.searchKeywords = []; - documentService.getDocuments($scope); + documentService.getDocuments([], function(documents) { + $scope.documents = documents; + }); $scope.searchDocuments = function(searchKeywords) { - $scope.searchKeywords = searchKeywords; - documentService.getDocuments($scope); - - } + documentService.getDocuments(searchKeywords, function(documents) { + $scope.documents = documents; + }); + }; $scope.select = function (document) { $modalInstance.close(document); @@ -882,13 +886,15 @@ coselmarControllers.controller('ModalCreateDocumentsCtrl', function ($scope, $mo ///////////////////////////////////////////////// // Controller for Referential Page -coselmarControllers.controller("ReferentialCtrl", ['$scope', '$routeParams', '$location', - function($scope, $routeParams, $location){ +coselmarControllers.controller("ReferentialCtrl", ['$scope', '$routeParams', '$location', 'questionsService', 'documentService', + function($scope, $routeParams, $location, questionsService, documentService){ //manage keywords if given - $scope.search = { keywords : [], results : [], onDocuments: false, onQuestions: false }; + $scope.search = { keywords : [], onDocuments: false, onQuestions: false }; + $scope.result = { questions : [], documents : []}; var keywords = $routeParams.keywords; + console.log(keywords); if (Array.isArray(keywords)) { $scope.search.keywords = keywords; } else if (keywords) { @@ -897,7 +903,6 @@ coselmarControllers.controller("ReferentialCtrl", ['$scope', '$routeParams', '$l var onQuestions = $routeParams.onQuestions; if (onQuestions) { - console.log(onQuestions); $scope.search.onQuestions = onQuestions; } @@ -907,23 +912,26 @@ coselmarControllers.controller("ReferentialCtrl", ['$scope', '$routeParams', '$l } var remoteSearchInReferential = function() { - console.log("TODO : call server"); -// referentialService.find($scope.search, function(results) { -// -// $scope.search.results = results -// -// }, function(error) { -// //TODO ymartel 20141211 : deal with error.status or statusText -// console.log("error occurs"); -// console.log(error.s); -// } -// ); + if ($scope.search.onQuestions && $scope.search.keywords.length > 0) { + var questionSearchOptions = { 'privacy' : '', 'status' : '', 'keywords' : $scope.search.keywords}; + questionsService.getQuestions(questionSearchOptions, function(questions) { + $scope.result.questions = questions; + }); + }; + + if ($scope.search.onDocuments && $scope.search.keywords.length > 0) { + documentService.getDocuments($scope.search.keywords, function(documents) { + $scope.result.documents = documents; + }); + }; + }; remoteSearchInReferential(); $scope.searchInReferential = function(){ + console.log($scope.search.keywords); if ($scope.search.keywords) { $location.search('keywords', $scope.search.keywords); } else { diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 55a30fb..7ba27db 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -78,20 +78,11 @@ function Document(resource, config){ }); }; - this.getDocuments = function(scope){ + this.getDocuments = function(searchKeywords, successFunction){ // Load all documents - var docResource = resource(baseURL, {searchKeywords : scope.searchKeywords}); - docResource.query(function(documents){ - scope.documents = documents; - }, function(errorResult) { - // let's log errors - if(errorResult.status === 404) { - console.log("Service unreachable dis donc !"); - } else { - console.log("WTF ?!?"); - } - }); + var docResource = resource(baseURL, {searchKeywords : searchKeywords}); + docResource.query(successFunction); }; this.findAllTypes = function(successFunction){ diff --git a/coselmar-ui/src/main/webapp/views/referential/referential.html b/coselmar-ui/src/main/webapp/views/referential/referential.html index e025162..922565d 100644 --- a/coselmar-ui/src/main/webapp/views/referential/referential.html +++ b/coselmar-ui/src/main/webapp/views/referential/referential.html @@ -31,7 +31,7 @@ <label class="col-md-2 control-label">Keywords</label> <div class="col-md-4"> - <input type="text" class="form-control" name="keywords" ng-minlength="10" + <input type="text" class="form-control" name="keywords" ng-model="search.keywords" ng-list placeholder="keyword 1, keyword2"/> </div> @@ -59,24 +59,59 @@ </div> <!-- End Search Line --> - <div class=""> + <hr/> - <table class="table"> + <!-- Documents Table --> + <div class="" ng-if="result.documents && result.documents.length > 0"> + + <h3>{{result.documents.length}} document<span ng-if="result.documents.length > 1">s</span> found</h3> + + <table class="table" title="Documents"> + <tr> + <th>Name</th> + <th>Deposit Date</th> + <th>Authors</th> + <th>Keywords</th> + </tr> + <tr ng-repeat="document in result.documents"> + <td> + <a href="#/documents/{{document.id}}" target="_blank" + tooltip-placement="bottom" tooltip-html-unsafe="{{document.summary}}">{{document.name}}</a> + </td> + <td>{{document.depositDate | date:'mediumDate'}}</td> + <td>{{document.authors}}</td> + <td><span ng-repeat="keyword in document.keywords">{{keyword}} ,</span></td> + </tr> + </table> + + </div> + <!-- End of Documents Table --> + + + <!-- Questions Table --> + <div class="" ng-if="result.questions && result.questions.length > 0"> + + <h3>{{result.questions.length}} question<span ng-if="result.questions.length > 1">s</span> found</h3> + + <table class="table" title="Questions"> <tr> - <th>Type</th> <th>Title</th> <th>Deposit Date</th> - <th>Head</th> + <th>Themes</th> + <th>Status</th> </tr> - <tr ng-repeat="content in search.results"> - <td>{{content.type}}</td> - <td ng-if="content.type.toLowerCase() == 'document'"><a href="#/documents/{{content.id}}">{{content.title}}</a></td> - <td ng-if="content.type.toLowerCase() == 'question'"><a href="#/questions/{{content.id}}">{{content.title}}</a></td> - <td>{{content.depositDate}}</td> - <td>{{content.head}}</td> + <tr ng-repeat="question in result.questions"> + <td ng-if="currentUser.role != 'MEMBER'"> + <a href="#/questions/{{question.id}}" target="_blank" + tooltip-placement="bottom" tooltip-html-unsafe="{{question.summary}}">{{question.title}}</a> + </td> + <td>{{question.submissionDate | date:'mediumDate'}}</td> + <td><span ng-repeat="theme in question.themes">{{theme}}, </span></td> + <td>{{question.status}}</td> </tr> </table> </div> + <!-- End of Questions Table --> </div> \ No newline at end of file -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.