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_view_History.js Maven / Gradle / Ivy
/**
* @projectDescription View controller for the history viewport. (CRC's "previous queries" window)
* @inherits i2b2.CRC.view
* @namespace i2b2.CRC.view.history
* @author Nick Benik, Griffin Weber MD PhD
* @version 1.3
* ----------------------------------------------------------------------------------------
* updated 9-15-08: RC4 launch [Nick Benik]
*/
console.group('Load & Execute component file: CRC > view > History');
console.time('execute time');
// create and save the screen objects
i2b2.CRC.view.history = new i2b2Base_cellViewController(i2b2.CRC, 'history');
i2b2.CRC.view.history.visible = false;
i2b2.CRC.view.history.autorefresh = '';
// define the option functions
// ================================================================================================== //
i2b2.CRC.view.history.showOptions = function(subScreen){
if (!this.modalOptions) {
setTimeout("i2b2.CRC.ctrlr.history._loadUsersInOptions();",300);
var handleSubmit = function(){
// submit value(s)
var value = $('HISTMaxQryDisp').value;
var userValue = $('HISTUser').value;
if(!isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10))){
if(parseInt(value, 10) > 0){
if (this.submit()) {
if ($('HISTsortOrderASC').checked) {
tmpValue = 'ASC';
}
else {
tmpValue = 'DESC';
}
i2b2.CRC.view['history'].params.sortOrder = tmpValue;
if ($('HISTsortByNAME').checked) {
tmpValue = 'NAME';
}
else {
tmpValue = 'DATE';
}
i2b2.CRC.view['history'].params.sortBy = tmpValue;
tmpValue = parseInt($('HISTMaxQryDisp').value, 10);
i2b2.CRC.view['history'].params.maxQueriesDisp = tmpValue;
i2b2.CRC.view['history'].params.userBy = userValue;
// requery the history list
i2b2.CRC.ctrlr.history.Refresh();
var refreshValue = parseInt($('HISTAuto').value, 10);
if(refreshValue > 0){
clearInterval(i2b2.CRC.view.history.autorefresh);
i2b2.CRC.view.history.autorefresh = setInterval(function(){ i2b2.CRC.ctrlr.history.Refresh(); }, refreshValue*1000);
} else {
clearInterval(i2b2.CRC.view.history.autorefresh);
}
}
} else {
alert('Please enter number greater than 0 for Maximum Children to Display.');
$('HISTMaxQryDisp').style.border = "2px inset red";
}
} else {
alert('Please enter a valid number for Maximum Queries to Display.');
$('HISTMaxQryDisp').style.border = "2px inset red";
}
}
var handleCancel = function(){
this.cancel();
}
this.modalOptions = new YAHOO.widget.SimpleDialog("optionsHistory", {
width: "400px",
fixedcenter: true,
constraintoviewport: true,
modal: true,
zindex: 700,
buttons: [{
text: "OK",
handler: handleSubmit,
isDefault: true
}, {
text: "Cancel",
handler: handleCancel
}]
});
$('optionsHistory').show();
this.modalOptions.validate = function(){
// now process the form data
var tmpValue = parseInt($('HISTMaxQryDisp').value, 10);
var value = $('HISTMaxQryDisp').value;
if(!isNaN(value) && parseInt(Number(value)) == value && !isNaN(parseInt(value, 10))){
$('HISTMaxQryDisp').style.border = "2px inset";
return true;
} else {
alert("The max number of Queries must be a whole number larger then zero.");
$('HISTMaxQryDisp').style.border = "2px inset red";
return false;
}
};
this.modalOptions.render(document.body);
}
this.modalOptions.show();
// load settings
if (this.params.sortOrder=="ASC") {
$('HISTsortOrderASC').checked = true;
} else {
$('HISTsortOrderDESC').checked = true;
}
if (this.params.sortBy=="NAME") {
$('HISTsortByNAME').checked = true;
} else {
$('HISTsortByDATE').checked = true;
}
$('HISTMaxQryDisp').value = this.params.maxQueriesDisp;
}
// ================================================================================================== //
i2b2.CRC.view.history.ToggleNode = function(divTarg, divTreeID) {
// get the i2b2 data from the yuiTree node
var tvTree = YAHOO.widget.TreeView.getTree(divTreeID);
var tvNode = tvTree.getNodeByProperty('nodeid', divTarg.id);
tvNode.toggle();
}
i2b2.CRC.view.history.selectTab = function(tabCode) {
// toggle between the Navigate and Find Terms tabs
switch (tabCode) {
case "find":
$('crctabFind').addClassName('active');
$('crctabNavigate').removeClassName('active');
$('crcNavDisp').hide();
$('crcFindDisp').show();
break;
case "nav":
$('crctabNavigate').addClassName('active');
$('crctabFind').removeClassName('active');
$('crcFindDisp').hide();
$('crcNavDisp').show();
break;
}
}
// ================================================================================================== //
i2b2.CRC.view.history.Resize = function(e) {
// this function provides the resize functionality needed for this screen
var viewObj = i2b2.CRC.view.history;
var ve = $('crcHistoryBox');
if (viewObj.visible) {
ve.show();
// var ds = document.viewport.getDimensions();
var w = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
var h = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
if (w < 840) {w = 840;}
if (h < 517) {h = 517;}
ve = ve.style;
// resize our visual components
switch(i2b2.hive.MasterView.getViewMode()) {
case "Patients":
if (i2b2.WORK && i2b2.WORK.isLoaded) {
// make room for the workspace window
ve.width = Math.max(initBrowserViewPortDim.width-rightSideWidth, 0);
ve.top = h-196+44-48;
$('crcHistoryData').style.height = '125px';
$('crcSearchNamesResults').style.height = '120px';
} else {
ve.width = w-578;
ve.top = h-196;
$('crcHistoryData').style.height = '144px';
$('crcSearchNamesResults').style.height = '116px';
}
break;
case "Analysis":
if (i2b2.WORK && i2b2.WORK.isLoaded) {
// make room for the workspace window
w = parseInt(w/3)-10;
ve.width = w;
ve.top = h-196+44-48;
$('crcHistoryData').style.height = '125px';
$('crcSearchNamesResults').style.height = '120px';
} else {
w = parseInt(w/3)-10;
ve.width = w;
ve.top = h-196-48;
$('crcHistoryData').style.height = '144px';
$('crcSearchNamesResults').style.height = '116px';
}
break;
}
if (viewObj.isZoomed) {
ve.top = '';
$('crcHistoryData').style.height = h-97-25;
$('crcSearchNamesResults').style.height = h-125;
}
$$('DIV#crcHistoryBox DIV#crcHistoryData')[0].style.width = (parseInt(ve.width)-24) + 'px';
$$('DIV#crcHistoryBox DIV#crcSearchNamesResults')[0].style.width = (parseInt(ve.width)-24) + 'px';
} else {
ve.hide();
}
}
//YAHOO.util.Event.addListener(window, "resize", i2b2.CRC.view.history.Resize, i2b2.CRC.view.history); // tdw9
i2b2.CRC.view.history.Resize();
//================================================================================================== //
i2b2.CRC.view.history.splitterDragged = function()
{
var splitter = $( i2b2.hive.mySplitter.name );
var CRCHist = $("crcHistoryBox");
CRCHist.style.width = Math.max((parseInt(splitter.style.left) - CRCHist.offsetLeft - 3), 0) + "px";
$$('DIV#crcHistoryBox DIV#crcHistoryData')[0].style.width = Math.max((parseInt(CRCHist.style.width)-24), 0) + 'px';
$$('DIV#crcHistoryBox DIV#crcSearchNamesResults')[0].style.width = Math.max((parseInt(CRCHist.style.width)-24), 0) + 'px';
}
//================================================================================================== //
i2b2.CRC.view.history.ResizeHeight = function() {
// this function provides the resize functionality needed for this screen
var viewObj = i2b2.CRC.view.history;
var ve = $('crcHistoryBox');
if (viewObj.visible) {
ve.show();
// var ds = document.viewport.getDimensions();
var h = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
if (h < 517) {h = 517;}
ve = ve.style;
// resize our visual components
switch(i2b2.hive.MasterView.getViewMode()) {
case "Patients":
if (i2b2.WORK && i2b2.WORK.isLoaded) {
// make room for the workspace window
ve.top = h-196+44-48;
$('crcHistoryData').style.height = '125px';
$('crcSearchNamesResults').style.height = '120px';
} else {
ve.top = h-196;
$('crcHistoryData').style.height = '144px';
$('crcSearchNamesResults').style.height = '144px';
}
break;
case "Analysis":
if (i2b2.WORK && i2b2.WORK.isLoaded) {
// make room for the workspace window
ve.top = h-196+44-48;
$('crcHistoryData').style.height = '125px';
$('crcSearchNamesResults').style.height = '120px';
} else {
ve.top = h-196;
$('crcHistoryData').style.height = '144px';
$('crcSearchNamesResults').style.height = '144px';
}
break;
}
if (viewObj.isZoomed) {
ve.top = '';
$('crcHistoryData').style.height = h-97-25;
$('crcSearchNamesResults').style.height = h-125;
}
} else {
ve.hide();
}
}
// ================================================================================================== //
i2b2.CRC.view.history.PopulateQueryMasters = function(dm_ptr, dm_name, options) {
var thisview = i2b2.CRC.view.history;
// clear the data first
var tvTree = i2b2.CRC.view.history.yuiTree;
var tvRoot = tvTree.getRoot();
tvTree.removeChildren(tvRoot);
tvTree.locked = false;
// sort by the options
if (Object.isUndefined(options)) { var options = {}; }
if (!options.sortBy) { options.sortBy = 'DATE'; }
if (!options.sortOrder) { options.sortBy = 'DESC'; }
if (options.sortBy=='NAME') {
var compareAttrib = 'name';
} else {
var compareAttrib = 'created';
}
if (options.sortOrder=='ASC') {
var reverseSort = false;
} else {
var reverseSort = true;
}
// NEW SORT METHOD USING prototype Enumerators
var QM_sortVal = function(rec) {
var hash_key = rec[0];
var sdxExtObj = rec[1];
var cl_compareAttrib = compareAttrib; // <---- closure var
var t = sdxExtObj.origData[cl_compareAttrib];
if (cl_compareAttrib=="created") {
// proper date handling (w/improper handling for latest changes to output format)
var sd = t.toUpperCase();
if (sd.indexOf('Z') != -1 || sd.indexOf('T') != -1) {
t = t.toLowerCase();
} else {
t = Date.parse(t);
}
} else {
t = String(t.toLowerCase() );
}
return t;
};
var sortFinal = i2b2.CRC.model.QueryMasters.sortBy(QM_sortVal);
// reverse if needed
if (reverseSort) { sortFinal.reverse(true); }
// populate the Query Masters into the treeview
for (var i=0; i
i2b2.CRC.view.history.queryResponse = cellResult.msgResponse;
i2b2.CRC.view.history.queryRequest = cellResult.msgRequest;
i2b2.CRC.view.history.queryUrl = cellResult.msgUrl;
//
for(var i1=0; i1<1*cellResult.results.length; i1++) {
var o = cellResult.results[i1];
var renderOptions = {
title: o.origData.title,
dragdrop: "i2b2.sdx.TypeControllers.QI.AttachDrag2Data",
dblclick: "i2b2.CRC.view.history.ToggleNode(this,'"+cl_node.tree.id+"')",
icon: "sdx_CRC_QI.gif",
iconExp: "sdx_CRC_QI_exp.gif"
};
var sdxRenderData = i2b2.sdx.Master.RenderHTML(cl_node.tree.id, o, renderOptions);
i2b2.sdx.Master.AppendTreeNode(cl_node.tree, cl_node, sdxRenderData);
}
// handle the YUI treeview
if (getObjectClass(cl_onCompleteCB)=='i2b2_scopedCallback') {
cl_onCompleteCB.callback.call(cl_onCompleteCB.scope, cellResult);
} else {
cl_onCompleteCB(cellResult);
}
}
var sdxParentNode = node.data.i2b2_SDX;
i2b2.sdx.Master.getChildRecords(sdxParentNode, scopedCallback);
}));
i2b2.sdx.Master.setHandlerCustom('crcSearchNamesResults', 'QM', 'LoadChildrenFromTreeview', (function(node, onCompleteCallback) {
var scopedCallback = new i2b2_scopedCallback();
scopedCallback.scope = node.data.i2b2_SDX;
scopedCallback.callback = function(cellResult) {
var cl_node = node;
var cl_onCompleteCB = onCompleteCallback;
// THIS function is used to process the AJAX results of the getChild call
// results data object contains the following attributes:
// refXML: xmlDomObject <--- for data processing
// msgRequest: xml (string)
// msgResponse: xml (string)
// error: boolean
// errorStatus: string [only with error=true]
// errorMsg: string [only with error=true]
//
i2b2.CRC.view.history.queryResponse = cellResult.msgResponse;
i2b2.CRC.view.history.queryRequest = cellResult.msgRequest;
i2b2.CRC.view.history.queryUrl = cellResult.msgUrl;
//
for(var i1=0; i1<1*cellResult.results.length; i1++) {
var o = cellResult.results[i1];
var renderOptions = {
title: o.origData.title,
dragdrop: "i2b2.sdx.TypeControllers.QI.AttachDrag2Data",
dblclick: "i2b2.CRC.view.history.ToggleNode(this,'"+cl_node.tree.id+"')",
icon: "sdx_CRC_QI.gif",
iconExp: "sdx_CRC_QI_exp.gif"
};
var sdxRenderData = i2b2.sdx.Master.RenderHTML(cl_node.tree.id, o, renderOptions);
i2b2.sdx.Master.AppendTreeNode(cl_node.tree, cl_node, sdxRenderData);
}
// handle the YUI treeview
if (getObjectClass(cl_onCompleteCB)=='i2b2_scopedCallback') {
cl_onCompleteCB.callback.call(cl_onCompleteCB.scope, cellResult);
} else {
cl_onCompleteCB(cellResult);
}
}
var sdxParentNode = node.data.i2b2_SDX;
i2b2.sdx.Master.getChildRecords(sdxParentNode, scopedCallback);
}));
// -------------------------------------------------------
i2b2.CRC.view.history.ContextMenu = new YAHOO.widget.ContextMenu(
"divContextMenu-History",
{ lazyload: true,
trigger: $('crcNavDisp'),
itemdata: [
{ text: "Display", onclick: { fn: i2b2.CRC.view.history.doDisplay } },
{ text: "Rename", onclick: { fn: i2b2.CRC.view.history.doRename } },
{ text: "Delete", onclick: { fn: i2b2.CRC.view.history.doDelete } },
{ text: "Refresh All", onclick: { fn: i2b2.CRC.view.history.doRefreshAll } }
] }
);
i2b2.CRC.view.history.ContextMenu.subscribe("triggerContextMenu",i2b2.CRC.view.history.ContextMenuValidate);
// =========================================================
}
})
);
//================================================================================================== //
i2b2.events.initView.subscribe((function(eventTypeName, newMode) {
// -------------------------------------------------------
this.visible = true;
if (i2b2.WORK && i2b2.WORK.isLoaded) {
$('crcHistoryData').style.height = '125px';
$('crcSearchNamesResults').style.height = '120px';
} else {
$('crcHistoryData').style.height = '144px';
$('crcSearchNamesResults').style.height = '116px';
}
$('crcHistoryBox').show();
this.Resize();
// -------------------------------------------------------
}),'',i2b2.CRC.view.history);
// ================================================================================================== //
i2b2.events.changedViewMode.subscribe((function(eventTypeName, newMode) {
newMode = newMode[0];
this.viewMode = newMode;
switch(newMode) {
case "Patients":
case "Analysis":
var wlst = i2b2.hive.MasterView.getZoomWindows();
if (wlst.indexOf("ONT")!=-1 || wlst.indexOf("WORK")!=-1) { return; }
this.visible = true;
if (i2b2.WORK && i2b2.WORK.isLoaded) {
$('crcHistoryData').style.height = '125px';
$('crcSearchNamesResults').style.height = '120px';
} else {
$('crcHistoryData').style.height = '144px';
$('crcSearchNamesResults').style.height = '116px';
}
$('crcHistoryBox').show();
//this.Resize(); // tdw9
this.splitterDragged();
this.ResizeHeight();
break;
default:
this.visible = false;
$('crcHistoryBox').hide();
break;
}
}),'',i2b2.CRC.view.history);
// ================================================================================================== //
i2b2.events.changedZoomWindows.subscribe((function(eventTypeName, zoomMsg) {
newMode = zoomMsg[0];
if (!newMode.action) { return; }
if (newMode.action == "ADD") {
switch (newMode.window) {
case "HISTORY":
this.isZoomed = true;
this.visible = true;
break;
case "ONT":
case "WORK":
this.visible = false;
this.isZoomed = false;
}
} else {
switch (newMode.window) {
case "HISTORY":
case "ONT":
case "WORK":
this.isZoomed = false;
this.visible = true;
}
}
this.ResizeHeight();
this.splitterDragged();
}),'',i2b2.CRC.view.history);
console.timeEnd('execute time');
console.groupEnd();