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

Merge branch '1366-reverse-search-pop-up-display' into 'master'

Resolve "reverse search pop-up display"

Closes #1366

See merge request !1303
parents d892a301 b7edf3bd
Pipeline #40776 failed with stage
in 18 minutes and 26 seconds
......@@ -12,6 +12,7 @@ minerva (16.0.0~alpha.2) stable; urgency=medium
* 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)
* Small improvement: reverse search pop-up reorganized (#1366)
* Bug fix: arrows without a "process" box had an irregular empty space in
their lines (#1471)
* Bug fix: when selecting drug in the alias window the input text is updated
......
......@@ -2196,7 +2196,7 @@ ServerConnector.getDrugsByQuery = function (params) {
var self = this;
var queryParams = {};
var filterParams = {
query: params.query
query: encodeURIComponent(params.query)
};
return self.getProjectId(params.projectId).then(function (result) {
queryParams.projectId = result;
......@@ -2234,7 +2234,7 @@ ServerConnector.getChemicalsByQuery = function (params) {
var self = this;
var queryParams = {};
var filterParams = {
query: params.query
query: encodeURIComponent(params.query)
};
return self.getProjectId(params.projectId).then(function (result) {
queryParams.projectId = result;
......
......@@ -922,7 +922,7 @@ CustomMap.prototype.getOverlayDataForIdentifiedElement = function (identifiedEle
generalFlag = false;
}
overlays.push(overlay);
promises.push(overlay.getDetailDataByIdentifiedElement(identifiedElement, overlay.allowSearchById()
promises.push(overlay.getDetailDataByIdentifiedElement(identifiedElement, !overlay.allowSearchById()
|| generalFlag));
}
......
"use strict";
var $ = require('jquery');
var Promise = require("bluebird");
var logger = require('../../logger');
......@@ -11,6 +12,7 @@ var GuiUtils = require('../../gui/leftPanel/GuiUtils');
var IdentifiedElement = require('../data/IdentifiedElement');
var ObjectWithListeners = require('../../ObjectWithListeners');
var TargettingStructure = require('../data/TargettingStructure');
var OverlayTabs = require("./OverlayTabs");
/**
* Class representing any info window in our map.
......@@ -177,7 +179,7 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) {
if (alias.getType().toUpperCase() === "RNA" ||
alias.getType().toUpperCase() === "PROTEIN" ||
alias.getType().toUpperCase() === "GENE") {
return this._createDrugInfoDiv(overlay, data);
return this._createTargetInfoDiv({overlay: overlay, data: data, name: ""});
} else {
return null;
}
......@@ -185,7 +187,7 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) {
if (alias.getType().toUpperCase() === "RNA" ||
alias.getType().toUpperCase() === "PROTEIN" ||
alias.getType().toUpperCase() === "GENE") {
return this._createChemicalInfoDiv(overlay, data);
return this._createTargetInfoDiv({overlay: overlay, data: data, name: ""});
} else {
return null;
}
......@@ -193,7 +195,7 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) {
if (alias.getType().toUpperCase() === "RNA" ||
alias.getType().toUpperCase() === "PROTEIN" ||
alias.getType().toUpperCase() === "GENE") {
return this._createMiRnaInfoDiv(overlay, data);
return this._createTargetInfoDiv({overlay: overlay, data: data, name: ""});
} else {
return null;
}
......@@ -218,23 +220,6 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) {
}
};
/**
* Creates and returns div for drug overlay information.
*
* @param {AbstractDbOverlay} overlay
* @param {Drug[]} data
* data taken from drug overlay
* @returns {HTMLElement} div for drug overlay information
* @private
*/
AbstractInfoWindow.prototype._createDrugInfoDiv = function (overlay, data) {
return this._createTargetInfoDiv({
overlay: overlay,
data: data,
name: "Interacting drugs"
});
};
/**
* Creates and returns div for comment overlay information.
*
......@@ -411,13 +396,24 @@ AbstractInfoWindow.prototype._updateContent = function () {
AbstractInfoWindow.prototype.createDbOverlaysDiv = function () {
var self = this;
var result = document.createElement("div");
var overlayTabs = null;
return this.getDbOverlaysData(self.getOverlayFullViewArray()).then(function (overlayData) {
for (var i = 0; i < overlayData.length; i++) {
var overlay = overlayData[i].overlay;
var data = overlayData[i].data;
var overlayInfo = self.createOverlayInfoDiv(overlay, data);
if (overlayInfo !== null) {
result.appendChild(overlayInfo);
if (overlay.name === "drug" || overlay.name === "chemical" || overlay.name === "mirna") {
if (overlayTabs == null) {
var div = document.createElement("div")
result.appendChild(div);
overlayTabs = new OverlayTabs({element: div, project: self.getCustomMap().getProject()});
self.getGuiUtils().initTabContent(overlayTabs);
}
self.getGuiUtils().addTab(overlayTabs, {name: overlay.name, content: overlayInfo});
} else {
result.appendChild(overlayInfo);
}
}
}
return result;
......@@ -468,20 +464,30 @@ AbstractInfoWindow.prototype._createTargetInfoDiv = function (params) {
result.appendChild(titleElement);
if (overlay.allowGeneralSearch()) {
var checkboxDiv = document.createElement("div");
checkboxDiv.style.float = "right";
var checkbox = document.createElement("input");
checkbox.id = "checkbox-" + name + "-" + this.getElementType() + "-" + this.getElementId();
checkbox.type = "checkbox";
checkbox.checked = self.isOverlayFullView(overlay.getName());
checkbox.onclick = function () {
return self.setOverlayFullView(overlay.getName(), this.checked).then(null, GuiConnector.alert);
var ie = new IdentifiedElement(self.alias);
result.removeChild(table);
var messageImg = Functions.createElement({
type: "img",
src: 'resources/images/icons/ajax-loader.gif'
});
result.appendChild(messageImg);
return overlay.getDetailDataByIdentifiedElement(ie, this.checked).then(function (data) {
table = self._createTableForTargetDiv(data, overlay);
result.appendChild(table);
}).finally(function () {
result.removeChild(messageImg);
})
};
checkboxDiv.appendChild(checkbox);
var description = document.createElement("div");
description.style.float = "right";
description.style.display = "inline-block";
description.innerHTML = "Show all";
checkboxDiv.appendChild(description);
result.appendChild(checkboxDiv);
......@@ -512,88 +518,42 @@ AbstractInfoWindow.prototype._createTargetInfoDiv = function (params) {
* @private
*/
AbstractInfoWindow.prototype._createTableForTargetDiv = function (data, overlay) {
var self = this;
var result = document.createElement("div")
var table = document.createElement("table");
table.className = "minerva-window-drug-table";
var header = document.createElement("tr");
var headerCol = document.createElement("th");
headerCol.innerHTML = "Name";
header.appendChild(headerCol);
headerCol = document.createElement("th");
headerCol.innerHTML = "References";
header.appendChild(headerCol);
var cell;
table.appendChild(header);
var row;
var onclick = function () {
// ';' enforces single query (in case there are ',' characters in the name)
result.appendChild(table);
var dataTable = $(table).DataTable({
fnRowCallback: function (nRow, aData) {
nRow.setAttribute('id', aData[0]);
},
columns: [{
title: 'Name'
}]
});
$(table).on("click", "a", function () {
return overlay.searchByQuery(this.innerHTML + ";");
};
});
var page = dataTable.page();
var count = 0;
var rows = [];
for (var searchId in data) {
if (data.hasOwnProperty(searchId)) {
row = document.createElement("tr");
var nameContent = searchId;
var annotations = [];
if (typeof data[searchId] === "string") {
nameContent = data[searchId];
} else if (data[searchId] instanceof TargettingStructure) {
nameContent = data[searchId].getName();
var targets = data[searchId].getTargetsForIdentifiedElement(self.getIdentifiedElement());
for (var i = 0; i < targets.length; i++) {
var references = targets[i].getReferences();
for (var j = 0; j < references.length; j++) {
annotations.push(references[j]);
}
}
}
var link = Functions.createElement({
type: "a",
onclick: onclick,
href: "#",
content: nameContent
});
var nameTd = Functions.createElement({
type: "td"
});
nameTd.appendChild(link);
row.appendChild(nameTd);
var referencesCell = Functions.createElement({
type: "td"
});
referencesCell.appendChild(self.getGuiUtils().createAnnotationList(annotations, {groupAnnotations: false}));
row.appendChild(referencesCell);
table.appendChild(row);
count++;
rows.push(["<a href='#'>" + nameContent + "</a>"]);
}
}
if (self.isOverlayFullView(overlay.getName()) && count === 0) {
row = document.createElement("tr");
cell = document.createElement("td");
cell.colSpan = 2;
cell.innerHTML = "No results available";
row.appendChild(cell);
table.appendChild(row);
}
//it should be simplified, but I couldn't make it work
dataTable.clear().rows.add(rows).page(page).draw(false).page(page).draw(false);
if (!self.isOverlayFullView(overlay.getName()) && count === 0 && overlay.allowGeneralSearch()) {
row = document.createElement("tr");
cell = document.createElement("td");
cell.colSpan = 2;
cell.innerHTML = "Search for available targets";
row.appendChild(cell);
table.appendChild(row);
}
return table;
return result;
};
/**
......@@ -662,39 +622,6 @@ AbstractInfoWindow.prototype.getGuiUtils = function () {
return this._guiUtils;
};
/**
* Creates and returns DOM div for chemical overlay information.
*
* @param {AbstractDbOverlay} overlay
* @param {Chemical[]} data
* data taken from chemical overlay
* @returns {HTMLElement} element with a div for comment overlay information
* @private
*/
AbstractInfoWindow.prototype._createChemicalInfoDiv = function (overlay, data) {
return this._createTargetInfoDiv({
overlay: overlay,
data: data,
name: "Interacting chemicals"
});
};
/**
* Creates and returns DOM div for mi rna overlay information.
*
* @param {AbstractDbOverlay} overlay
* @param {MiRna[]} data
* data taken from mi rna overlay
* @returns {HTMLElement} DOM element with a div for comment overlay information
*/
AbstractInfoWindow.prototype._createMiRnaInfoDiv = function (overlay, data) {
return this._createTargetInfoDiv({
overlay: overlay,
data: data,
name: "Interacting Micro RNAs"
});
};
/**
*
* @param {IdentifiedElement} identifiedElement
......
"use strict";
var AbstractGuiElement = require('../../gui/AbstractGuiElement');
var xss = require('xss');
/**
*
* @param {Object} params
* @param {HTMLElement} params.element
* @param {CustomMap} [params.customMap]
* @param {Project} [params.project]
* @param {ServerConnector} [params.serverConnector]
*
* @constructor
* @extends AbstractGuiElement
*/
function OverlayTabs(params) {
AbstractGuiElement.call(this, params);
}
OverlayTabs.prototype = Object.create(AbstractGuiElement.prototype);
OverlayTabs.prototype.constructor = OverlayTabs;
module.exports = OverlayTabs;
......@@ -260,6 +260,7 @@ public abstract class BaseRestImpl {
properties = getSearchByNameProperties(target);
searchPropertyList.add(properties);
break;
}
default:
throw new InvalidArgumentException("Unknown drug target type: " + target.getType());
......
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