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 374ec384e93c655988180b20b56be62cbee00c76 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 29 16:37:58 2015 +0100 be able in ui to remove document file --- coselmar-ui/src/main/webapp/i18n/en.js | 1 + coselmar-ui/src/main/webapp/i18n/fr.js | 1 + .../src/main/webapp/js/coselmar-controllers.js | 23 +++++++++++++++----- .../main/webapp/views/documents/editDocument.html | 25 +++++++++++++++++----- 4 files changed, 40 insertions(+), 10 deletions(-) diff --git a/coselmar-ui/src/main/webapp/i18n/en.js b/coselmar-ui/src/main/webapp/i18n/en.js index 858dc94..6415140 100644 --- a/coselmar-ui/src/main/webapp/i18n/en.js +++ b/coselmar-ui/src/main/webapp/i18n/en.js @@ -110,6 +110,7 @@ var translateEN = { "document.button.download" : "Download", "document.button.openLink" : "Open link", +"document.button.removeFile" : "Remove file", //Questions part diff --git a/coselmar-ui/src/main/webapp/i18n/fr.js b/coselmar-ui/src/main/webapp/i18n/fr.js index a9663a5..e2982b6 100644 --- a/coselmar-ui/src/main/webapp/i18n/fr.js +++ b/coselmar-ui/src/main/webapp/i18n/fr.js @@ -110,6 +110,7 @@ var translateFR = { "document.button.download" : "Télécharger", "document.button.openLink" : "Ouvrir le lien", +"document.button.removeFile" : "Supprimer le fichier", //Questions part diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index 1c6db12..e9a17c8 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -193,6 +193,7 @@ coselmarControllers.controller("DocumentViewCtrl", function($scope, $route, $location, documentService, $routeParams, coselmarConfig) { $scope.container = {baseUrl : coselmarConfig.BASE_URL}; + $scope.upload = {}; $scope.editSession = $routeParams.edit ? $routeParams.edit : false; @@ -233,30 +234,42 @@ coselmarControllers.controller("DocumentViewCtrl", $scope.isFormValid = function() { var isValid = $scope.document.name && $scope.document.name.length > 0; - console.log(isValid); isValid = isValid && $scope.document.type && $scope.document.type.length > 0; isValid = isValid && $scope.document.keywords && $scope.document.keywords.length > 0; isValid = isValid && $scope.document.authors && $scope.document.authors.length > 0; isValid = isValid && $scope.document.copyright && $scope.document.copyright.length > 0; isValid = isValid && $scope.document.summary && $scope.document.summary.length > 0; if (!$scope.document.fileName) { - isValid = isValid && $scope.document.externalUrl && $scope.document.externalUrl.length > 0; + isValid = isValid && (($scope.document.externalUrl && $scope.document.externalUrl.length > 0) || $scope.upload.file); } return isValid; }; + $scope.removeFile = function() { + $scope.document.withFile = false; + $scope.document.fileName = undefined; + $scope.document.mimeType = undefined; + } + $scope.saveDocument = function(){ if (angular.isDate($scope.document.publicationDate)) { $scope.document.publicationDate = $scope.document.publicationDate.getTime(); } - // Call service to create a new document + // Call service to save document if ($scope.isFormValid()) { $scope.hasErrors = false; documentService.saveDocument($scope.document, function() { - $location.search(""); + if ($scope.upload.file) { + var documentId = $scope.document.id; + documentService.saveDocumentFile(documentId, $scope.upload.file, function() { + $location.search(""); + }); + } else { + $location.search(""); + } }, function(error) { console.log("error occurs"); } @@ -591,7 +604,7 @@ coselmarControllers.controller("QuestionsCtrl", ['$scope', '$route', '$routePara }]); -// Controller for All User View +// Controller for Question View coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParams', '$location', '$modal', 'questionsService', function($scope, $route, $routeParams, $location, $modal, questionsService){ diff --git a/coselmar-ui/src/main/webapp/views/documents/editDocument.html b/coselmar-ui/src/main/webapp/views/documents/editDocument.html index d398776..3864f43 100644 --- a/coselmar-ui/src/main/webapp/views/documents/editDocument.html +++ b/coselmar-ui/src/main/webapp/views/documents/editDocument.html @@ -109,12 +109,27 @@ <div> <label class="col-md-2 control-label">{{ 'document.metadata.file' | translate }}</label> - <div class="col-md-4"> + <div class="col-md-3" ng-if="document.fileName" > <input type="text" class="form-control" name="fileName" - data-ng-model="document.fileName" disabled="disabled" /> + data-ng-model="document.fileName" disabled="disabled"/> + + </div> + + <!-- if file, display way to remove it --> + <div class="col-md-1" ng-if="document.fileName" > + <button type="button" class="btn btn-danger fa fa-remove" + title="{{ 'document.button.removeFile' | translate}}" + ng-click="removeFile();"/> </div> - </div> + <!-- if no file, display input file to add new one --> + <div class="col-md-4" ng-if="!document.fileName" > + + <input type="file" class="form-control" name="uploadFile" + ng-file-model="upload.file" /> + + </div> + </div> <div> <label class="col-md-2 control-label">{{ 'document.metadata.externalUrl' | translate }}</label> @@ -125,8 +140,8 @@ </div> </div> - <p ng-show="!document.externalUrl && !documentForm.externalUrl.$pristine && !document.fileName" - class="help-block text-center clear">{{ 'document.message.requiredExternalUrl' | translate }}</p> + <p ng-show="!document.externalUrl && !document.fileName && !upload.file" + class="help-block text-center clear">{{ 'document.message.requiredExternalUrlOrFile' | translate }}</p> </div> <!-- Line with Keywords --> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.