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 27fa957f3263c14ac4eb532c53e9a4b313807a67 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Dec 4 16:16:01 2014 +0100 can add existing documents in questions --- coselmar-ui/src/main/webapp/index.html | 2 +- .../src/main/webapp/js/coselmar-controllers.js | 58 +++++++++++++++++++++- .../src/main/webapp/js/coselmar-services.js | 1 - .../views/documents/smallDocumentSearch.html | 42 ++++++++++++++++ .../main/webapp/views/questions/editquestion.html | 37 ++++++++++++-- 5 files changed, 132 insertions(+), 8 deletions(-) diff --git a/coselmar-ui/src/main/webapp/index.html b/coselmar-ui/src/main/webapp/index.html index b81be28..7bf3104 100644 --- a/coselmar-ui/src/main/webapp/index.html +++ b/coselmar-ui/src/main/webapp/index.html @@ -102,7 +102,7 @@ </div> <form class="navbar-form navbar-right" role="form" ng-if="currentUser"> - <div class="form-group">{{currentUser.firstName}} {{currentUser.lastName}} <a href="#/users/{{currentUser.userId}}?edit" class="glyphicon glyphicon-pencil"></a></div> + <div class="form-group">{{currentUser.firstName}} {{currentUser.lastName}} <a href="#/users/{{currentUser.userId}}?edit" class="fa fa-pencil"></a></div> <button type="submit" class="btn btn-danger" ng-click="logout()">Logout</button> </form> </nav> diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 2587787..0cb8cf2 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -267,9 +267,14 @@ coselmarControllers.controller("UserViewCtrl", ///////////////////////////////////////////////// // Controller for new question View -coselmarControllers.controller("NewQuestionCtrl", ['$scope', '$route', '$location', 'questionsService', function($scope, $route, $location, questionsService){ +coselmarControllers.controller("NewQuestionCtrl", ['$scope', '$route', '$location', '$modal', + 'questionsService', 'userService', 'documentService', + function($scope, $route, $location, $modal, + questionsService, userService, documentService){ - $scope.question = {'privacy' : 'PUBLIC', 'themes' : [], 'experts' : [], 'clients' : [], 'externalExperts' : []}; + $scope.question = {'privacy' : 'PUBLIC', + 'themes' : [], 'experts' : [], 'externalExperts' : [], + 'clients' : [], 'relatedDocuments': [] }; $scope.users = { 'experts' : [], 'clients': [], 'supervisors' : []}; questionsService.findUsers({'role': 'EXPERT', 'active': 'true'}, function(users) { @@ -309,8 +314,57 @@ coselmarControllers.controller("NewQuestionCtrl", ['$scope', '$route', '$locatio } } + $scope.searchDocuments = function () { + + var modalInstance = $modal.open({ + templateUrl: 'views/documents/smallDocumentSearch.html', + controller: 'ModalSearchDocumentsCtrl', + size: 'lg' + }); + + modalInstance.result.then(function (selectedDocument) { + var already = false; + for (var i = 0; i < $scope.question.relatedDocuments.length; i++) { + if ($scope.question.relatedDocuments[i].id == selectedDocument.id) { + already = true + } + } + if (!already) { + $scope.question.relatedDocuments.push(selectedDocument); + } + }); + }; + + $scope.removeDocument = function(document) { + var position = $scope.question.relatedDocuments.indexOf(document); + if (document && position != -1) { + $scope.question.relatedDocuments.splice(position, 1); + } + } }]); +coselmarControllers.controller('ModalSearchDocumentsCtrl', function ($scope, $modalInstance, documentService) { + + $scope.searchKeywords = []; + + documentService.getDocuments($scope); + + $scope.searchDocuments = function(searchKeywords) { + $scope.searchKeywords = searchKeywords; + documentService.getDocuments($scope); + + } + + $scope.select = function (document) { + $modalInstance.close(document); + }; + + $scope.cancel = function () { + $modalInstance.dismiss('cancel'); + }; + +}); + /** * AngularJS default filter with the following expression: * "person in people | filter: {name: $select.search, age: $select.search}" diff --git a/coselmar-ui/src/main/webapp/js/coselmar-services.js b/coselmar-ui/src/main/webapp/js/coselmar-services.js index 2d236b3..709b9e9 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-services.js @@ -80,7 +80,6 @@ function Document(resource, config){ this.getDocuments = function(scope){ // Load all documents - console.log("loading all documents"); var docResource = resource(baseURL, {searchKeywords : scope.searchKeywords}); docResource.query(function(documents){ diff --git a/coselmar-ui/src/main/webapp/views/documents/smallDocumentSearch.html b/coselmar-ui/src/main/webapp/views/documents/smallDocumentSearch.html new file mode 100644 index 0000000..97fe884 --- /dev/null +++ b/coselmar-ui/src/main/webapp/views/documents/smallDocumentSearch.html @@ -0,0 +1,42 @@ + +<div style="padding: 0px 0px 0px 30px"> + <div class="page-header" style="margin: 0"> + <h1> + <!-- Heading goes here --> + Search Documents + </h1> + </div> + + <div> + <div> + <form class="form-inline pull-right" role="documentOptions" ng-submit="searchDocuments(searchKeywords)"> + <div class="form-group"> + <input type="search" class="form-control" placeholder="keyword1,keyword2,..." ng-model="searchKeywords" ng-list /> + </div> + <div class="form-group"> + <button type="submit" class="btn btn-default fa fa-search"></button> + </div> + </form> + </div> + <br/> + <table class="table"> + <tr> + <th>Name</th> + <th>Owner</th> + <th>Privacy</th> + <th>Keywords</th> + <th>Deposit Date</th> + <th></th> + </tr> + <tr ng-repeat="document in documents"> + <td><a href="#/documents/{{document.id}}" target="_blank">{{document.name}}</a></td> + <td>{{document.ownerName}}</td> + <td>{{document.privacy}}</td> + <td><span ng-repeat="keyword in document.keywords">{{keyword}} ,</span></td> + <td>{{document.depositDate | date:'mediumDate'}}</td> + <td> + <a class="btn fa fa-plus" title="Add Document" ng-click="select(document)"/></td> + </tr> + </table> + </div> +</div> \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/questions/editquestion.html b/coselmar-ui/src/main/webapp/views/questions/editquestion.html index ebc2702..0d4ea7f 100644 --- a/coselmar-ui/src/main/webapp/views/questions/editquestion.html +++ b/coselmar-ui/src/main/webapp/views/questions/editquestion.html @@ -214,10 +214,39 @@ <!-- End Line with External Experts and Supervisor --> - <!-- datalist for Experts --> - <datalist id="expertList"> - <option data-ng-repeat="expert in users.experts" value="{{expert}}"> pouet </option> - </datalist> + + <!-- Line with Related Document --> + + <div class="form-group" > + + + <label class="col-md-2 control-label">Related Documents</label> + + <div class="col-md-10"> + <table class="table table-bordered table-condensed"> + <tr> + <th>Name</th> + <th>Owner</th> + <th>Keywords</th> + <th>Deposit Date</th> + <th> + <a class="btn fa fa-search" title="Search document" ng-click="searchDocuments()" /> + <!--<a class="btn fa fa-plus" title="Add Document" ng-click=""/>--> + </th> + </tr> + <tr ng-repeat="document in question.relatedDocuments"> + <td>{{document.name}}</a></td> + <td>{{document.ownerName}}</td> + <td><span ng-repeat="keyword in document.keywords">{{keyword}}, </span></td> + <td>{{document.depositDate | date:'mediumDate'}}</td> + <td><a class="btn fa fa-minus" title="Remove document" ng-click="removeDocument(document)"/></td> + </tr> + </table> + </div> + + </div> + + <!-- End Line with Related Document --> <div class="form-group" ng-if="questionForm.$valid && question.themes.length > 0"> <div style="padding-left: 200px"> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.