Commit 06ebf63e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

list of drugs is paginable

parent 06e58dc3
......@@ -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;
......
......@@ -178,7 +178,7 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) {
if (alias.getType().toUpperCase() === "RNA" ||
alias.getType().toUpperCase() === "PROTEIN" ||
alias.getType().toUpperCase() === "GENE") {
return this._createTargetInfoDiv({overlay:overlay, data:data, name:""});
return this._createTargetInfoDiv({overlay: overlay, data: data, name: ""});
} else {
return null;
}
......@@ -186,7 +186,7 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) {
if (alias.getType().toUpperCase() === "RNA" ||
alias.getType().toUpperCase() === "PROTEIN" ||
alias.getType().toUpperCase() === "GENE") {
return this._createTargetInfoDiv({overlay:overlay, data:data, name:""});
return this._createTargetInfoDiv({overlay: overlay, data: data, name: ""});
} else {
return null;
}
......@@ -194,7 +194,7 @@ AbstractInfoWindow.prototype.createOverlayInfoDiv = function (overlay, data) {
if (alias.getType().toUpperCase() === "RNA" ||
alias.getType().toUpperCase() === "PROTEIN" ||
alias.getType().toUpperCase() === "GENE") {
return this._createTargetInfoDiv({overlay:overlay, data:data, name:""});
return this._createTargetInfoDiv({overlay: overlay, data: data, name: ""});
} else {
return null;
}
......@@ -505,88 +505,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;
};
/**
......
......@@ -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