Commit 7dec57b3 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

selecting layout from url get param

parent fa91b693
......@@ -302,6 +302,24 @@ CustomMap.prototype.openLayoutById = function(identifier) {
}
};
CustomMap.prototype.openLayoutByName = function(name) {
logger.debug("Opening layout: " + name);
var index = null;
var layouts = this.getLayouts();
for (var i = 0; i < layouts.length; i++) {
var layout = layouts [i];
if (layout.getName() === name) {
index = 'cv' + layout.getId();
}
}
// if layout doesn't exist print error
if (index == null) {
alert("You have no privileges for selected layout");
} else {
this.openLayout(index);
}
};
CustomMap.prototype.createMapMenu = function() {
var selfMap = this;
......
......@@ -38,14 +38,22 @@ LayoutData.prototype.getId = function() {
return this.id;
};
LayoutData.prototype.getName = function() {
return this.name;
};
LayoutData.prototype.setId = function(id) {
this.id = parseInt(id);
};
LayoutData.prototype.getInputDataAvailable = function() {
return this._inputDataAvailable;
};
LayoutData.prototype.setInputDataAvailable = function(inputDataAvailable) {
this._inputDataAvailable = inputDataAvailable;
};
LayoutData.prototype.getName = function() {
return this.name;
};
LayoutData.prototype.setName = function(name) {
this.name = name;
};
......
......@@ -13,8 +13,7 @@ var logger = require('./logger');
function processUrlGetParams(configuration) {
if (GuiConnector.getParams["submap"] === undefined
|| configuration.getId() === parseInt(GuiConnector.getParams["submap"])) {
if (GuiConnector.getParams["x"] !== undefined
&& GuiConnector.getParams["y"] !== undefined) {
if (GuiConnector.getParams["x"] !== undefined && GuiConnector.getParams["y"] !== undefined) {
ServerConnector.setCenterCoordinateX(GuiConnector.getParams["x"]);
ServerConnector.setCenterCoordinateY(GuiConnector.getParams["y"]);
}
......@@ -47,8 +46,7 @@ function create(params) {
+ "Select 'Tools' menu item. \n"
+ "Select the 'Compatibility View' settings option. \n"
+ "Make sure the 'Display all websites in Compatibility View' check box is unchecked and that the 'Compatibility View; list of websites is cleared.\n"
+ "\n"
+ "Alternatively, please, use other browsers: Chrome, Firefox or Safari.";
+ "\n" + "Alternatively, please, use other browsers: Chrome, Firefox or Safari.";
alert(message);
logger.warn(message);
}
......@@ -66,8 +64,7 @@ function create(params) {
if (params.dataCollections !== undefined) {
for (var i = 0; i < params.dataCollections.length; i++) {
var collection = params.dataCollections[i];
ServerConnector.addOverlayCollection(new OverlayCollection(result,
collection.name, collection.allowSearchById,
ServerConnector.addOverlayCollection(new OverlayCollection(result, collection.name, collection.allowSearchById,
collection.allowGeneralSearch));
}
result.refreshOverlays();
......@@ -83,8 +80,22 @@ function create(params) {
document.getElementById('comment_checkbox').click();
}
if (GuiConnector.getParams["layout"] !== undefined) {
document.getElementById('tabView:layoutForm3:hidden2').value = GuiConnector.getParams["layout"];
getVisualizedLayoutDetails();
var layouts = params.project.getModel().getLayouts();
var found = false;
logger.debug(GuiConnector.getParams["layout"]);
for (var j = 0; j < layouts.length; j++) {
var layout = layouts[j];
logger.debug(layout);
if (layout.getName() === GuiConnector.getParams["layout"]) {
found = true;
if (layout.getInputDataAvailable()) {
result.addSelectedLayout(layout.getId(), layout.getName());
} else {
result.openLayoutByName(layout.getName());
}
}
}
logger.debug("Layout found: " + found);
}
// when I try to hide legend from the beginning or in the same thread it's
......@@ -100,11 +111,9 @@ function create(params) {
GuiConnector.openDialog(submodelId);
clearInterval(waitingForResponse);
if (GuiConnector.getParams["zoom"] !== undefined) {
result
.setZoom(submodelId, parseInt(GuiConnector.getParams["zoom"]));
result.setZoom(submodelId, parseInt(GuiConnector.getParams["zoom"]));
}
if (GuiConnector.getParams["x"] !== undefined
&& GuiConnector.getParams["y"] !== undefined) {
if (GuiConnector.getParams["x"] !== undefined && GuiConnector.getParams["y"] !== undefined) {
var x = GuiConnector.getParams["x"];
var y = GuiConnector.getParams["y"];
var point = new google.maps.Point(x, y);
......
......@@ -24,8 +24,7 @@ GuiConnectorMock.addListener = function(type, fun) {
}
if (typeof fun !== "function") {
throw "Second parameter must be a function but \"" + typeof (fun)
+ "\" found.";
throw "Second parameter must be a function but \"" + typeof (fun) + "\" found.";
}
var listenerList = this.listeners[type];
......@@ -42,8 +41,7 @@ GuiConnectorMock.removeListener = function(type, fun) {
}
if (typeof fun !== "function") {
throw "Second parameter must be a function but \"" + typeof (fun)
+ "\" found.";
throw "Second parameter must be a function but \"" + typeof (fun) + "\" found.";
}
var listenerList = this.listeners[type];
......@@ -61,8 +59,7 @@ GuiConnectorMock.callListeners = function(type) {
}
var listenerList = this.listeners[type];
if (listenerList !== undefined) {
logger.debug("GuiConnector is calling: " + type + ". "
+ listenerList.length + " listeners found.");
logger.debug("GuiConnector is calling: " + type + ". " + listenerList.length + " listeners found.");
for ( var i in listenerList) {
var e = {
type : type,
......@@ -100,17 +97,14 @@ GuiConnectorMock.getLoadingImg = function() {
GuiConnectorMock.referenceToHtml = function(reference) {
var result = "";
if (reference.summary !== null && reference.summary !== undefined
&& reference.summary !== "") {
if (reference.summary !== null && reference.summary !== undefined && reference.summary !== "") {
result = '<div title="' + reference.summary + '">';
result += '<a href="' + reference.link + '" target="_blank">'
+ reference.name + "</a>";
result += '<a href="' + reference.link + '" target="_blank">' + reference.name + "</a>";
// + reference.name + "(" + reference.type + ")</a>";
result += "</div>";
return result;
} else {
result = '<div><a href="' + reference.link + '" target="_blank">'
+ reference.name + "</a></div>";
result = '<div><a href="' + reference.link + '" target="_blank">' + reference.name + "</a></div>";
// + reference.name + "(" + reference.type + ")</a></div>";
return result;
}
......
......@@ -135,6 +135,7 @@ var google = {
},
setMapTypeId : function(id) {
data.mapTypeId = id;
google.maps.event.trigger(this, "maptypeid_changed", id);
},
setOptions : function() {
},
......
......@@ -20,6 +20,21 @@ Helper.prototype.createProject = function() {
return result;
};
Helper.prototype.createOptions = function() {
var map = this.createGoogleMap();
var project = this.createProject();
var options = {
map : map,
project : project,
dataCollections : [ {
name : "testCollection" + this.idCounter++,
} ],
};
return options;
};
Helper.prototype.createModel = function() {
var result = new Model();
result.setId(this.idCounter++);
......@@ -28,17 +43,16 @@ Helper.prototype.createModel = function() {
result.setHeight(800);
result.setMaxZoom(8);
result.setMinZoom(2);
var layout = this.createLayout();
result.addLayout(layout);
return result;
};
Helper.prototype.createLayout= function() {
Helper.prototype.createLayout = function() {
var layout = new LayoutData();
layout.setId(this.idCounter++);
layout.setName("testLayout"+layout.getId());
layout.setName("testLayout" + layout.getId());
return layout;
};
......
......@@ -4,7 +4,6 @@ var Helper = require('./helper');
require("./mocha-config.js");
var Project = require('../../main/js/map/data/Project');
var minerva = require('../../main/js/minerva');
var chai = require('chai');
......@@ -13,23 +12,63 @@ var logger = require('./logger');
describe('minerva global', function() {
var helper;
before(function() {
helper = new Helper();
});
it('create', function() {
var map = new google.maps.Map(testDiv, {
center : {
lat : -34.397,
lng : 150.644
},
scrollwheel : false,
zoom : 8
});
var options = helper.createOptions();
var result = minerva.create(options);
assert.ok(result);
assert.equal(logger.getWarnings().length, 1);
});
it('create with layout', function() {
var project = helper.createProject();
var map = helper.createGoogleMap();
var layout = helper.createLayout();
layout.setInputDataAvailable(false);
var layoutName = layout.getName();
var layoutId = layout.getId();
project.getModel().addLayout(layout);
GuiConnector.getParams["layout"] = layoutName;
var options = {
map : map,
project : project,
dataCollections : [ {
name : "testCollection"
} ],
};
var result = minerva.create(options);
assert.ok(result);
// input file is not available so it's the background
assert.equal(result.getSelectedLayouts().length, 0);
assert.equal(ServerConnector.getSelectedLayout(), "cv" + layoutId);
assert.equal(logger.getWarnings().length, 1);
});
it('create with layout 2', function() {
var project = helper.createProject();
var map = helper.createGoogleMap();
var layout = helper.createLayout();
layout.setInputDataAvailable(true);
var layoutName = layout.getName();
var layoutId = layout.getId();
project.getModel().addLayout(layout);
GuiConnector.getParams["layout"] = layoutName;
var options = {
map : map,
project : project,
......@@ -40,6 +79,8 @@ describe('minerva global', function() {
var result = minerva.create(options);
assert.ok(result);
// input file is available so it's not the background file but overlay
assert.equal(result.getSelectedLayouts().length, 1);
assert.equal(logger.getWarnings().length, 1);
});
});
......@@ -69,7 +69,7 @@
</p:dataTable>
<center>
<p:commandButton id="refreshLayoutsButton" actionListener="#{layoutMB.refreshCustomLayouts}" icon="ui-icon-refresh" oncomplete="updateConfig();" update="layoutDataTable">
<p:commandButton id="refreshLayoutsButton" actionListener="#{layoutMB.refreshCustomLayouts}" icon="ui-icon-refresh" update="layoutDataTable">
</p:commandButton>
</center>
......@@ -143,8 +143,6 @@
<h:inputHidden id="hidden2" value="#{layoutMB.visualizedLayout.name}" />
<h:inputHidden id="hidden_directory" value="#{layoutMB.visualizedLayout.directory}" />
<h:inputHidden id="hidden_layout_id" value="#{layoutMB.visualizedLayout.idObject}" />
<p:remoteCommand name="getVisualizedLayoutDetails" actionListener="#{layoutMB.getVisualizedLayoutDetails}"
oncomplete="updateConfig(); customMap.openLayoutById(document.getElementById('tabView:layoutForm3:hidden_layout_id').value);" update="hidden_layout_id"/>
</h:form>
<h:form id="layoutAccessAliasForm">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment