From b8c9998171b1d12ff3f15a9b2d984f0653c1afee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20K=C3=A4stle?= <sven.kaestle@gmx.de> Date: Thu, 6 Sep 2018 15:48:36 +0200 Subject: [PATCH] feat: Show user created submission parts on the project page --- .../main/webapp/assets/js/project-student.js | 82 +++++++++++++++++-- .../src/main/webapp/pages/project-student.jsp | 9 +- 2 files changed, 78 insertions(+), 13 deletions(-) diff --git a/gemeinsamforschen/src/main/webapp/assets/js/project-student.js b/gemeinsamforschen/src/main/webapp/assets/js/project-student.js index 3a487384..59d86b77 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/project-student.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/project-student.js @@ -1,4 +1,22 @@ $(document).ready(function(){ + // fetch all submission part project representations from database + getSubmissionPartsByProjectId(getProjectIdFromUrl(), function (response) { + + // iterate over response and display each element + for (let i = 0; i < response.length; i++) { + displaySubmission(response[i].user, response[i].category, response[i].fullSubmissionId); + } + + // add click listener to feedback buttons + $('.annotationview').click(function () { + location.href="annotation-document.jsp?token="+getUserTokenFromUrl(); + }); + + }, function () { + // display empty view + displayEmptyView() + }); + /* var memberTable = $('#myGroupMembers'); memberTable.hide(); @@ -13,11 +31,65 @@ $(document).ready(function(){ location.href="viewfeedback.jsp?token="+getUserTokenFromUrl(); }); - $('.annotationview').click(function () { - location.href="annotation-document.jsp?token="+getUserTokenFromUrl(); - }); - $('#btnUnstructuredUpload').click(function () { location.href="unstructured-upload.jsp?token="+getUserTokenFromUrl() + "&projectId=" + getProjectIdFromUrl(); }) -}); \ No newline at end of file +}); + +/** + * Display category of submission part in list + * + * @param user The user of the submission part + * @param category The category of the submission part + * @param fullSubmissionId The id of the full submission the submission part belongs to + */ +function displaySubmission(user, category, fullSubmissionId) { + // build link + $('#submissionUpload').append( + $('<li>') + .append($('<span>').append(category.toUpperCase() + " eingereicht")) + .append($('<a>').attr("class", "annotationview").attr("role", "button") + .append($('<label>').css("font-size", "10px") + .append($('<i>').attr("class", "far fa-comments").css("font-size", "15px")) + .append("feedback") + ) + ) + ) + // add data to link + .data("fullSubmissionId", fullSubmissionId); +} + +/** + * Display a not found message if there are no submission parts in the database (or on error) + */ +function displayEmptyView() { + // build link + $('#submissionUpload').append( + $('<li>') + .append($('<span>').append("keine Daten gefunden")) + ); +} + +/** + * GET: Get all representations of a submission part for a given project id + * + * @param projectId The id of the project + * @param responseHandler The response handler + * @param errorHandler The error handler + */ +function getSubmissionPartsByProjectId(projectId, responseHandler, errorHandler) { + var url = "../rest/submissions/project/" + projectId; + $.ajax({ + url: url, + type: "GET", + dataType: "json", + success: function (response) { + // handle the response + responseHandler(response); + }, + error: function () { + // handle the error + errorHandler(); + } + }) +} \ No newline at end of file diff --git a/gemeinsamforschen/src/main/webapp/pages/project-student.jsp b/gemeinsamforschen/src/main/webapp/pages/project-student.jsp index 55567371..a8be6406 100644 --- a/gemeinsamforschen/src/main/webapp/pages/project-student.jsp +++ b/gemeinsamforschen/src/main/webapp/pages/project-student.jsp @@ -95,14 +95,7 @@ <img src="../assets/img/3.jpg"> <a href="#">student3@uni.de</a> <hr> - <ul> - <li> - "Viva la Floristika" - Titel hochgeladen - <a class="annotationview" role="button"> - <label style="font-size:10px;"><i class="far fa-comments" - style="font-size:15px;"></i>feedback</label> - </a> - </li> + <ul id="submissionUpload"> </ul> </td> -- GitLab