Commit 70a45435 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '578-upload-of-genetic_variant-overlay-not-working' into 'master'

Resolve "Upload of genetic_variant overlay not working"

Closes #578

See merge request !514
parents 647b3940 8f4c536c
Pipeline #7801 failed with stage
in 9 minutes and 54 seconds
......@@ -107,15 +107,20 @@ AddOverlayDialog.prototype.createGui = function () {
content.appendChild(contentInput);
content.appendChild(guiUtils.createNewLine());
var consentCheckbox = Functions.createElement({type: "input", name: "overlay-google-consent"});
consentCheckbox.type = "checkbox";
content.appendChild(consentCheckbox);
content.appendChild(guiUtils.createLabel("I am aware that if this map is displayed using Google Maps API, " +
"it falls under their license <a href='https://cloud.google.com/maps-platform/terms/' target='_blank'>" +
"https://cloud.google.com/maps-platform/terms/</a>, to which I agree. I warrant that this dataset contains no " +
"Protected Health Information (as defined in and subject to HIPAA)."));
if (self.getProject().getMapCanvasType() === "GOOGLE_MAPS_API") {
var consentCheckbox = Functions.createElement({
type: "input",
name: "overlay-google-consent",
inputType: "checkbox"
});
content.appendChild(consentCheckbox);
content.appendChild(guiUtils.createLabel("I am aware that if this map is displayed using Google Maps API, " +
"it falls under their license <a href='https://cloud.google.com/maps-platform/terms/' target='_blank'>" +
"https://cloud.google.com/maps-platform/terms/</a>, to which I agree. I warrant that this dataset contains no " +
"Protected Health Information (as defined in and subject to HIPAA)."));
content.appendChild(guiUtils.createNewLine());
content.appendChild(guiUtils.createNewLine());
}
self.getElement().appendChild(content);
};
......
......@@ -355,15 +355,19 @@ OverlayPanel.prototype.openEditOverlayDialog = function (overlay) {
row = guiUtils.createTableRow([guiUtils.createLabel("Description: "), descriptionInput]);
content.appendChild(row);
var consentCheckbox = document.createElement("input");
consentCheckbox.type = "checkbox";
consentCheckbox.checked = overlay.isGoogleLicenseConsent();
row = guiUtils.createTableRow([guiUtils.createLabel("I am aware that if this map is displayed using Google Maps API, " +
"it falls under their license <a href='https://cloud.google.com/maps-platform/terms/' target='_blank'>" +
"https://cloud.google.com/maps-platform/terms/</a>, to which I agree. I warrant that this dataset contains no " +
"Protected Health Information (as defined in and subject to HIPAA)."), consentCheckbox]);
content.appendChild(row);
var consentCheckbox = Functions.createElement({
type: "input",
name: "overlay-google-consent",
inputType: "checkbox"
});
if (self.getProject().getMapCanvasType() === "GOOGLE_MAPS_API") {
row = guiUtils.createTableRow([guiUtils.createLabel("I am aware that if this map is displayed using Google Maps API, " +
"it falls under their license <a href='https://cloud.google.com/maps-platform/terms/' target='_blank'>" +
"https://cloud.google.com/maps-platform/terms/</a>, to which I agree. I warrant that this dataset contains no " +
"Protected Health Information (as defined in and subject to HIPAA)."), consentCheckbox]);
content.appendChild(row);
}
var buttons = [{
text: "SAVE",
......
......@@ -14,13 +14,7 @@ describe('AddOverlayDialog', function () {
it('addOverlay', function () {
var dialog;
return ServerConnector.getProject().then(function (project) {
dialog = new AddOverlayDialog({
element: testDiv,
project: project,
customMap: null,
configuration: helper.getConfiguration(),
serverConnector: ServerConnector
});
dialog = createDialog(project);
dialog.setFileContent("s1\n");
assert.equal(0, logger.getWarnings().length);
......@@ -28,4 +22,38 @@ describe('AddOverlayDialog', function () {
});
});
/**
*
* @param {Project} project
* @returns {AddOverlayDialog}
*/
function createDialog(project) {
return new AddOverlayDialog({
element: testDiv,
project: project,
customMap: null,
configuration: helper.getConfiguration(),
serverConnector: ServerConnector
});
}
describe('constructor', function () {
it('hide consent checkbox for non google maps api project', function () {
var dialog;
return ServerConnector.getProject().then(function (project) {
project.setMapCanvasType("OPEN_LAYERS");
dialog = createDialog(project);
assert.equal(0, $("[name='overlay-google-consent']", dialog.getElement()).length);
});
});
it('hide consent checkbox for non google maps api project', function () {
var dialog;
return ServerConnector.getProject().then(function (project) {
project.setMapCanvasType("GOOGLE_MAPS_API");
dialog = createDialog(project);
assert.ok($("[name='overlay-google-consent']", dialog.getElement()).length > 0);
});
});
});
});
......@@ -149,47 +149,72 @@ describe('OverlayPanel', function () {
describe('openAddOverlayDialog', function () {
it('open', function () {
var map = helper.createCustomMap();
it('open', function () {
var map = helper.createCustomMap();
var panel = createOverlayPanel(map);
var panel = createOverlayPanel(map);
return panel.openAddOverlayDialog().then(function () {
return panel.destroy();
return panel.openAddOverlayDialog().then(function () {
return panel.destroy();
});
});
});
it('trigger onAddOverlay event handler', function () {
var map = helper.createCustomMap();
var panel = createOverlayPanel(map);
it('trigger onAddOverlay event handler', function () {
var map = helper.createCustomMap();
var panel = createOverlayPanel(map);
return panel.init().then(function () {
return panel.openAddOverlayDialog();
}).then(function () {
var overlay = helper.createOverlay(panel.getProject().getModels()[0]);
return panel._addOverlayDialog.callListeners("onAddOverlay", overlay);
}).then(function () {
return panel.destroy();
});
});
});
});
return panel.init().then(function () {
return panel.openAddOverlayDialog();
describe('openEditOverlayDialog', function () {
it('open for map with Google Maps Api', function () {
helper.loginAsAdmin();
var panel;
return ServerConnector.getProject().then(function (project) {
project.setMapCanvasType("GOOGLE_MAPS_API");
panel = new OverlayPanel({
element: testDiv,
customMap: helper.createCustomMap(project)
});
return panel.init();
}).then(function () {
var overlay = helper.createOverlay(panel.getProject().getModels()[0]);
return panel._addOverlayDialog.callListeners("onAddOverlay", overlay);
var backgroundLink = $("[name='editButton']", panel.getElement())[0];
assert.ok($(backgroundLink).attr("data"));
return helper.triggerJqueryEvent(backgroundLink, "click");
}).then(function () {
assert.equal(1, $("[name='overlay-google-consent']").length);
return panel.destroy();
});
});
});
it('openEditOverlayDialog', function () {
helper.loginAsAdmin();
var panel;
return ServerConnector.getProject().then(function (project) {
panel = new OverlayPanel({
element: testDiv,
customMap: helper.createCustomMap(project)
it('open for map without Google Maps Api', function () {
helper.loginAsAdmin();
var panel;
return ServerConnector.getProject().then(function (project) {
project.setMapCanvasType("OPEN_LAYERS");
panel = new OverlayPanel({
element: testDiv,
customMap: helper.createCustomMap(project)
});
return panel.init();
}).then(function () {
var backgroundLink = $("[name='editButton']", panel.getElement())[0];
assert.ok($(backgroundLink).attr("data"));
return helper.triggerJqueryEvent(backgroundLink, "click");
}).then(function () {
assert.equal(0, $("[name='overlay-google-consent']").length);
return panel.destroy();
});
return panel.init();
}).then(function () {
var backgroundLink = $("[name='editButton']", panel.getElement())[0];
assert.ok($(backgroundLink).attr("data"));
return helper.triggerJqueryEvent(backgroundLink, "click");
}).then(function () {
return panel.destroy();
});
});
});
});
......@@ -1174,6 +1174,10 @@ public class ProjectService implements IProjectService {
if (token != null) {
Model model = modelService.getLastModelByProjectId(project.getProjectId(), token);
if (model != null) {
//TODO it's a hack to prevent lazy initialization of the project
project.setModels(model.getProject().getModels());
project.setLayouts(model.getProject().getLayouts());
project.setOverviewImages(model.getProject().getOverviewImages());
model.setProject(project);
}
}
......
Markdown is supported
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