branch develop updated (8030790 -> 2cf3d10)
This is an automated email from the git hooks/post-receive script. New change to branch develop in repository coselmar. See http://git.codelutin.com/coselmar.git from 8030790 Merge branch 'develop' of https://git.codelutin.com/coselmar into develop new ed39489 can remove file from document during save new 374ec38 be able in ui to remove document file new 2cf3d10 Merge branch 'feature/6549-modify-or-delete-document-file' into develop The 3 revisions listed above as "new" are entirely new to this repository and will be described in separate emails. The revisions listed as "adds" were already present in the repository and have only been added to this reference. Detailed log of new commits: commit 2cf3d10dd8ede318d5bf378f9c1e0f37e2502765 Merge: 8030790 374ec38 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 29 16:38:38 2015 +0100 Merge branch 'feature/6549-modify-or-delete-document-file' into develop 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 commit ed394897428a341dbc8198fca2052de44a00d047 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 29 15:59:22 2015 +0100 can remove file from document during save Summary of changes: .../coselmar/services/v1/DocumentsWebService.java | 31 +++++++++++++++++++--- 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 +++++++++++++---- 5 files changed, 67 insertions(+), 14 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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 ed394897428a341dbc8198fca2052de44a00d047 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 29 15:59:22 2015 +0100 can remove file from document during save --- .../coselmar/services/v1/DocumentsWebService.java | 31 +++++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java index df083b8..a2cd223 100644 --- a/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java +++ b/coselmar-rest/src/main/java/fr/ifremer/coselmar/services/v1/DocumentsWebService.java @@ -318,6 +318,12 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { String filePath = pathAndContentType.getLeft(); String contentType = pathAndContentType.getRight(); + // If document has already a file, remove it + if (StringUtils.isNotBlank(document.getFilePath())) { + File documentFile = new File(document.getFilePath()); + FileUtils.deleteQuietly(documentFile); + } + document.setWithFile(true); document.setMimeType(contentType); document.setFilePath(filePath); @@ -409,6 +415,12 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { // Resource part documentEntity.setExternalUrl(document.getExternalUrl()); + // If had file info and now no file info : remove file + boolean hadFile = documentEntity.isWithFile(); + if (hadFile && StringUtils.isBlank(document.getFileName())) { + deleteAttachedFile(documentEntity); + } + documentEntity.setComment(document.getComment()); @@ -455,10 +467,7 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { } // Delete physical file - if (StringUtils.isNotBlank(document.getFilePath())) { - File documentFile = new File(document.getFilePath()); - FileUtils.deleteQuietly(documentFile); - } + deleteAttachedFile(document); getDocumentDao().delete(document); @@ -594,4 +603,18 @@ public class DocumentsWebService extends CoselmarWebServiceSupport { return fullIds; } + /** + * Delete physically Document File, and update Document entity setting + * filePath and fileName to null and withFile boolean to false + */ + protected void deleteAttachedFile(Document document) { + if (StringUtils.isNotBlank(document.getFilePath())) { + File documentFile = new File(document.getFilePath()); + FileUtils.deleteQuietly(documentFile); + + document.setFilePath(null); + document.setFileName(null); + document.setWithFile(false); + } + } } -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
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>.
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 2cf3d10dd8ede318d5bf378f9c1e0f37e2502765 Merge: 8030790 374ec38 Author: Yannick Martel <martel@©odelutin.com> Date: Thu Jan 29 16:38:38 2015 +0100 Merge branch 'feature/6549-modify-or-delete-document-file' into develop .../coselmar/services/v1/DocumentsWebService.java | 31 +++++++++++++++++++--- 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 +++++++++++++---- 5 files changed, 67 insertions(+), 14 deletions(-) -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.
participants (1)
-
codelutin.com scm