Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
webclient.js-i2b2.cells.CRC.CRC_ctrlr_TQryPanel.js Maven / Gradle / Ivy
/**
* @projectDescription Controller for Temporal Query Tool's query panels. (GUI-only controller).
* @inherits CRC_ctrlr_QryPanel
* @namespace
* @author Taowei David Wang (tdw9)
* @version 1.0
* ----------------------------------------------------------------------------------------
*
*/
function TQueryPanelController(eventController, panelDOMID, index, isSecondary)
{
//tdw9: 1710: inheriting from i2b2_PanelController's
i2b2_PanelController.call(this, null);
this.initialize = function()
{
this.yuiTree = new YAHOO.widget.TreeView( this.domID + "_content" ); // add yui treeview to content panel
// add click handler to date and exclude controls
jQuery('#' + this.domID + ' [class^="temporalPanelDatesDiv"]').click(function() { self.handlePanelDates(); });
jQuery('#' + this.domID + ' [class^="temporalPanelExcludeDiv"]').click(function() { self.handleExclude(); });
// add content panel to context menu trigger list
var triggers = i2b2.CRC.view.TQuery.ContextMenuObj.cfg.getProperty("trigger");
triggers.push( $(this.domID + "_content") );
i2b2.CRC.view.TQuery.ContextMenuObj.cfg.setProperty("trigger", triggers);
};
this.attachDropHandlers = function()
{
var dropTargetDomID = this.domID + "_content";
var op_trgt = { dropTarget: true };
i2b2.sdx.Master.AttachType(dropTargetDomID, 'CONCPT', op_trgt); // tdw9 1707c: lets the panel accept drops
var funcHovOverCONCPT = function(e, id, ddProxy)
{
jQuery("#" + dropTargetDomID).addClass('ddCONCPTTarget');
}
var funcHovOutCONCPT = function(e, id, ddProxy)
{
jQuery("#" + dropTargetDomID).removeClass('ddCONCPTTarget');
}
i2b2.sdx.Master.setHandlerCustom(dropTargetDomID, 'CONCPT', 'onHoverOut', funcHovOutCONCPT);
i2b2.sdx.Master.setHandlerCustom(dropTargetDomID, 'CONCPT', 'onHoverOver', funcHovOverCONCPT);
i2b2.sdx.Master.setHandlerCustom(dropTargetDomID, 'CONCPT', 'DropHandler', (function(sdxData)
{
sdxData = sdxData[0]; // only interested in first record
if (self.index != 0 && !sdxData.origData.isModifier)
{
alert("This panel only accepts Modifiers.");
return;
}
self.performDrop(sdxData);
// increment tutorial state
var eventID = jQuery("#"+dropTargetDomID).parent().parent().attr("id");
i2b2.CRC.view.QT.incrementTutorialState(1, {"id":eventID} );
}));
i2b2.sdx.Master.setHandlerCustom(dropTargetDomID, 'CONCPT', 'AppendTreeNode', this.funcATN);
};
/* Detaches handlers by removing its references directly from i2b2.sdx.Mater._sysData. This is called when user initiates a panel deletion */
this.detachDropHandlers = function()
{
var dropTargetDomID = this.domID + "_content";
delete i2b2.sdx.Master._sysData[dropTargetDomID]; // delete references to handlers
};
/* removes self from the list of triggers known to the context menu */
this.detachContextMenuTriggers = function()
{
var thisPanelContent = $(this.domID + "_content");
var triggers = i2b2.CRC.view.TQuery.ContextMenuObj.cfg.getProperty("trigger"); // get reference to triggers
for ( var i = 0; i < triggers.length; i++ )
{
if ( triggers[i] == thisPanelContent)
{
triggers.splice(i, 1); // removes self form triggers
break;
}
}
i2b2.CRC.view.TQuery.ContextMenuObj.cfg.setProperty("trigger", triggers);
}
/* Handles concept drops into the panel */
this.performDrop = function(sdxConceptOrig)
{
i2b2.CRC.view.QT.resetQueryResults();
var sdxConcept = i2b2.sdx.TypeControllers.CONCPT.MakeObject(sdxConceptOrig.origData.xmlOrig, sdxConceptOrig.origData.isModifier, null, sdxConceptOrig.origData.parent, sdxConceptOrig.sdxInfo.sdxType);
// following nw096's Date Constraints overhaul
if (this.dateFrom)
sdxConcept.dateFrom = this.dateFrom;
if (this.dateTo)
sdxConcept.dateTo = this.dateTo;
// save data
var newConceptInfo = this.performAddConcept(sdxConcept, this.yuiTree.root, true);
this.redrawTree(); // draw the node
this.redrawItemExclusion();
this.redrawItemDates();
};
this.performAddConcept = function(sdxConcept, tvParent, isDragged)
{
var tmpNode = this._addConceptVisuals.call(this, sdxConcept, tvParent, isDragged, this);
sdxConcept.itemNumber = this.items.length + 1; // assign itemNumber to each item so things like modlab dialog will work properly. This number comforms with i2b2_PanelController.itemNumber, which, inexplicably, starts with 1, not 0.
sdxConcept.parentPanel = this; // link sdxConcept to this panel controller
sdxConcept.renderData = tmpNode; // tdw9:1710 attach tmpNode as renderData for sdxConcept (sdxConcept.renderData cannot be null when invoking Lab/Mod dialog)
this.items.push( sdxConcept );
return tmpNode;
}
this.performDeleteConcept = function(htmlID, itemNum)
{
if (undefined===htmlID) return; // nothing to delete
i2b2.CRC.view.QT.resetQueryResults();
var node = this.yuiTree.getNodeByProperty('nodeid', htmlID );
this.yuiTree.removeNode(node, false); // remove visual in tree
this.items.splice(itemNum-1,1); // remove concept in model (we use itemNumber-1 because items[i].itemNumber = i+1)
this.redrawTree();
this.redrawItemExclusion();
this.redrawItemDates();
// re-assign itemNumber for all remaining items
for (var i = 0; i < this.items.length; i++)
this.items[i].itemNumber = i+1;
};
this.performChangeConceptDate = function(htmlID, itemNum)
{
if (undefined === htmlID) return; // nothing to change
i2b2.CRC.ctrlr.dateConstraint.tqShowDates( this.items[itemNum-1], itemNum-1 );
};
// tdw9: 1710: the following two methods now call the proper functions with proper arguments
this.performChangeLabValue = function( sdxConcept )
{
if (undefined === sdxConcept) return; // nothing to change
this.showLabValues(sdxConcept.origData.key, sdxConcept);
};
this.performChangeModValue = function( sdxConcept )
{
if (undefined === sdxConcept) return; // nothing to change
this.showModValues(sdxConcept.origData.key, sdxConcept);
};
this.handleExclude = function(bExclude)
{
if ( this.items.length == 0) return; // do nothing if there are no items
i2b2.CRC.view.QT.resetQueryResults();
var bVal;
if (undefined != bExclude)
bVal = bExclude;
else
bVal = !Boolean(this.exclude);
this.exclude = bVal;
//this._redrawButtons(dm);
this.redrawExcludeButton();
this.redrawItemExclusion();
this.redrawItemDates();
// clear the query name and set the query as having dirty data
//var QT = i2b2.CRC.ctrlr.QT;
//QT.doSetQueryName.call(QT, '');
};
this.handlePanelDates = function()
{
i2b2.CRC.ctrlr.dateConstraint.tqShowDates(self);
};
// returns whether the panel is empty
this.isEmpty = function()
{ return this.items.length == 0; };
/********************************************************************************
* (tdw9: 1710) Overriding i2b2_PanelController functions for Mod/Lab selector
*********************************************************************************/
this.showLabValues = function(key, extData)
{
this.currentTerm = extData; // save value as this.currentTerm, which is required for ModLabVlues to work properly
i2b2.CRC.view.modLabvaluesCtlr.selectValueBox(-1, this, key, extData, false, this); // pass in this as pluginObj
};
this.showModValues = function(key, extData)
{
this.currentTerm = extData; // save value as this.currentTerm, which is required for ModLabVlues to work properly
i2b2.CRC.view.modLabvaluesCtlr.selectValueBox(-1, this, key, extData, true, this); // pass in this as pluginObj
};
/********************************************************************************
* (tdw9: 1710) Implement function necessary for ModLabValues to work properly
*********************************************************************************/
this.conceptsRenderFromValueBox = function()
{
var closure_number = this.currentTerm.itemNumber;
// find the correct item in the panel
for (var i = 0; i < this.items.length; i++)
{
if (this.items[i].itemNumber == closure_number)
{
if (this.currentTerm.origData.isModifier)
{
this.items[i].ModValues = this.currentTerm.ModValues;
}
else
{
this.items[i].LabValues = this.currentTerm.LabValues;
}
break;
}
}
// update the panel/query tool GUI
i2b2.CRC.ctrlr.QT.doSetQueryName.call(this, '');
this._performRenameConcept(this.currentTerm.itemNumber, this.currentTerm.origData.isModifier, this);
i2b2.CRC.view.QT.resetQueryResults(); // reset query results
};
/***************************************************************
* Redraw functions
****************************************************************/
this.redrawTree = function()
{
//if (undefined === pd.tvRootNode)
// pd.tvRootNode = this.yuiTree.root;
// redraw tree
this.yuiTree.draw();
/*
for (var i = 0; i < pd.tvRootNode.children.length; i++) {
// fix the folder icon for expanded folders
var n = pd.tvRootNode.children[i];
this._redrawTreeFix.call(this, n);
}
*/
};
this.redrawExcludeButton = function()
{
jQuery('#' + this.domID + " .temporalPanelExcludeDiv").removeClass("temporalPanelButtonActive");
if (this.exclude)
jQuery('#' + this.domID + " .temporalPanelExcludeDiv").addClass("temporalPanelButtonActive"); // adds underline style
};
this.redrawItemExclusion = function()
{
jQuery('#' + this.domID + "_content" + ' [class^="sdxDefault"]').find('span.itemExclude').remove();
if (this.exclude)
{
for (var i = 0; i < this.items.length; i++)
{
jQuery(' NOT ').prependTo(jQuery('#' +this.domID + '_content [class^="sdxDefault"]')[i]);
}
}
}
this.redrawDateButton = function() {
jQuery('#' + this.domID + " .temporalPanelDatesDiv").removeClass("temporalPanelButtonActive");
if (this.dateFrom || this.dateTo )
jQuery('#' + this.domID + " .temporalPanelDatesDiv").addClass("temporalPanelButtonActive"); // adds underline style
};
this.redrawItemDates = function()
{
jQuery('#' + this.domID + ' table.ygtvdepth0 [class^="sdxDefault"]').find('span.itemDateConstraint').remove();
if (this.items.length > 0) {
for (var i = 0; i < this.items.length; i++) {
if (this.items[i].dateFrom && this.items[i].dateTo)
jQuery(' [' + this.items[i].dateFrom.Month + '/' + this.items[i].dateFrom.Day + '/' + this.items[i].dateFrom.Year + ' to ' + this.items[i].dateTo.Month + '/' + this.items[i].dateTo.Day + '/' + this.items[i].dateTo.Year + '] ').appendTo(jQuery('#' + this.domID + ' table.ygtvdepth0 [class^="sdxDefault"]')[i]);
if (this.items[i].dateFrom && !this.items[i].dateTo)
jQuery(' [≥' + this.items[i].dateFrom.Month + '/' + this.items[i].dateFrom.Day + '/' + this.items[i].dateFrom.Year + '] ').appendTo(jQuery('#' + this.domID + ' table.ygtvdepth0 [class^="sdxDefault"]')[i]);
if (!this.items[i].dateFrom && this.items[i].dateTo)
jQuery(' [≤' + this.items[i].dateTo.Month + '/' + this.items[i].dateTo.Day + '/' + this.items[i].dateTo.Year + '] ').appendTo(jQuery('#' + this.domID + ' table.ygtvdepth0 [class^="sdxDefault"]')[i]);
}
}
};
this.funcATN = function(yuiTree, yuiParentNode, sdxDataPack, callbackLoader)
{
var myobj = { html: sdxDataPack.renderData.html, nodeid: sdxDataPack.renderData.htmlID }
// if the treenode we are appending to is the root node then do not show the [+] infront
if (yuiTree.getRoot() == yuiParentNode) {
var tmpNode = new YAHOO.widget.HTMLNode(myobj, yuiParentNode, false, false);
} else {
var tmpNode = new YAHOO.widget.HTMLNode(myobj, yuiParentNode, false, true);
}
if (sdxDataPack.renderData.iconType != 'CONCPT_item' && !Object.isUndefined(callbackLoader)) {
// add the callback to load child nodes
sdxDataPack.sdxInfo.sdxLoadChildren = callbackLoader;
}
tmpNode.data.i2b2_SDX = sdxDataPack;
tmpNode.toggle = function() {
if (!this.tree.locked && (this.hasChildren(true))) {
var data = this.data.i2b2_SDX.renderData;
var img = this.getContentEl();
img = Element.select(img, 'img')[0];
if (this.expanded) {
img.src = data.icon;
this.collapse();
} else {
img.src = data.iconExp;
this.expand();
}
}
};
if (sdxDataPack.renderData.iconType == 'CONCPT_leaf' || !sdxDataPack.renderData.canExpand) { tmpNode.dynamicLoadComplete = true; }
};
/****************************************************************************************************
* Code called to change a treenode that represents a concept that changes names (e.g. change of value). Ref: CRC_ctrlr_QryPanel.js: _renameConcept
* pd is an instance of TQueryPanelController
****************************************************************************************************/
this._performRenameConcept = function(key, isModifier, pd)
{
$('infoQueryStatusText').innerHTML = "";
$('infoQueryStatusChart').innerHTML = "";
$('infoQueryStatusReport').innerHTML = "";
// remove the concept from panel
for (var i = 0; i < pd.items.length; i++)
{
if ((pd.items[i].origData.key == key) || (pd.items[i].itemNumber == key))
{
// found the concept to remove
var rto = pd.items[i];
break;
}
}
if (undefined === rto) { return; }
// rename the node in the treeview
var tvChildren = this.yuiTree.root.children;
for (var i = 0; i < tvChildren.length; i++)
{
if (tvChildren[i].data.i2b2_SDX.sdxConcept.itemNumber == key)
{
var tt = tvChildren[i].getContentHtml();
var tt2 = tt.substring(0, tt.lastIndexOf("\"/>") + 3);
var tt3 = "";
if (isModifier)
{
var values = rto.ModValues;
var modParent = rto.origData.parent;
while (modParent != null)
{
if (modParent.isModifier)
modParent = modParent.parent;
else
break;
}
tt2 += modParent.name + " [" + rto.origData.name;
tt3 = "]";
rto.origData.newName = modParent.name + " [" + rto.origData.name;
}
else
{
var values = rto.LabValues;
tt2 += rto.origData.name;
rto.origData.newName = rto.origData.name;
}
tvChildren[i].html = tt2 + tt3 + "