From f32a9a19fbf5b4903d7236b147c264323d3767c7 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Wed, 11 Jan 2017 17:43:17 +0100 Subject: [PATCH] info about turing on/ogg comments is passed via session or GET param --- frontend-js/src/main/js/ServerConnector.js | 2 +- frontend-js/src/main/js/map/CustomMap.js | 21 ++++++++----------- .../main/js/map/overlay/CommentDbOverlay.js | 4 ++-- frontend-js/src/main/js/minerva.js | 16 +++++++++++--- 4 files changed, 25 insertions(+), 18 deletions(-) diff --git a/frontend-js/src/main/js/ServerConnector.js b/frontend-js/src/main/js/ServerConnector.js index 685ddcba4f..7c52cddad0 100644 --- a/frontend-js/src/main/js/ServerConnector.js +++ b/frontend-js/src/main/js/ServerConnector.js @@ -123,7 +123,7 @@ ServerConnector.addOverlayCollection = function(overlay) { if (overlay.constructor.name==="OverlayCollection") { throw new Error("Unknown overlay: ", overlay); } else { - logger.warn("Adding collection that shouldn't be added: "+overlay.getName()); + logger.warn("Adding collection that shouldn't be added: "+overlay.constructor.name); } } }; diff --git a/frontend-js/src/main/js/map/CustomMap.js b/frontend-js/src/main/js/map/CustomMap.js index a496b3a4f2..0379938160 100644 --- a/frontend-js/src/main/js/map/CustomMap.js +++ b/frontend-js/src/main/js/map/CustomMap.js @@ -370,18 +370,15 @@ CustomMap.prototype.createMapMenu = function() { commentCheckbox.type = "checkbox"; commentCheckbox.name = "Comments"; commentCheckbox.id = ControlType.COMMENT_CHECKBOX; - commentCheckbox.onclick = (function() { - var selfButton = commentCheckbox; - return function() { - ServerConnector.getSessionData(selfMap.getProject()).setShowComments(selfButton.checked); - if (selfButton.checked) { - document.getElementById('refresh_comments_button').style.display = 'inline'; - } else { - document.getElementById('refresh_comments_button').style.display = 'none'; - } - selfMap.refreshComments(); - }; - })(); + commentCheckbox.onclick = function() { + ServerConnector.getSessionData(selfMap.getProject()).setShowComments(commentCheckbox.checked); + if (commentCheckbox.checked) { + document.getElementById('refresh_comments_button').style.display = 'inline'; + } else { + document.getElementById('refresh_comments_button').style.display = 'none'; + } + return selfMap.refreshComments(); + }; this.addControl(commentCheckbox); var element = document.createElement('label'); element.innerHTML = "COMMENTS"; diff --git a/frontend-js/src/main/js/map/overlay/CommentDbOverlay.js b/frontend-js/src/main/js/map/overlay/CommentDbOverlay.js index abbbec7715..103d82ddb5 100644 --- a/frontend-js/src/main/js/map/overlay/CommentDbOverlay.js +++ b/frontend-js/src/main/js/map/overlay/CommentDbOverlay.js @@ -3,6 +3,7 @@ var Promise = require("bluebird"); var OverlayCollection = require('./OverlayCollection'); +var ServerConnector = require('../../ServerConnector'); function CommentDbOverlay(params) { // call super constructor @@ -15,8 +16,7 @@ CommentDbOverlay.prototype.constructor = CommentDbOverlay; CommentDbOverlay.prototype.refresh = function() { var self = this; return new Promise(function(resolve, reject) { - ServerConnector.getLightComments({ - }).then(function(comments) { + return ServerConnector.getLightComments({}).then(function(comments) { self.elements = comments; resolve(self.elements); }).catch(reject); diff --git a/frontend-js/src/main/js/minerva.js b/frontend-js/src/main/js/minerva.js index e0237dd0c1..0542b0f42f 100644 --- a/frontend-js/src/main/js/minerva.js +++ b/frontend-js/src/main/js/minerva.js @@ -3,6 +3,7 @@ var functions = require('./Functions'); var CommentDbOverlay = require('./map/overlay/CommentDbOverlay'); +var ControlType = require('./map/ControlType'); var CustomMap = require('./map/CustomMap'); var OverlayCollection = require('./map/overlay/OverlayCollection'); var SearchDbOverlay = require('./map/overlay/SearchDbOverlay'); @@ -30,6 +31,11 @@ function processUrlGetParams(params) { sessionData.setZoomLevel(project.getModel(),GuiConnector.getParams["zoom"]); } } + + if (GuiConnector.getParams["comments"] ==="on") { + sessionData.setShowComments(true); + } + } function create(params) { @@ -101,10 +107,14 @@ function create(params) { if (GuiConnector.getParams["search"] !== undefined) { GuiConnector.search(GuiConnector.getParams["search"]); } + + if (ServerConnector.getSessionData().getShowComments()) { + result.getControl(ControlType.COMMENT_CHECKBOX).checked=true; + return result.refreshComments(); + } else { + return Promise.resolve(); + }}).then(function(){ - if (GuiConnector.getParams["comments"] === "on") { - document.getElementById('comment_checkbox').click(); - } if (GuiConnector.getParams["layout"] !== undefined) { var layouts = params.project.getModel().getLayouts(); var found = false; -- GitLab