遇到BUG,本文待補中
document.write("<iframe id=\"toolbar\" src=\"toolbar.html?mode=main\" style=\"border:none;\" ></iframe>");
document.write("<iframe id=\"instance\" style=\"border-bottom-style: none; border: none; border-right-style: none;\" ></iframe>");
document.write("<iframe id=\"relationships\" scrolling=\"no\" style=\"border: none; border-right-style: none;\" ></iframe>");
//+++ PUBLIC METHODS +++
function MarkTabToDisplay(relationshipName, relationshipGridSrc, relationshipGridSrcParameters, bDoDisplayTab)
//Required params: relationshipName
//Note: MUST be called before tabs loading (for example from ACW onload event).
{
var obj;
if (bDoDisplayTab === undefined) bDoDisplayTab = true;
if (bDoDisplayTab) {
obj = { name: relationshipName, src: relationshipGridSrc, srcParams: relationshipGridSrcParameters };
for (var i = 0; i < relshipsMetaData.length; i++) {
if (obj && relationshipName == relshipsMetaData[i].name) {
relshipsMetaData[i] = obj;
obj = null;
}
}
if (obj) relshipsMetaData.push(obj);
atLeastOneTabExists = true;
}
else {
var filteredArr = new Array();
for (var i = 0; i < relshipsMetaData.length; i++) {
if (relationshipName != relshipsMetaData[i].name) {
filteredArr.push(relshipsMetaData[i]);
}
}
relshipsMetaData = filteredArr;
}
}
//--- PUBLIC METHODS ---
//++++ to setup relationships ++++
var LocationSearches;
var relshipsMetaData = new Array(); //an element is an object. Properties: name - (relship type name), node - RelationshipType node, src - src to reflect relationships, srcParams - parameters string
var actItemTypeNd;
function initMainToolbar() {
var tbFrm = document.getElementById("toolbar").contentWindow;
if (relshipsMetaData.length < 1 || !tbFrm || !tbFrm.toolbarReady) {
return;
}
var idenList = aras.getIdentityList();
var isCompleteVisible = (idenList && m && idenList.indexOf(m) > -1);
tbFrm.setControlVisible("complete_main", true);
}
//++++ to setup relationships ++++
var atLeastOneTabExists = false
function initRelationships() {
//LocationSearches = { relationships: "?db=" + aras.getDatabase() + "&ITName=Activity2&itemID=" + ActivityItem.getAttribute("id") + "&editMode=1&tabbar=1&toolbar=1&where=dialog" };
document.getElementById("relationships").contentWindow.location.replace("relationships.html");
}
console.log("-----------------xx");
var rtNames = new Array("WorkOrder");
var rtsWithConfigurableGrids = new Object();//key is relship name, value is conf grid name
rtsWithConfigurableGrids["WorkOrder"] = "workorder_grid";
var itm = aras.itemsCache;
console.log("-----------------00");
//+++ Get Configurable Grids ids, Activity2 Assignments, Activity2 Task ids
var aml2send;
var tmpDom = top.aras.createXMLDocument();
var r;
aml2send = "<Item type='Work Order' action='get' select='id'><Relationships>";
aml2send += "</Relationships></Item>";
r = top.aras.applyItem(aml2send);
console.log("-----------------01");
var namesOfCfgGrids = new Array();
for (var i=0; i<rtNames.length; i++)
{
var nm = rtsWithConfigurableGrids[rtNames[i]];
if (nm) namesOfCfgGrids.push(nm);
}
var cfgGridsIds = new Object();
if (namesOfCfgGrids.length>0)
{
var aml2send = "";
var tmpDom = top.aras.createXMLDocument();
var nms = "'"+namesOfCfgGrids.join("','")+"'";
aml2send = getQueryXml("Grid", "id,name", "name", nms, "in");//query to get Grid ids
r = top.aras.applyAML(aml2send);
if (r && r.indexOf("Item")>-1)
{
if (r.indexOf("<Result>")!==0) r = "<Result>"+r+"</Result>";
tmpDom.loadXML(r);
var nds = tmpDom.documentElement.selectNodes("Item[@type='Grid']");
for (var j=0; j<nds.length; j++)
{
var nd = nds[j];
cfgGridsIds[top.aras.getItemProperty(nd, "name")] = nd.getAttribute("id");
}
}
}
console.log("-----------------02");
//--- Get Configurable Grids ids, Activity2 Assignments, Activity2 Task
var rts2display = new Array();
//var itmID = itm.getAttribute("id");
var db = top.aras.getDatabase();
for (var i=0; i<rtNames.length; i++)
{
var src = "relationshipsGrid.html";
var srcParams;
var rtNm = rtNames[i];
var isDeliv = (rtNm=="Activity2 Deliverable");
var customToolbar = ((rtNm == "Activity2 Assignment" || rtNm == "Activity2 Task") ? "" : "&custom_toolbar_src=../Solutions/Project/Scripts/ActivityCompletionWorksheet/toolbar.html"+(isDeliv ? "?mode=deliv" : ""));
//srcParams = "?db="+db+"&ITName=Activity2"+"&relTypeID="+rtId+"&editMode=1&popupDisabled=1&toolbar=0"+customToolbar;
var doDisplayCfgGrid = (rtNames)
var cfgGridNm = rtsWithConfigurableGrids[rtNm];
if (cfgGridNm && cfgGridsIds[cfgGridNm])
{
src = "configurableGrid.html";
srcParams = "?grid="+cfgGridsIds[cfgGridNm]+customToolbar;
}
rts2display.push({name:rtNm, src:src, srcParams:srcParams});
}
console.log("-----------------03");
for (var i=0; i<rts2display.length; i++)
{
var ob = rts2display[i];
console.log(ob);
MarkTabToDisplay(ob.name, ob.src, ob.srcParams);
}
console.log("-----------------04");
var item=aras.itemsCache;
initRelationships();
initMainToolbar();
//------- display fields for rollup properties if need
function getQueryXml(itName, select, conditionPropNm, conditionPropVal, conditionAttrVal)
{
var aml="<AML><Item type='"+itName+"' action='get' select='"+select+"'><"+conditionPropNm+" condition='"+conditionAttrVal+"'>"+conditionPropVal+"</"+conditionPropNm+"></Item></AML>";
return aml;
}