" +
((panel.model.exclude) ? "
NOT" : "") +
"
" +
concept +
((output)? (" (
)") : "") +
"
";
// var panel.model.conceptPanelId = panel.view.getElementsByClassName('MedCo-QueryPanelConcepts')[0].id;
var conceptPanel = document.getElementById(panel.model.conceptPanelId)
conceptPanel.innerHTML += conceptDiv;
return conceptPanel.lastChild
};
panel.view.clear = function(){
panel.model.exclude = false;
var excludeButton = document.getElementById(panel.model.panelId).getElementsByClassName("exclude")[0]
excludeButton.style.textDecoration = panel.model.exclude? "underline":"none";
var concepts = document.getElementById(panel.model.conceptPanelId);
while (concepts.firstChild) {
concepts.removeChild(concepts.firstChild);
}
};
// ------ initialize the controller ------
panel.ctrlr.doDrop = function (sdxData) {
var concept = sdxData[0]; // only interested in first record
// CHECK: some useful functions:
// alert(i2b2.h.getXNodeVal(sdxData.origData.xmlOrig, "level"))
// alert(Object.getOwnPropertyNames(sdxData.origData));
// optimization to prevent requerying the hive for new results if the input dataset has not changed
// i2b2.ExampTabs.model.dirtyResultsData = true;
// check whether to show a popup or directly append the concept
switch(concept.sdxInfo.sdxDisplayName) {
case "Gene Name":
i2b2.MedCo.popups.ByGene.ctrlr.show(i2b2.MedCo.QT.panels.indexOf(panel));
return;
case "Protein Position":
i2b2.MedCo.popups.ByProteinPosition.ctrlr.show(i2b2.MedCo.QT.panels.indexOf(panel));
return;
case "Variant Name":
i2b2.MedCo.popups.ByVariantName.ctrlr.show(i2b2.MedCo.QT.panels.indexOf(panel));
return;
}
var keyval = concept.sdxInfo.sdxKeyValue;
var sensitive = !keyval.includes("nonsensitive") && !keyval.includes("non-sensitive");
var conceptModel = sensitive ? concept.origData.basecode.split(":")[1] : (concept.origData.key).replace(/ NOT
var not = document.createElement("span")
not.className = "itemExclude"
not.title = "This item is being excluded"
not.innerHTML = "NOT"
conceptsDiv[i].insertBefore(not, conceptsDiv[i].firstChild);
}
}
else {
// remove the "NOT" in front of the concepts in the div
for (var i = 0; i < conceptsDiv.length; i++) {
conceptsDiv[i].removeChild(conceptsDiv[i].getElementsByClassName("itemExclude")[0])
}
}
};
panel.ctrlr.delete = function(){
var index = i2b2.MedCo.QT.panels.indexOf(panel)
if (index == -1){
alert("Impossible to delete the panel, panel inexistent.")
return
}
// delete the panel from the model
i2b2.MedCo.QT.panels.splice(index, 1)
// delete the panel from the view
var panels_container = document.getElementById("MedCo-QueryPanels")
var panels = panels_container.childElements()
panels_container.removeChild(panels[index]);
// update the group number in the header of the panels
panels = panels_container.childElements()
for (var i = 0; i < panels.length; i++) {
// i2b2.MedCo.QT.panels[i].group = (i + 1);
var header = panels[i].getElementsByClassName("groupId")[0]
header.innerHTML = 'Group ' + (i+1);
}
if (i2b2.MedCo.QT.panels.length != panels.length){
alert("Something went wrong: model and view are inconsistent.")
}
}
panel.ctrlr.isEmpty = function(){
// check there is at least a row which contains something
for (var i=0; i < panel.model.content.length; i++) {
if (panel.model.content[i].values.length > 0) {
return false;
}
}
return true;
}
};
i2b2.MedCo.QT.ctrlr.deletePanel = function(HTMLelem){
// HTMLelem: (clicked) html element
// first get the index of the panel
var index = getPanelIndex(HTMLelem);
if (index < 0){
alert("Panel not found");
return
}
// then call the delete function on it
i2b2.MedCo.QT.panels[index].ctrlr.delete()
};
i2b2.MedCo.QT.ctrlr.excludePanel = function(HTMLelem){
// HTMLelem: (clicked) html element
// first get the index of the panel
var index = getPanelIndex(HTMLelem)
if (index < 0){
alert("Panel not found")
return
}
// then call the exclude function on it
i2b2.MedCo.QT.panels[index].ctrlr.exclude(HTMLelem)
};
i2b2.MedCo.QT.ctrlr.showDateConstraint = function(HTMLelem){
var index = getPanelIndex(HTMLelem)
if (index < 0){
alert("Panel not found")
return
}
// alert("panel index:"+index)
i2b2.MedCo.QT.panels[index].model.date.ctrlr.show()
}
\ No newline at end of file
diff --git a/shrine-webclient/src/main/html/js-i2b2/cells/plugins/MedCo/MedCo_popups.js b/shrine-webclient/src/main/html/js-i2b2/cells/plugins/MedCo/MedCo_popups.js
index 2f1bb7f53..bfdc40c1f 100644
--- a/shrine-webclient/src/main/html/js-i2b2/cells/plugins/MedCo/MedCo_popups.js
+++ b/shrine-webclient/src/main/html/js-i2b2/cells/plugins/MedCo/MedCo_popups.js
@@ -1,1027 +1,1028 @@
i2b2.MedCo.popups = {};
i2b2.MedCo.popups.ctrlr = {};
// popups for building the query
i2b2.MedCo.popups.ByVariantName = {};
i2b2.MedCo.popups.ByVariantName.ctrlr = {};
i2b2.MedCo.popups.ByGene = {};
i2b2.MedCo.popups.ByGene.ctrlr = {};
i2b2.MedCo.popups.ByProteinPosition = {};
i2b2.MedCo.popups.ByProteinPosition.ctrlr = {};
// popup for managing the query type
i2b2.MedCo.popups.SelectQueryType = {};
i2b2.MedCo.popups.SelectQueryType.ctrlr = {};
// popup for authentication
i2b2.MedCo.popups.Authentication = {};
i2b2.MedCo.popups.Authentication.ctrlr = {};
i2b2.MedCo.popups.ctrlr.init = function (){
i2b2.MedCo.popups.ByVariantName.ctrlr.init();
i2b2.MedCo.popups.ByGene.ctrlr.init();
i2b2.MedCo.popups.ByProteinPosition.ctrlr.init();
i2b2.MedCo.popups.SelectQueryType.ctrlr.init();
i2b2.MedCo.popups.Authentication.ctrlr.init();
};
i2b2.MedCo.popups.ctrlr.clear = function(){
i2b2.MedCo.popups.ByVariantName.ctrlr.clear();
i2b2.MedCo.popups.ByGene.ctrlr.clear();
i2b2.MedCo.popups.ByProteinPosition.ctrlr.clear();
i2b2.MedCo.popups.SelectQueryType.ctrlr.clear();
i2b2.MedCo.popups.Authentication.ctrlr.clear();
};
i2b2.MedCo.popups.ctrlr.unload = function() {
// delete view of everything
i2b2.MedCo.popups.ByVariantName.ctrlr.unload();
i2b2.MedCo.popups.ByGene.ctrlr.unload();
i2b2.MedCo.popups.ByProteinPosition.ctrlr.unload();
i2b2.MedCo.popups.SelectQueryType.ctrlr.unload();
i2b2.MedCo.popups.Authentication.ctrlr.unload();
};
// Manage the php requests.
// success: function that takes as input the response form the server
// error: function that takes as input the error code returned by the server
// phpQuery: string that contains the path and the parameters of the request
function phpGETRequest(success, error, phpQuery) {
// create the request object to send the request and manage the response
var req = false;
try {
// most browsers
req = new XMLHttpRequest();
} catch (e) {
// IE
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
// try an older version
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {
return false;
}
}
}
// if the http request obj has not been created then return
if (!req) return false;
// update the request object to act when receiving the response
req.onreadystatechange = function () {
if (req.readyState == 4) {
return req.status === 200 ?
success(req.responseText) : error(req.status);
}
};
req.open("GET", phpQuery, true);
req.send(null);
return req;
};
// Function used to initialize gene, protein and variant popup (they have the same structure).
// -popup: contains variables used to create the pupup (e.g. title, description)
// -fetchParametersQuery: php query used retrieve the parameters (e.g. genes, proteins or variants). Contains
// "¶mValue" that must be filled with the value of the parameter selected from the popup
// -fetchVariantsQuery: the final objective of the popup is to fetch the variants. This should be the path to the php
// file that fetches the variants from the database.
i2b2.MedCo.popups.ctrlr.MedCo_queryPopupInit = function (fetchParametersQuery, fetchVariantsQuery, popup, ctrlr){
// ------ Initialize the model ------
var model = {};
model.choiceList = []; // here is stored the list of suggested parameters
// the panel number is passed to the popup when opened (so to bind the popup with a panel)
model.panelIndex = 0;
// ------ Initialize the view ------
popup.Id = "MedCo_" + popup.name + "Popup"
popup.paramInputBoxId = "search" + popup.name + "InputBox";
popup.heteroId = "heterozygous" + popup.name + "Popup";
popup.homoId = "homozygous" + popup.name + "Popup";
popup.unknId = "unknown" + popup.name + "Popup";
document.getElementById("MedCo-CONTENT").appendChild(htmlToElement(
"\n"));
var view = {};
view.popup = document.getElementById(popup.Id);
view.inputBox = document.querySelector("#"+ popup.Id + " #" +popup.paramInputBoxId);
view.zygosityList = {
heterozygousCheckbox: document.querySelector("#"+ popup.Id + " #" + popup.heteroId),
homozygousCheckbox: document.querySelector("#"+ popup.Id + " #" + popup.homoId),
unknownCheckbox: document.querySelector("#"+ popup.Id + " #" + popup.unknId)
};
// autocompletion for the inputBox
new autoComplete({
cache: false,
selector: '#' + popup.paramInputBoxId,
minChars: 1,
source: function(term, suggest){
term = term.toLowerCase();
var matches = [];
for (var i=0; i