This is an automated email from the git hooks/post-receive script. New commit to branch feature/6010-search-document in repository coselmar. See http://git.codelutin.com/coselmar.git commit 12bbb7c070d268d6fd35e00fa6104802f1855bc3 Author: Yannick Martel <martel@©odelutin.com> Date: Sat Nov 8 12:12:44 2014 +0100 enable document search on ui --- .../src/main/webapp/js/coselmar-controllers.js | 19 ++++++++++++++++--- coselmar-ui/src/main/webapp/js/coselmar-services.js | 6 ++---- coselmar-ui/src/main/webapp/views/documents.html | 12 +++++++++++- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 0fe4ced..d3a85d2 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -4,7 +4,17 @@ var coselmarControllers = angular.module('coselmarControllers', []); coselmarControllers.controller("HomeCtrl", ['$scope', function($scope){ }]); // Controller for All Documents View -coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', 'documentService', function($scope, $route, documentService){ +coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', '$routeParams', '$location', 'documentService', function($scope, $route, $routeParams, $location, documentService){ + + //manage keywords if given + $scope.searchKeywords = []; + var keywords = $routeParams.keywords; + if (Array.isArray(keywords)) { + $scope.searchKeywords = keywords; + } else if (keywords) { + $scope.searchKeywords.push(keywords); + } + documentService.getDocuments($scope); $scope.deleteDocument = function(documentId){ @@ -14,10 +24,13 @@ coselmarControllers.controller("DocumentsCtrl", ['$scope', '$route', 'documentSe // Go back to documents list $route.reload(); }); + }; - // Reload the page + $scope.searchDocuments = function(){ +// $route.current.params.keywords = $scope.searchKeywords; // $route.reload(); - }; + $location.search('keywords', $scope.searchKeywords); + } }]); diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 3ff7fca..fec056c 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -44,9 +44,6 @@ function Document(resource){ // Load the document var docResource = resource('http://localhost:8081/services/v1/documents/:documentId', {documentId:'@id'}); // var docResource = resource('v1/documents/:documentId', {documentId:'@documentId'}); -// docResource.delete({documentId:id}, function(){ -// route.reload(); -// }); docResource.delete({documentId:id}, successFunction); } @@ -62,7 +59,8 @@ function Document(resource){ this.getDocuments = function(scope){ // Load all documents console.log("loading all documents"); - var docResource = resource('http://localhost:8081/services/v1/documents'); + + var docResource = resource('http://localhost:8081/services/v1/documents', {searchKeywords : scope.searchKeywords}); // var docResource = resource('v1/documents'); docResource.query(function(documents){ scope.documents = documents; diff --git a/coselmar-ui/src/main/webapp/views/documents.html b/coselmar-ui/src/main/webapp/views/documents.html index 0c1426f..7403ae7 100644 --- a/coselmar-ui/src/main/webapp/views/documents.html +++ b/coselmar-ui/src/main/webapp/views/documents.html @@ -8,7 +8,17 @@ <div> <div> - <a href="#/documents/new" class="btn btn-primary">Add a document</a> + <div class="form-group"> + <a href="#/documents/new" class="form-inline navbar-left btn btn-primary">Add a document</a> + </div> + <form class="form-inline pull-right" role="documentOptions" ng-submit="searchDocuments()"> + <div class="form-group"> + <input type="search" class="form-control" placeholder="Search a document" ng-model="searchKeywords" ng-list /> + </div> + <div class="form-group"> + <button type="submit" class="btn btn-default glyphicon glyphicon-search"></button> + </div> + </form> </div> <table class="table"> <tr> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.