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

Merge branch '1451-group-search-results-by-diagram' into 'master'

Resolve "Group search results by diagram"

Closes #1451

See merge request !1302
parents 30123210 051417f2
Pipeline #40761 passed with stage
in 20 minutes and 18 seconds
......@@ -9,6 +9,7 @@ minerva (16.0.0~alpha.2) stable; urgency=medium
* Small improvement: information about dimer in sbgn is provided only once
if the information is duplicated in sbgn data (#1358)
* Small improvement: glyph quality is improved (#1458)
* Small improvement: search results are group by diagram (#1451)
* Small improvement: "Failed to fetch" errors are reported in a way that suggest
retrying before submitting error report (#738)
* Bug fix: arrows without a "process" box had an irregular empty space in
......
......@@ -16,6 +16,7 @@ var SearchBioEntityGroup = require('../../map/data/SearchBioEntityGroup');
var logger = require('../../logger');
var Functions = require('../../Functions');
var SearchMapBioEntityGroup = require("../../map/data/SearchMapBioEntityGroup");
/**
*
......@@ -318,12 +319,15 @@ AbstractDbPanel.prototype.addResultTab = function (query, elements) {
onclick: function () {
var identifiedElements = [];
for (var i = 0; i < elements.length; i++) {
if (elements[i].element instanceof SearchBioEntityGroup) {
for (var j = 0; j < elements[i].element.getBioEntities().length; j++) {
identifiedElements.push(new IdentifiedElement(elements[i].element.getBioEntities()[j]));
var element = elements[i].element;
if (element instanceof SearchBioEntityGroup) {
for (var j = 0; j < element.getBioEntities().length; j++) {
identifiedElements.push(new IdentifiedElement(element.getBioEntities()[j]));
}
} else if (element instanceof SearchMapBioEntityGroup) {
identifiedElements.push.apply(identifiedElements, element.getIdentifiedElements());
} else {
identifiedElements.push(new IdentifiedElement(elements[i].element));
identifiedElements.push(new IdentifiedElement(element));
}
}
return self.getOverlayDb().callListeners("onFocus", {query: query, identifiedElements: identifiedElements});
......
......@@ -18,6 +18,7 @@ var SearchBioEntityGroup = require('../../map/data/SearchBioEntityGroup');
// noinspection JSUnusedLocalSymbols
var logger = require('../../logger');
var Functions = require('../../Functions');
var SearchMapBioEntityGroup = require("../../map/data/SearchMapBioEntityGroup");
/**
*
......@@ -105,17 +106,98 @@ GenericSearchPanel.prototype.createSearchGui = function () {
* @override
*/
GenericSearchPanel.prototype.createTableElement = function (element, icon) {
var self = this;
if (element instanceof Alias) {
return this.createAliasElement(element, icon);
} else if (element instanceof Reaction) {
return this.createReactionElement(element);
} else if (element instanceof SearchBioEntityGroup) {
return this.createSearchBioEntityGroupElement(element);
} else if (element instanceof SearchMapBioEntityGroup) {
var promises = [];
element.getBioEntities().forEach(function (bioEntity) {
promises.push(self.createTableElement(bioEntity, icon));
});
return Promise.all(promises).then(function (divs) {
var guiUtils = self.getGuiUtils();
var result = document.createElement("div");
var table = document.createElement("table");
var expandStyle = "fa-eye";
var headerDiv;
if (element.getModelId() !== self.getMap().getId()) {
headerDiv = guiUtils.createSubMapLink({
label: "Submap: ",
mapId: element.getModelId()
});
} else {
headerDiv = document.createElement("div");
$(headerDiv).css("height", "21px");
}
$(headerDiv).css("padding", "5px");
$(table).hide();
result.appendChild(headerDiv);
headerDiv.appendChild(Functions.createElement({
type: "a",
className: "minerva-toggle-hide-show",
content: '<i class="fa ' + expandStyle + '" style="font-size:17px"></i>&nbsp;',
href: "#",
onclick: function () {
if ($(table).is(":visible")) {
$(table).hide();
$("a.minerva-toggle-hide-show>i", headerDiv).removeClass("fa-eye-slash");
$("a.minerva-toggle-hide-show>i", headerDiv).addClass("fa-eye");
} else {
$(table).show();
$("a.minerva-toggle-hide-show>i", headerDiv).removeClass("fa-eye");
$("a.minerva-toggle-hide-show>i", headerDiv).addClass("fa-eye-slash");
}
},
title: "Hide/Show",
style: "float:right",
xss: false
}));
$(table).css("width", "100%");
result.appendChild(table);
divs.forEach(function (htmlTag) {
table.appendChild(htmlTag);
});
return result;
});
} else {
throw new Error("Unknown element type: " + element.constructor.name);
}
};
GenericSearchPanel.prototype.addResultTab = function (query, elements) {
var self = this;
var groupsByMap = {};
var groups = [];
for (var i = 0; i < elements.length; i++) {
var element = elements[i].element;
var icon = elements[i].icon;
if (element instanceof Alias || element instanceof Reaction) {
element = new SearchBioEntityGroup(element);
element.setIcon(icon);
}
if (groupsByMap[element.getModelId()] === undefined) {
groupsByMap[element.getModelId()] = new SearchMapBioEntityGroup(element);
groups.push({element: groupsByMap[element.getModelId()], icon: null});
} else {
groupsByMap[element.getModelId()].addBioEntity(element);
}
}
return AbstractDbPanel.prototype.addResultTab.call(this, query, groups).then(function () {
var contentElement = self.getControlElement(PanelControlElementType.SEARCH_RESULTS_CONTENT_TAB);
var links = $(".table div>a.minerva-toggle-hide-show", contentElement);
if (links.length > 0) {
links[0].onclick();
}
});
}
/**
*
* @returns {HTMLDivElement}
......
......@@ -664,9 +664,6 @@ GuiUtils.prototype.createReactionElement = function (params) {
className: self._configurationOptionToClassName(ConfigurationType.SHOW_REACTION_TITLE)
});
titleDiv.appendChild(self.createLabel("Reaction: " + reaction.getReactionId()));
if (reaction.getModelId() !== self.getMap().getId()) {
titleDiv.appendChild(self.createSubMapLink({label: "In submap: ", mapId: reaction.getModelId()}));
}
div.appendChild(titleDiv);
}
......@@ -837,13 +834,6 @@ GuiUtils.prototype.createAliasElement = function (params) {
className: self._configurationOptionToClassName(ConfigurationType.SHOW_ELEMENT_TITLE),
value: alias.getName()
}));
if (alias.getModelId() !== self.getMap().getId()) {
div.appendChild(self.createSubMapLink({
label: "In submap: ",
className: self._configurationOptionToClassName(ConfigurationType.SHOW_ELEMENT_TITLE),
mapId: alias.getModelId()
}));
}
}
div.appendChild(self.createSubMapLink({
label: "Associated submap: ",
......
"use strict";
var BioEntity = require("./BioEntity");
var SearchBioEntityGroup = require("./SearchBioEntityGroup");
// noinspection JSUnusedLocalSymbols
var logger = require('../../logger');
var IdentifiedElement = require("./IdentifiedElement");
/**
* Class representing merged search bioEntities based on map.
*
* @param {BioEntity|SearchBioEntityGroup} bioEntity
* initial bioEntity from which group is created
* @constructor
*/
function SearchMapBioEntityGroup(bioEntity) {
if (!(bioEntity instanceof BioEntity) && !(bioEntity instanceof SearchBioEntityGroup)) {
throw new Error("Invalid argument");
}
this._bioEntites = [bioEntity];
}
/**
*
* @param {BioEntity} newBioEntity
*/
SearchMapBioEntityGroup.prototype.addBioEntity = function (newBioEntity) {
this._bioEntites.push(newBioEntity);
};
/**
*
* @returns {BioEntity[]}
*/
SearchMapBioEntityGroup.prototype.getBioEntities = function () {
return this._bioEntites;
};
/**
*
* @returns {number}
*/
SearchMapBioEntityGroup.prototype.getModelId = function () {
return this._bioEntites[0].getModelId();
};
/**
*
* @returns {IdentifiedElement[]}
*/
SearchMapBioEntityGroup.prototype.getIdentifiedElements = function () {
var result = [];
for (var i = 0; i < this.getBioEntities().length; i++) {
var element = this.getBioEntities()[i];
if (element instanceof SearchBioEntityGroup) {
for (var j = 0; j < element.getBioEntities().length; j++) {
result.push(new IdentifiedElement(element.getBioEntities()[j]));
}
} else {
result.push(new IdentifiedElement(element));
}
}
return result;
}
module.exports = SearchMapBioEntityGroup;
......@@ -516,7 +516,7 @@ AliasInfoWindow.prototype.createGenomicDiv = function (params) {
var distDiff = Math.floor((range.stop - range.start + 1) / 4);
range.start += distDiff;
range.stop -= distDiff;
$(".zoom-slider", contentElement).val(parseInt($(".zoom-slider", zoomControls).val()) + 1);
self.pileup.setRange(range);
});
......
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