From 3aa2136ff0850562b4416797b592a3e953ab2635 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sven=20K=C3=A4stle?= <sven.kaestle@gmx.de> Date: Tue, 28 Aug 2018 20:42:57 +0200 Subject: [PATCH] feat: restore category annotations on page load --- .../assets/js/unstructuredAnnotation.js | 20 ++++++++++++++++--- .../main/webapp/assets/js/unstructuredRest.js | 7 +------ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/gemeinsamforschen/src/main/webapp/assets/js/unstructuredAnnotation.js b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredAnnotation.js index 9efba686..ecac045a 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/unstructuredAnnotation.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredAnnotation.js @@ -8,6 +8,22 @@ $(document).ready(function() { // set text in div $('#documentText').html(response.text); + // get submissions parts from database + getAllSubmissionParts(getSubmissionIdFromUrl(), function (response) { + + // iterate over response + for (var i = 0; i < response.length; i++) { + // save current category and body + let category = response[i].category; + let body = response[i].body; + // iterate over body and handle every selection + for (var j = 0; j < body.length; j++) { + handleCategorySelection(category.toLowerCase(), body[j].startCharacter, body[j].endCharacter); + } + } + + }); + }, function () { // jump to upload page on error location.href="unstructured-upload.jsp?token="+getUserTokenFromUrl(); @@ -17,9 +33,7 @@ $(document).ready(function() { $('#btnSave').click(function () { saveButtonHandler(); }); - - - + /** * Context menu handler */ diff --git a/gemeinsamforschen/src/main/webapp/assets/js/unstructuredRest.js b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredRest.js index 80d3b51f..819c8221 100644 --- a/gemeinsamforschen/src/main/webapp/assets/js/unstructuredRest.js +++ b/gemeinsamforschen/src/main/webapp/assets/js/unstructuredRest.js @@ -96,9 +96,8 @@ function getSubmissionPart(id, responseHandler, errorHandler) { * * @param id The id of the full submission * @param responseHandler The response handler - * @param errorHandler The error handler */ -function getAllSubmissionParts(id, responseHandler, errorHandler) { +function getAllSubmissionParts(id, responseHandler) { var url = "../rest/submissions/full/" + id + "/parts"; $.ajax({ url: url, @@ -107,10 +106,6 @@ function getAllSubmissionParts(id, responseHandler, errorHandler) { success: function (response) { // handle the response responseHandler(response); - }, - error: function () { - // handle the error - errorHandler(); } }) } \ No newline at end of file -- GitLab