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 f7f0ac087573298e1d87b65d4810e8d0ea9fad9e Author: Yannick Martel <martel@©odelutin.com> Date: Mon Jan 11 14:51:17 2016 +0100 refs-30 #7894 prepare modal presentation of project hierarchy --- coselmar-ui/src/main/webapp/i18n/en.js | 4 + coselmar-ui/src/main/webapp/i18n/fr.js | 4 + .../src/main/webapp/js/coselmar-controllers.js | 94 ++++++++++++++++++++++ .../main/webapp/js/coselmar-questions-services.js | 12 +++ .../webapp/views/questions/modalHierarchy.html | 29 +++++++ .../main/webapp/views/questions/viewquestion.html | 2 +- 6 files changed, 144 insertions(+), 1 deletion(-) diff --git a/coselmar-ui/src/main/webapp/i18n/en.js b/coselmar-ui/src/main/webapp/i18n/en.js index 5571de6..c260b58 100644 --- a/coselmar-ui/src/main/webapp/i18n/en.js +++ b/coselmar-ui/src/main/webapp/i18n/en.js @@ -136,6 +136,7 @@ var translateEN = { "question.add.title" : "Add a Project", "question.newDocument.title" : "Contribute with new documents", "question.modal.parents.title" : "Assign parent project", +"question.modal.hierarchy.title" : "Tree view of project ", "question.metadata.title" : "Title", "question.metadata.type" : "Type", @@ -163,6 +164,8 @@ var translateEN = { "question.metadata.links" : "Associated Links", "question.metadata.links.display" : "Go further", +"question.metadata.hierarchy.display" : "Show tree view", + "question.metadata.submitBefore" : "Submit before", "question.metadata.submitAfter" : "Submit after", "question.metadata.deadlineBefore" : "Deadline before", @@ -312,6 +315,7 @@ var translateEN = { "common.button.edit" : "Modify", "common.button.add" : "Add", "common.button.cancel" : "Cancel", +"common.button.close" : "Close", "common.button.search" : "Search", "common.button.advanceSearch" : "Advance search", "common.button.simpleSearch" : "Simple search", diff --git a/coselmar-ui/src/main/webapp/i18n/fr.js b/coselmar-ui/src/main/webapp/i18n/fr.js index 6c5aeac..a878108 100644 --- a/coselmar-ui/src/main/webapp/i18n/fr.js +++ b/coselmar-ui/src/main/webapp/i18n/fr.js @@ -136,6 +136,7 @@ var translateFR = { "question.add.title" : "Ajouter un projet", "question.newDocument.title" : "Contribuer avec de nouveaux documents", "question.modal.parents.title" : "Désigner un projet parent", +"question.modal.hierarchy.title" : "Arborescence du projet", "question.metadata.title" : "Titre", "question.metadata.type" : "Type", @@ -163,6 +164,8 @@ var translateFR = { "question.metadata.links" : "Liens associés", "question.metadata.links.display" : "Pour aller plus loin", +"question.metadata.hierarchy.display" : "Voir l'arborescence", + "question.metadata.submitBefore" : "Soumis avant le", "question.metadata.submitAfter" : "Soumis après le", "question.metadata.deadlineBefore" : "Date limite avant le", @@ -312,6 +315,7 @@ var translateFR = { "common.button.edit" : "Éditer", "common.button.add" : "Ajouter", "common.button.cancel" : "Annuler", +"common.button.close" : "Fermer", "common.button.search" : "Rechercher", "common.button.advanceSearch" : "Recherche avancée", "common.button.simpleSearch" : "Recherche simple", diff --git a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js index e673704..c007ce9 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-controllers.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-controllers.js @@ -1462,6 +1462,19 @@ coselmarControllers.controller("QuestionCtrl", ['$scope', '$route', '$routeParam } }; + $scope.showModalQuestionHierarchy = function() { + + var modalInstance = $uibModal.open({ + templateUrl: 'views/questions/modalHierarchy.html', + controller: 'ModalQuestionHierarchyCtrl', + size: 'lg', + resolve : { + currentQuestion : $scope.question + } + }); + + }; + }]); coselmarControllers.controller('ModalSearchDocumentsCtrl', function ($scope, $uibModalInstance, documentService, errorService) { @@ -1606,6 +1619,87 @@ coselmarControllers.controller('ModalEditLinkCtrl', function ($scope, $uibModalI }); +coselmarControllers.controller('ModalQuestionHierarchyCtrl', function ($scope, $uibModalInstance, currentQuestion, questionsService) { + + $scope.question = currentQuestion; + $scope.depth = 2; + $scope.ancestors = []; + $scope.descendants = []; + $scope.hierarchyTree = { name : $scope.question.title, parents : [], children : [] }; + + + $scope.loadAncestors = function() { + var searchParams = { questionId : $scope.question.id, depth: $scope.depth}; + questionsService.getAncestors(searchParams, function(ancestors){ + $scope.ancestors = ancestors; + // load parents + angular.forEach($scope.ancestors, function(value, key) { + var parent = { name : value.title, isparent: true }; + var subParents = loadParents(value, $scope.depth - 1); + if (subParents.length > 0) { + parent.parents = subParents; + } + this.push(parent); + }, $scope.hierarchyTree.parents); + }); + }; + + $scope.loadDescendants = function() { + var searchParams = { questionId : $scope.question.id, depth: $scope.depth}; + questionsService.getDescendants(searchParams, function(descendants){ + $scope.descendants = descendants; + // load children + angular.forEach($scope.descendants, function(value, key) { + var child = { name : value.title, isparent: false }; + var subChildren = loadChildren(value, $scope.depth); + if (subChildren.length > 0) { + child.children = subChildren; + } + this.push(child); + }, $scope.hierarchyTree.children); + }); + }; + + var loadChildren = function(treeNode, depth) { + var children = []; + if (depth > 0) { + angular.forEach(treeNode.descendants, function(value, key) { + var child = { name : value.title, isparent: false }; + var subChildren = loadChildren(value, depth - 1); + if (subChildren.length > 0) { + child.children = subChildren; + } + this.push(child); + }, children) + } + return children; + }; + + var loadParents = function(treeNode, depth) { + var parents = []; + if (depth > 0) { + angular.forEach(treeNode.ancestors, function(value, key) { + var parent = { name : value.title, isparent: true }; + var subParents = loadParents(value, depth - 1); + if (subParents.length > 0) { + parent.parents = subParents; + } + this.push(parent); + }, parents) + } + return parents; + }; + + $scope.loadAncestors(); + $scope.loadDescendants(); + + $scope.cancel = function () { + $uibModalInstance.dismiss('cancel'); + }; + +}); + + ///////////////////////////////////////////////// /////////// Referential Part ////////////////// diff --git a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js index a466fe7..3b60067 100644 --- a/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js +++ b/coselmar-ui/src/main/webapp/js/coselmar-questions-services.js @@ -143,4 +143,16 @@ function Question(resource, http, config){ return exportURL; }; + this.getAncestors = function(searchParams, successFunction) { + var ancestorsURL = baseURL + "/" + searchParams.questionId + "/ancestors"; + var questionResource = resource(ancestorsURL, {'depth' : searchParams.depth}); + questionResource.query().$promise.then(successFunction); + }; + + this.getDescendants = function(searchParams, successFunction) { + var descendantsURL = baseURL + "/" + searchParams.questionId + "/descendants"; + var questionResource = resource(descendantsURL, {'depth' : searchParams.depth}); + questionResource.query().$promise.then(successFunction); + }; + }; \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/questions/modalHierarchy.html b/coselmar-ui/src/main/webapp/views/questions/modalHierarchy.html new file mode 100644 index 0000000..b76fc29 --- /dev/null +++ b/coselmar-ui/src/main/webapp/views/questions/modalHierarchy.html @@ -0,0 +1,29 @@ +<div xmlns="http://www.w3.org/1999/html"> + <div class="modal-title"> + <h2 class="paddingLeft20">{{ 'question.modal.hierarchy.title' | translate }} {{question.title}}</h2> + </div> + + <div class="modal-body"> + + <div id="questionHierarchy">{{hierarchyTree}}</div> + <div> + <ul> + <li ng-repeat="parent in ancestors"> + <a href="#/questions/{{parent.id}}" target="_blank">{{parent.title}}</a> + </li> + </ul> + </td> + <td> + <ul> + <li ng-repeat="child in descendants"> + <a href="#/questions/{{child.id}}" target="_blank">{{child.title}}</a> + </li> + </ul> + </div> + </div> + + <div class="modal-footer"> + <button class="btn btn-action btn-disable" ng-click="cancel()">{{ 'common.button.close' | translate }}</button> + </div> + +</div> \ No newline at end of file diff --git a/coselmar-ui/src/main/webapp/views/questions/viewquestion.html b/coselmar-ui/src/main/webapp/views/questions/viewquestion.html index 5c2aaec..5c83a52 100644 --- a/coselmar-ui/src/main/webapp/views/questions/viewquestion.html +++ b/coselmar-ui/src/main/webapp/views/questions/viewquestion.html @@ -96,7 +96,7 @@ </dl> <dl> - <dt>{{ 'document.metadata.relatedQuestions' | translate }}</dt> + <dt>{{ 'document.metadata.relatedQuestions' | translate }} - <a ng-click="showModalQuestionHierarchy()">{{ 'question.metadata.hierarchy.display' | translate }}</a></dt> <dd> <table class="table table-bordered table-condensed"> <thead> -- To stop receiving notification emails like this one, please contact codelutin.com SCM administrator <admin+scm@codelutin.com>.