Commit 70727284 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

Merge branch '1314-make-text-area-glyphs-with-z-index-0-non-clickable' into 'master'

Resolve "Make text area glyphs with z-index < 0 non-clickable"

Closes #1314

See merge request !1203
parents 6d11244e 5eb2b556
Pipeline #29074 passed with stage
in 13 minutes and 55 seconds
......@@ -21,6 +21,10 @@ minerva (15.1.0) unstable; urgency=medium
raised if images are not referenced in coords.txt file (#1308)
* Small improvement: hitting enter after filling credentials automatically
tries to log in (#1312)
* Small improvement: rest API provides information about element glyph and z
index
* Small improvement: pathways with glyphs and z index below 0 are not
clickable (#1314)
* Bug fix: export to image from selected polygon contained all elements
inside rectangle bounded by the polygon coordinates (#1096)
* Bug fix: continuous refreshing list of project when uploading/removing
......
......@@ -23,6 +23,7 @@ function Alias(javaObject) {
if (javaObject.bounds !== undefined) {
this.setX(javaObject.bounds.x);
this.setY(javaObject.bounds.y);
this.setZ(javaObject.bounds.z);
this.setWidth(javaObject.bounds.width);
this.setHeight(javaObject.bounds.height);
}
......@@ -79,8 +80,11 @@ Alias.prototype.update = function (javaObject) {
this.setInitialAmount(javaObject.getInitialAmount());
this.setInitialConcentration(javaObject.getInitialConcentration());
this.setGlyph(javaObject.getGlyph());
this.setX(javaObject.getX());
this.setY(javaObject.getY());
this.setZ(javaObject.getZ());
this.setWidth(javaObject.getWidth());
this.setHeight(javaObject.getHeight());
......@@ -113,10 +117,12 @@ Alias.prototype.update = function (javaObject) {
this.setInitialAmount(javaObject.initialAmount);
this.setInitialConcentration(javaObject.initialConcentration);
this.setGlyph(javaObject.glyph);
if (javaObject.bounds !== undefined) {
this.setX(javaObject.bounds.x);
this.setY(javaObject.bounds.y);
this.setZ(javaObject.bounds.z);
this.setWidth(javaObject.bounds.width);
this.setHeight(javaObject.bounds.height);
}
......@@ -256,6 +262,24 @@ Alias.prototype.getY = function () {
return this.y;
};
/**
*
* @param {number} z
*/
Alias.prototype.setZ = function (z) {
if (z !== undefined) {
this.z = z;
}
};
/**
*
* @returns {number}
*/
Alias.prototype.getZ = function () {
return this.z;
};
/**
*
* @param {number} elementId
......@@ -400,4 +424,20 @@ Alias.prototype.getCenter = function () {
return new Point(this.getX() + this.getWidth() / 2, this.getY() + this.getHeight() / 2);
};
/**
*
* @returns {Object}
*/
Alias.prototype.getGlyph = function () {
return this._glyph;
};
/**
*
* @param {Object} glyph
*/
Alias.prototype.setGlyph = function (glyph) {
this._glyph = glyph;
};
module.exports = Alias;
......@@ -228,6 +228,17 @@ SearchDbOverlay.prototype.findCompartmentByCoordinates = function (coordinates,
}
});
}
}).then(function (result) {
if (result !== undefined) {
return model.getAliasById(result.getId(), true).then(function (alias) {
//pathways with glyph and z index below 0 should not be clickable
if (alias.getType() === "Pathway" && alias.getZ() < 0 && alias.getGlyph() !== null) {
return undefined;
} else {
return result;
}
});
}
});
};
......@@ -295,6 +306,13 @@ SearchDbOverlay.prototype.searchByCoordinates = function (params) {
searchResult.push(new IdentifiedElement(reactionElements[i]));
}
});
} else {
return model.getAliasById(searchResult[0].getId(), true).then(function (alias) {
//pathways with glyph and z index below 0 should not be clickable
if (alias.getType() === "Pathway" && alias.getZ() < 0 && alias.getGlyph() !== null) {
searchResult = [];
}
});
}
} else {
searchResult = [];
......
......@@ -13,6 +13,7 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.converter.model.celldesigner.structure.fields.ModificationType;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.layout.graphics.Glyph;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.field.*;
......@@ -211,7 +212,10 @@ public class ElementsRestImpl extends BaseRestImpl {
}
break;
case "bounds":
value = createBounds(element.getX(), element.getY(), element.getWidth(), element.getHeight());
value = createBounds(element.getX(), element.getY(),element.getZ(), element.getWidth(), element.getHeight());
break;
case "glyph":
value = createGlyph(element.getGlyph());
break;
default:
value = "Unknown column";
......@@ -222,6 +226,16 @@ public class ElementsRestImpl extends BaseRestImpl {
return result;
}
private Map<String, Object> createGlyph(Glyph glyph) {
if (glyph == null) {
return null;
} else {
Map<String, Object> result = new HashMap<>();
result.put("fileId", glyph.getFile().getId());
return result;
}
}
protected Map<String, Object> getOthersForElement(Element element) {
Map<String, Object> result = new TreeMap<>();
List<Map<String, Object>> modifications = new ArrayList<>();
......@@ -307,10 +321,11 @@ public class ElementsRestImpl extends BaseRestImpl {
return result;
}
private Map<String, Object> createBounds(Double x, Double y, Double width, Double height) {
private Map<String, Object> createBounds(Double x, Double y, Integer z, Double width, Double height) {
Map<String, Object> result = new TreeMap<>();
result.put("x", x);
result.put("y", y);
result.put("z", z);
result.put("width", width);
result.put("height", height);
return result;
......@@ -343,6 +358,7 @@ public class ElementsRestImpl extends BaseRestImpl {
columnsSet.add("boundaryCondition");
columnsSet.add("constant");
columnsSet.add("initialAmount");
columnsSet.add("glyph");
} else {
columnsSet.addAll(Arrays.asList(columns.split(",")));
}
......
package lcsb.mapviewer.web;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
......@@ -81,6 +80,7 @@ public class MapControllerIntegrationTest extends ControllerIntegrationTest {
.getAsJsonArray().size();
assertTrue("user should be able to access elements", elements > 0);
assertFalse(response.contains("Unknown column"));
}
@Test
......
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