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 f7060c24edbf0cb3870a0d02f299dd7718d6f248 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Dec 4 17:41:19 2014 +0100 add modal for document creation during question edit --- .../src/main/webapp/js/coselmar-controllers.js | 51 ++++- .../webapp/views/documents/modalDocumentEdit.html | 205 +++++++++++++++++++++ ...ocumentSearch.html => modalDocumentSearch.html} | 5 +- .../main/webapp/views/questions/editquestion.html | 2 +- 4 files changed, 260 insertions(+), 3 deletions(-) diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 0cb8cf2..c103428 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -317,7 +317,7 @@ coselmarControllers.controller("NewQuestionCtrl", ['$scope', '$route', '$locatio $scope.searchDocuments = function () { var modalInstance = $modal.open({ - templateUrl: 'views/documents/smallDocumentSearch.html', + templateUrl: 'views/documents/modalDocumentSearch.html', controller: 'ModalSearchDocumentsCtrl', size: 'lg' }); @@ -335,12 +335,34 @@ coselmarControllers.controller("NewQuestionCtrl", ['$scope', '$route', '$locatio }); }; + $scope.createDocument = function () { + + var modalInstance = $modal.open({ + templateUrl: 'views/documents/modalDocumentEdit.html', + controller: 'ModalCreateDocumentsCtrl', + 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) { @@ -365,6 +387,33 @@ coselmarControllers.controller('ModalSearchDocumentsCtrl', function ($scope, $mo }); +coselmarControllers.controller('ModalCreateDocumentsCtrl', function ($scope, $modalInstance, documentService) { + + $scope.document = {'privacy': 'PUBLIC'}; + $scope.upload = {}; + + $scope.existingKeywords = []; + + $scope.create = function (isValidForm) { + if (isValidForm) { + documentService.createDocument( + $scope.document, $scope.upload.file, function(document) { + $modalInstance.close(document); + + },function(error) { + //TODO ymartel 20141118 : deal with error.status or statusText + console.log("error occurs"); + console.log(error.s); + }); + } + }; + + $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/views/documents/modalDocumentEdit.html b/coselmar-ui/src/main/webapp/views/documents/modalDocumentEdit.html new file mode 100644 index 0000000..ba57ce6 --- /dev/null +++ b/coselmar-ui/src/main/webapp/views/documents/modalDocumentEdit.html @@ -0,0 +1,205 @@ +<div xmlns="http://www.w3.org/1999/html"> + <div class="modal-title"> + <h2>New Document</h2> + Field with <strong><big>*</big></strong> are mandatory. + </div> + + <form class="form-horizontal" name="documentForm" role="form" + ng-submit="createNewDocument(documentForm.$valid)"> + + <div class="modal-body"> + + + <!-- Line with Name and Type --> + <div class="form-group row"> + + <div class="" + ng-class="{'has-error' : documentForm.name.$invalid && !documentForm.name.$pristine}"> + <label class="col-md-2 control-label">Name *</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="name" + ng-model="document.name" required/> + + <p ng-show="documentForm.name.$invalid && !documentForm.name.$pristine" + class="help-block">Document name is required.</p> + </div> + </div> + + <div class="" + ng-class="{'has-error' : documentForm.type.$invalid && !documentForm.type.$pristine}"> + <label class="col-md-2 control-label">Type *</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="type" + ng-model="document.type" required/> + + <p ng-show="documentForm.type.$invalid && !documentForm.type.$pristine" + class="help-block">Document type is required.</p> + </div> + </div> + </div> + <!-- End Line with name and Type --> + + <!-- Line with file and externalURL --> + <div class="form-group" + ng-class="{'has-error' : + !documentForm.externalUrl.$invalid && !documentForm.externalUrl.$pristine && + !upload.file}"> + <div class=""> + <label class="col-md-2 control-label">File</label> + + <div class="col-md-4"> + <input type="file" class="form-control" name="uploadFile" + ng-file-model="upload.file"/> + </div> + </div> + + <div class=""> + <label class="col-md-2 control-label">External URL</label> + + <div class="col-md-4"> + <input type="input" class="form-control" name="externalUrl" + ng-model="document.externalUrl" ng-minlength="6"/> + + </div> + </div> + <p ng-show="!document.externalUrl && !file.upload" + class="help-block text-center">A File or an external URL is + required.</p> + </div> + <!-- End Line with file and externalURL --> + + + <!-- Line with keywords and privacy --> + <div class="form-group"> + <div + ng-class="{'has-error' : documentForm.keywords.$invalid && !documentForm.keywords.$pristine}"> + <label class="col-md-2 control-label">keywords *</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="keywords" + ng-model="document.keywords" ng-list required + placeholder="keyword 1, keyword2"/> + + <p ng-show="documentForm.keywords.$invalid && !documentForm.keywords.$pristine" + class="help-block">At least one keyword is required.</p> + </div> + </div> + + <div class=""> + <label class="col-md-2 control-label">Privacy</label> + + <div class="col-md-4"> + <select class="form-control" name="privacy" + ng-model="document.privacy"> + <option value="PRIVATE">Private</option> + <option value="PUBLIC">Public</option> + <option value="RESTRICTED">Restricted to current Question</option> + </select> + + </div> + + </div> + </div> + <!-- End Line with keywords and privacy --> + + <!-- Line with publication Date, Authors and Language --> + <div class="form-group"> + <div class=""> + <label class="col-md-2 control-label">Publication date</label> + + <div class="col-md-2"> + <div class="input-group"> + <input type="text" class="form-control" name="publicationDate" + ng-model="document.publicationDate" + datepicker-popup="dd/MM/yyyy" + is-open="publicationDateOpened" + ng-click="publicationDateOpened = true"/> + <span class="input-group-addon"><span class="fa fa-calendar" + aria-hidden="true"></span></span> + </div> + </div> + </div> + + <div class="" + ng-class="{'has-error' : documentForm.authors.$invalid && !documentForm.authors.$pristine}"> + <label class="col-md-1 control-label">Authors</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="authors" + ng-model="document.authors" required/> + + <p ng-show="documentForm.authors.$invalid && !documentForm.authors.$pristine" + class="help-block">Document authors is required.</p> + </div> + </div> + + <div class=""> + <label class="col-md-1 control-label">Language</label> + + <div class="col-md-2"> + <input type="text" class="form-control" name="language" + ng-model="document.language"/> + </div> + </div> + </div> + <!-- End Line with publication Date, Authors and Language --> + + <!-- Line with Copyright and Licence --> + <div class="form-group"> + <div + ng-class="{'has-error' : documentForm.copyright.$invalid && !documentForm.copyright.$pristine}"> + <label class="col-md-2 control-label">Copyright *</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="copyright" + ng-model="document.copyright" required/> + + <p ng-show="documentForm.copyright.$invalid && !documentForm.copyright.$pristine" + class="help-block">Copyright is required.</p> + </div> + </div> + + <div class="form-group"> + <label class="col-md-2 control-label">Licence</label> + + <div class="col-md-4"> + <input type="text" class="form-control" name="licence" + ng-model="document.licence"/> + </div> + </div> + </div> + <!-- End Line with Copyright and Licence --> + + <!-- End Line with Summary --> + <div class="form-group" + ng-class="{'has-error' : documentForm.summary.$invalid && !documentForm.summary.$pristine}"> + <label class="col-md-2 control-label">Summary</label> + + <div class="col-md-10"> + <textarea type="text" class="form-control" name="summary" rows="5" + ng-model="document.summary" required/> + + <p ng-show="documentForm.summary.$invalid && !documentForm.summary.$pristine" + class="help-block">A summary is required.</p> + </div> + </div> + + <div class="form-group"> + <div style="float-right col-md-4"> + <input type="submit" value="Submit" class="btn btn-primary" + ng-if="documentForm.$valid && privacy != 'RESTRICTED'"/> + </div> + </div> + + </div> + + <div class="modal-footer"> + <input type="submit" class="btn btn-primary" ng-click="create()"/> + <button class="btn btn-warning" ng-click="cancel()">Cancel</button> + </div> + + </form> + +</div> \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/documents/smallDocumentSearch.html b/coselmar-ui/src/main/webapp/views/documents/modalDocumentSearch.html similarity index 89% rename from coselmar-ui/src/main/webapp/views/documents/smallDocumentSearch.html rename to coselmar-ui/src/main/webapp/views/documents/modalDocumentSearch.html index 97fe884..009d325 100644 --- a/coselmar-ui/src/main/webapp/views/documents/smallDocumentSearch.html +++ b/coselmar-ui/src/main/webapp/views/documents/modalDocumentSearch.html @@ -1,6 +1,6 @@ <div style="padding: 0px 0px 0px 30px"> - <div class="page-header" style="margin: 0"> + <div class="page-header"> <h1> <!-- Heading goes here --> Search Documents @@ -39,4 +39,7 @@ </tr> </table> </div> + <div class="modal-footer"> + <button class="btn btn-warning" ng-click="cancel()">Cancel</button> + </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 0d4ea7f..9dc0507 100644 --- a/coselmar-ui/src/main/webapp/views/questions/editquestion.html +++ b/coselmar-ui/src/main/webapp/views/questions/editquestion.html @@ -231,7 +231,7 @@ <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=""/>--> + <a class="btn fa fa-plus" title="Add new Document" ng-click="createDocument()"/> </th> </tr> <tr ng-repeat="document in question.relatedDocuments"> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.