/******************************************************************************************************************************** * Licensed Materials - Property of IBM * * * * IBM Cognos Products: HTS * * * * (C) Copyright IBM Corp. 2005, 2022 * * * * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. * *********************************************************************************************************************************/ /* * Called when a task is skipped */ function hts_skipTask(fragmentObj, fragmentName) { fragmentObj_retrieve(fragmentObj, "action=skipTask", null, true); return true; } /* * Called when a task is completed */ function hts_complete(fragmentObj, fragmentName) { fragmentObj_retrieve(fragmentObj, "action=complete", null, true); return true; } function hts_claimTask(fragmentObj, fragmentName) { fragmentObj_retrieve(fragmentObj, "action=claim", null, true); return true; } function hts_releaseTask(fragmentObj, fragmentName) { fragmentObj_retrieve(fragmentObj, "action=release", null, true); return true; } /* */ function hts_createNotificationTask(fragmentObj, fragmentName) { var iframe = $(fragmentName+'_notificationMessageValue_iframe'); var bodytext = iframe.contentDocument? iframe.contentDocument.body.textContent : iframe.contentWindow.document.body.innerText; $(fragmentName+'_notificationMessageTextValue').value = bodytext; var params = new hts_taskUpdateParams("action=createNotificationTask"); if (params) { var messages = hts_getMsgs(fragmentName); //the value entered for "To" field var recipients = document.getElementById(fragmentName + '_potentialOwners_value'); //the value entered for "CC" field var stakeholders = document.getElementById(fragmentName + '_stakeHolders_value'); if ((recipients.value == '' || recipients.value.indexOf('{"organizationalEntities":[]}') != -1) && (stakeholders.value == '' || stakeholders.value.indexOf('{"organizationalEntities":[]}') != -1)) { alert(messages['MSG_ERR_NOTIFICATION_RECIPIENT_NOT_SELECTED']); return false; } //check if the notification checkbox is selected or not var notificationCheckBox = document.getElementById(fragmentName + 'notification'); if(notificationCheckBox.checked==true) { //only if the checkbox is checked, we have to set the notification deadline //validate the date if(hts_validateNotificationDate(fragmentName + 'taskOptions_dueDate', messages)) { //if the date is valid, create the param params.createParamFromElement('dueDate', 'p_' + fragmentName + 'taskOptions_dueDate'); } else { //the date is invalid so return return false; } } //create the update parameters params.createParamFromElement('priority',fragmentName + 'taskOptions_priority'); params.createParamFromElement('stakeholderList',fragmentName + '_stakeHolders_value'); params.createParamFromElement('recipientList',fragmentName + '_potentialOwners_value'); params.createParamFromElement('subject', fragmentName + '_subject_value'); params.createParamFromElement('message_HTML',fragmentName + '_notificationMessageValue'); params.createParamFromElement('message_text', fragmentName + '_notificationMessageTextValue'); params.createParamFromElement('reportLinks', fragmentName + '_linksList_value'); params.createParamFromElement('reportLinksDisplay', fragmentName + '_linksList_display'); var recordReadReceiptCheckbox = document.getElementById(fragmentName + 'recordReadReceipt'); if (recordReadReceiptCheckbox) { params += ("&recordReadReceipt=" + recordReadReceiptCheckbox.checked); } //fire the update var paramStr = params.toString(); fragmentObj_retrieve(fragmentObj, paramStr, null, true); } return params?true:false; } function hts_validateNotificationDate(notificationDate, msgs) { var htsDatePickerUtil = new hts_datePickerUtil(notificationDate); if(htsDatePickerUtil.isDateEmpty() || !htsDatePickerUtil.isDateValid()) { //if the date is empty or the date is not valid alert(msgs['MSG_ERR_NOTIFICATION_DATE_INVALID']); return false; } if(!htsDatePickerUtil.isDateLaterThanOrEqualToCurrentDate()) { alert(msgs['MSG_ERR_NOTIFICATION_DATE_IN_PAST']); return false; } return true; } function trim(s) { return s.replace(/^\s+|\s+$/, ''); } function hts_createGenericTask(fragmentObj, fragmentName, subscriptions) { var iframe = $(fragmentName+'_taskMessageValue_iframe'); var subject_val = $(fragmentName+'_subject_value'); var bodytext = iframe.contentDocument? iframe.contentDocument.body.textContent : iframe.contentWindow.document.body.innerText; $(fragmentName+'_taskMessageTextValue').value = bodytext; var subjectText = trim(subject_val.value); var params = hts_getParams(fragmentName,"createGenericTask"); var messages = hts_getMsgs(fragmentName); if (subjectText.length==0) { alert(messages['MSG_ERR_TASKVIEWER_WARN_GENERICTASK_NO_SUBJECT']); return false; } if (params) { var messages = hts_getMsgs(fragmentName); var assignedTo = document.getElementById(fragmentName + '_potentialOwners_value'); var stakeholders = document.getElementById(fragmentName + '_stakeHolders_value'); var regx = new RegExp("{\"organizationalEntities\":\\[\\]}"); if (regx.test(assignedTo.value) && regx.test(stakeholders.value)) { alert(messages['MSG_ERR_ASSIGNEDTO_OR_STAKEHOLDER_NOT_SELECTED']); return false; } params.createParamFromElement('subject', fragmentName + '_subject_value'); params.createParamFromElement('message_text',fragmentName + '_taskMessageTextValue'); params.createParamFromElement('message_HTML',fragmentName + '_taskMessageValue'); params.createParamFromElement('reportLinks', fragmentName + '_linksList_value'); params.createParamFromElement('reportLinksDisplay', fragmentName + '_linksList_display'); //Attach the subscriptions. params = params + subscriptions; //fire the update var paramStr = params.toString(); fragmentObj_retrieve(fragmentObj, paramStr, null, true); } return params?true:false; } /* * set the message to be set into the task options div that is displayed either when a task has been deselected or a task is loading */ function hts_setMessage(fragmentName,message) { var node = $(fragmentName+"infoDiv_value"); node.innerHTML=message; } /* * Called when a task is saved after editing */ function hts_saveTaskOptions(fragmentObj, fragmentName) { var params = hts_getParams(fragmentName,"updateTask"); if (params) { fragmentObj.raiseEvent('cognos.hts.showWait'); params.createParamFromElement('actualOwner',fragmentName + '_assingnedTo_token'); //fire the update var paramStr = params.toString(); fragmentObj_retrieve(fragmentObj, paramStr, null, true); } return params?true:false; } function hts_getParams(fragmentName, action) { var params = new hts_taskUpdateParams("action="+ action); var dt = new hts_datetime(fragmentName + 'taskOptions_startBy',fragmentName + 'taskOptions_dueDate',hts_getMsgs(fragmentName)); //create the update parameters params.createParamFromElement('hts_status', fragmentName + 'taskOptions_status'); params.createParamFromElement('priority',fragmentName + 'taskOptions_priority'); params.createParamFromElement('stakeholderList',fragmentName + '_stakeHolders_value'); params.createParamFromElement('potentialOwnerList',fragmentName + '_potentialOwners_value'); //check if the pickers have changed from the initial values when the fragment was loaded var fromPickerDirty = !dt.checkDate(true,eval(fragmentName+"dateFrom")); var toPickerDirty = !dt.checkDate(false,eval(fragmentName+"dateTo")); //if the pickers have the current date then no deadlines have been set on the task, check the dirty //flag, the user may have set the current date explicitly var datesValid = hts_validateDeadlines(dt,fromPickerDirty,toPickerDirty); //from deadline has been entered if (fromPickerDirty) { var elementName = 'p_' + fragmentName + 'taskOptions_startBy'; //adjust the time if the start date is todays date if (dt.checkCurrentDate(dt.getDateFromValue())) { var element = document.getElementById(elementName); if (element) { var newValue = element.value.replace("00:00:00.000","23:59:00.000"); element.value = newValue; } } params.createParamFromElement('startBy',elementName); } //to deadline has been entered if (toPickerDirty) { params.createParamFromElement('dueDate', 'p_' + fragmentName + 'taskOptions_dueDate'); } return datesValid?params:datesValid; } function hts_validateDeadlines(dt,fromPickerDirty,toPickerDirty) { var datesValid = true; //from and to deadlines have been entered if (fromPickerDirty && toPickerDirty) { datesValid = dt.validateDates(); } //from deadline has been entered else if (fromPickerDirty) { datesValid = dt.validateFromDate(); } //to deadline has been entered else if (toPickerDirty) { datesValid = dt.validateToDate(); } return datesValid; } function hts_getCurrentDate() { var currentDate = new Date(); var day = currentDate.getDate(); var month = currentDate.getMonth()+1; var year = currentDate.getFullYear(); return year + "-" + month +"-" + day; } function hts_getMsgs(fragmentName) { return eval(fragmentName+"msg_array"); } function hts_getDatePicker(fragmentName,pickerName) { return window['pickerControl' + fragmentName + pickerName]; } function hts_setDatePickers(fragmentName,dateFromStr,dateToStr) { var dt = new hts_datetime(fragmentName + 'taskOptions_startBy',fragmentName + 'taskOptions_dueDate',hts_getMsgs(fragmentName)); if (dateFromStr!=="") { dt.setDateFromValue(dateFromStr); } if (dateToStr!=="") { dt.setDateToValue(dateToStr); } } function hts_clearDatePickers(fragmentName) { var dt = new hts_datetime(fragmentName + 'taskOptions_startBy',fragmentName + 'taskOptions_dueDate',hts_getMsgs(fragmentName)); dt.setDateFromValue(""); dt.setDateToValue(""); } /** This sets a couple of listeners for the click and mousedown events. It finds all buttons that generate a datepicker, and adds a mousdown event. The mousedown will close all open pickers. It adds onclick to the body of the main page. When the body is clicked, all pickers are closed. if adds mousedown listener to the iframe and body of the Dojo editor. This is because in IE the body responds to events and the body covers 100% of the iframe. In firefox the body does not cover the iframe and so we need to cater for clicking on the iframe itself. */ function hts_datePickerListener() { // do it when the DOM is loaded dojo.addOnLoad( function() { // attach on click to id="textDiv" dojo.query('body').onclick( function(evt) { hts_hideDatePickers(); }); dojo.query("[id$='imgPicker']").onmousedown( function(evt) { hts_hideDatePickers(); dojo.query('iframe[id$="_iframe"]').forEach (function(item, idx) { if (item.contentDocument) { var handle = dojo.connect(item.contentWindow, "onmousedown", function(e){ hts_hideDatePickers(); dojo.disconnect(handle); }); } else { var handle = dojo.connect(item.contentWindow.document.body, "onmousedown", function(e) { hts_hideDatePickers(); dojo.disconnect(handle); }); } }); }); }); } function hts_hideDatePickers() { for (var i in window) { //We need to do this to get the picker object if (i.indexOf('pickerControl')!= -1 && i.indexOf('iframe')== -1) { //This will hide it. window[i].gotFocus(); } } } /** * The date pickers when clicked they create an iframe. On IE this Iframe * remains behind when the fragment is refreshed, this causes a problem * where when the picker is made visible again, both iframes become visible * and when hiding only one is hidden. The code below deleted the orphan * iframe if it is there. */ function hts_clearDatePickersIframe(id) { dojo.query("[id*='pickerControl" + id + "iframe']").forEach(dojo.destroy); } function hts_toggler(imgExpand,imgCollapse) { this.imgExpand = imgExpand; this.imgCollapse = imgCollapse; } hts_toggler.prototype = { toggleDynamicSection: function (name) { if(document.getElementById(name).style.display == 'none') { this.showDynamicSection(name); } else { this.hideDynamicSection(name); } }, showDynamicSection: function (name) { var node = document.getElementById(name); if (node) { node.style.display='block'; var imgName = document.getElementById('img' + name); if (imgName) { imgName.src = this.imgCollapse; imgName.setAttribute('alt','Collapse'); imgName.setAttribute('title','Collapse'); } } }, hideDynamicSection: function (name) { var node = document.getElementById(name); if (node) { node.style.display='none'; var imgName = document.getElementById('img' + name); if (imgName) { imgName.src = this.imgExpand; imgName.setAttribute('alt','Expand'); imgName.setAttribute('title','Expand'); } } }, isHidden: function(name) { return document.getElementById(name).style.display=='none'; } } function hts_taskUpdateParams(prefix) { this.params = prefix; } hts_taskUpdateParams.prototype = { createParamFromElement: function (paramName, elementName) { var element = document.getElementById(elementName); if (dijit.byId(elementName)) { //Hack it in. bug: COGCQ00225777 The contents should be html encoded to avoid problems with external html i.e. user typed html. element.value = dijit.byId(elementName).getValue(); } if (element) { this.params+="&"+_F_Strings.urlEncode(paramName)+"="+_F_Strings.urlEncode(element.value); } }, toString: function() { return this.params; }, contains: function(str) { return this.params.indexOf(str)>=0; } } function hts_selectCheckbox(id,frag) { //we have clicked the parent checkbox so select/deselect all state change options if (id==frag+'notification') { var cb = document.getElementById(id); hts_walk(document,frag,cb.checked); } //we have selected a state change option so select the parent checkbox too else { var parentCb = document.getElementById(frag+'notification'); parentCb.checked= hts_checkStateChanges(document,frag); } } function hts_walk(node,frag,subscribe) { for (var i=0; i < node.childNodes.length; i++){ var childNode = node.childNodes[i]; if (childNode.nodeName=='INPUT' && childNode.type=='checkbox' && node.id != frag+'notification' && childNode.id.indexOf(frag+'sub_stateChange')==0) { if (childNode.checked != subscribe) { childNode.checked=subscribe; } } hts_walk(childNode,frag,subscribe); } } function hts_checkStateChanges(node,frag) { var found = true; var checkboxes = node.getElementsByTagName('INPUT'); var cbName = frag+"sub_stateChange"; for (var i=0;i < checkboxes.length;i++) { if (checkboxes[i].type =='checkbox' && checkboxes[i].id.indexOf(cbName) != -1 && checkboxes[i].id != frag+'notification') { found = checkboxes[i].checked; //found a selected state change option so break if (found) { break; } } } return found; } function hts_setCurrentUser(prefix, id, name){ var oItemDisplay = document.getElementById(prefix + "_display"); var oItemValue = document.getElementById(prefix + "_value"); oItemDisplay.value = name; oItemValue.value = id; } function hts_selectUser(paramPrefix) { var sHeaderTitle = "taskpool"; var select_scope = "adminconsole.users"; var display_prop = "defaultName"; //var value_prop = "id"; var value_prop = "searchPath"; var oItemDisplay = document.getElementById(paramPrefix + "_display"); var oItemSearchPath = document.getElementById(paramPrefix + "_searchpath"); var oItemValue = document.getElementById(paramPrefix + "_value"); ccModalCallBack = function(cmd,sResponse) { if (cmd == "ok"){ var xmlDoc = XMLBuilderLoadXMLFromString(xmldecode(sResponse)); var item = xmlDoc.getElementsByTagName("item"); var isItemSet = false; var itemDisplay = ""; var itemValue = ""; var itemSearchPath = ""; for (var i=0; item.length > i; i++) { if (item[i].hasChildNodes()) { var children = item[i].childNodes; for (var j = 0; children.length > j; j++) { if (XMLHelper_GetText(children[j]) == display_prop) { itemDisplay = XMLHelper_GetText(children[1]); isItemSet = true; } if (XMLHelper_GetText(children[j]) == value_prop) { itemValue = XMLHelper_GetText(children[1]); } if (XMLHelper_GetText(children[j]) == 'searchPath') { itemSearchPath = XMLHelper_GetText(children[1]); } } } } } if (isItemSet == true) { hts_setText(oItemDisplay,_F_Strings.htmlEncode(itemDisplay)); hts_setText(oItemValue,itemValue); hts_setText(oItemSearchPath,itemSearchPath); } ui_modal_dialog.close(); } var defaultObject = ''; if (oItemSearchPath.value != '') { defaultObject = '&so.defaultObject='+ oItemSearchPath.value; } ui_modal_dialog.open('?b_action=xts.run&m=portal/select/select.xts&so.select=' + select_scope + defaultObject + '&md.callBack=data&md.callBackMode=&m_name=' + sHeaderTitle, false, true, true); } // removes links function hts_removeLinks(cListObj, divObjId) { cListObj.removeSelected(); hts_setFocusOnLink(divObjId); } // removes All links function hts_removeAllLinks(cListObj) { cListObj.removeAllNodes(); } // adds links to the Clist div function hts_selectLinks(cListObj,parentId, divObjId, linksTabIndex) { ccModalCallBack = function (cmd, entries) { if (cmd == "ok") { var htsLinks = new HTSLinks(cListObj,$(parentId)); for (var i = 0; i < entries.length; i++) { htsLinks.append(entries[i], linksTabIndex); } //update the dom htsLinks.commit(); } ui_modal_dialog.close(); hts_setFocusOnLink(divObjId); }; // open the modal dialog to select one or more links ui_modal_dialog.open('?b_action=xts.run&m=myinbox/add_entries_links.xts&m_name=' + "", false, true, true); } //to set the focus on element within the Div function hts_setFocusOnLink(divObjId) { if (divObjId != null) { dojo.query("div#"+divObjId+ " a").forEach( function(node, index, arr) { node.focus(); } ); } } var counter = 0; function hts_selectRecipients(presentationName,msgs,stakeHoldersPrefix,potOwnersPrefix, dialogType, divObjId) { var stakeHolders = new HTSHumanRole(stakeHoldersPrefix); var potentialOwners = new HTSHumanRole(potOwnersPrefix); if (hts_productMode && hts_productMode.getMode() == hts_productMode.PLANNING) { var psWrapper = new myinbox.PSWrapper(); //Get the securityMode first. psWrapper.getSecurityMode(function(response) { stakeHolders.setLogicalPeopleGroup(response); potentialOwners.setLogicalPeopleGroup(response); var appDialog = myinbox.ListApplicationDialog; var df = appDialog.openDialog(psWrapper); if (df ) { df.addCallback(dojo.hitch(this, function(result){ if (result) { var recipientDialog = email.RecipientDialog; var args = {"applicationId":result,"endPointAddress":psWrapper._getServiceUrl()}; var callBack = recipientDialog.openDialog(args); callBack.addCallback(dojo.hitch(this, function(recipients){ var resultObj = dojo.fromJson(recipients); if (resultObj.length > 0) { for (var i = 0; i < resultObj.length; i++) { var camId = resultObj[i].id?resultObj[i].id:counter++; var name = resultObj[i].name; //always a group never a user for planning var isGroup = 'true'; //get the 'to' and 'cc' flags var to = resultObj[i].to; var cc = resultObj[i].cc; //'to' recipient groups are assigned to potential owners if (to==true) { potentialOwners.append(camId,name,isGroup); } //'cc' recipient groups are assigned to stakeholders if (cc==true) { stakeHolders.append(camId,name,isGroup); } } //build the organisational entities stakeHolders.commit(); potentialOwners.commit(); } hts_setFocusOnLink(divObjId); potentialOwners.focus(); })); } })); } }); } else { ccModalCallBack = function(cmd, g_vEntries) { if (cmd == "ok") { potentialOwners.clear(); potentialOwners.commit(); stakeHolders.clear(); stakeHolders.commit(); if (g_vEntries.length > 0) { for (var i = 0; i < g_vEntries.length; i++) { var camId = g_vEntries[i].searchPath; var name = g_vEntries[i].defaultName; var type = g_vEntries[i].type.split(','); var isGroup = 'false'; if(g_vEntries[i].objectClass == 'role' || g_vEntries[i].objectClass == 'group') { isGroup = 'true'; } for (var j=0;j 0; }; this.cListObj.setEqualityFunc(eqFunc); } } HTSLinks.prototype.append = function (entry, linkTabIndex) { var dispValue = entry.defaultName; var itemValue = entry.key; var objectClass = entry.objectClass; var divElem; //get a perfectly formed and exquisitely crafted tag that contains the correct icon for the object type var img = entry.img; //create a div element //we always have an id but may not have an object class e.g. for agent condition report if (objectClass && objectClass!="") { divElem = dojo.create("div",{ id:itemValue,objectClass:objectClass}); } else { divElem = dojo.create("div",{ id:itemValue}); } //define link tabindex if it exists var tabIndex = 0; if(linkTabIndex != undefined && linkTabIndex != null && linkTabIndex != '') { tabIndex = linkTabIndex; } //cannot set the class using the dojo.create syntax above because IE will barf(reserved keyword) dojo.attr(divElem, "class","reportLink"); //set the content into the div which consists of an image followed by a link dojo.html.set(divElem, ''+img+''+ ''+_F_Strings.htmlEncode(dispValue)+'' ); //add the table element to the clist object this.cListObj.add(divElem, itemValue, dispValue); }; HTSLinks.prototype.commit = function (parentId) { if (this.cListObj.childCount > 0) { //attach to the dom i.e. show it if (parentId!=undefined) { $(parentId).appendChild(this.cListObj.getListElement()); } else { this.parent.appendChild(this.cListObj.getListElement()); } this.cListObj.deSelectAll(); } }; HTSLinks.prototype.getValues = function () { var valueObj = new Object(); var links = new Array(); if (this.cListObj.size() > 0) { var nodesArray = this.cListObj.getAllNodes(); dojo.forEach(nodesArray, function(item) { valueObj.id=dojo.attr(item, "cid"); valueObj.objectClass=dojo.query("table[objectClass]",item).at(0).attr("objectClass").toString(); var valueJson = dojo.toJson(valueObj); links.push(valueJson); }); } return links.join(','); }; HTSLinks.prototype.getDisplayValues = function () { var links = new Array(); if (this.cListObj.size() > 0) { var nodesArray = this.cListObj.getAllNodes(); dojo.forEach(nodesArray, function(item) { links.push(dojo.attr(item, "disp")); }); } return links.join(','); }; /* * HTS Human Role object */ function HTSHumanRole(humanRolePrefix) { this.values = document.getElementById(humanRolePrefix + "_value"); this.display = document.getElementById(humanRolePrefix + "_display"); this.rawValues = {}; this.rawValues.organizationalEntities = new Array(); //Default to CAM,if in Planning we then reset it. this.rawValues.logicalPeopleGroup = new String("CAM"); this.rawDisplayValues = new Array(); } HTSHumanRole.prototype.focus =function() { this.display.focus(); } HTSHumanRole.prototype.append = function (camId,name,bGroup) { this.addRawValue(camId,bGroup); this.addRawDisplayValue(name); }; HTSHumanRole.prototype.parse = function (formatted,raw) { if (raw != undefined) { this.processRaw(raw.users); this.processRaw(raw.groups); } if (formatted != undefined) { this.processFormatted(formatted.users); this.processFormatted(formatted.groups); } }; HTSHumanRole.prototype.processRaw = function (raw) { if (raw != undefined && raw.length === undefined) { if (raw.group != undefined) { this.addRawValue(raw.group,"true"); } else if (raw.user != undefined) { this.addRawValue(raw.user,"false"); } } for (var i=0;raw != undefined && i< raw.length;i++) { if (raw[i].group != undefined) { this.addRawValue(raw[i].group,"true"); } else if (raw[i].user != undefined) { this.addRawValue(raw[i].user,"false"); } } }; HTSHumanRole.prototype.processFormatted = function (formatted) { if (formatted != undefined && formatted.length === undefined) { if (formatted.group != undefined) { this.addRawDisplayValue(formatted.group); } else if (formatted.user != undefined) { this.addRawDisplayValue(formatted.user); } } for (var i=0;formatted != undefined && i 0){ menus = taskInfo.menus; }else{ menus = new Array(); if(taskInfo.menus.menu){ menus.push(taskInfo.menus); } } var idx = 0; var alreadyAdded = false; for (var i=0;i< menus.length;i++) { var status = menus[i].menu.targetStatus; var isReadyReserved = (status == 'READY' || status == 'RESERVED'); if (isReadyReserved) { if (alreadyAdded) { continue; } //do not bother with both reserved and ready. //i.e. same UI status Not Started for both, so only add one alreadyAdded = true; } comboBox.options[idx] = new Option(menuStrings[status], menus[i].menu.operation); //We will get here if reserved or ready is encountered first. The second round will be handled by the //condition above. var isRealStatusReadyReserved = taskInfo.status && (taskInfo.status == 'READY' || taskInfo.status == 'RESERVED'); var setSelected = (isRealStatusReadyReserved && isReadyReserved) || taskInfo.status == status; //We only want to set selectd if task status equals status or if real status is ready or reserved and status is either //ready or reserced as well. if (setSelected) { //shouldnt get in here currentStatus = true; comboBox.options[idx].selected=true; } idx++; } if(currentStatus != true ){ var currentOption = new Option(menuStrings[taskInfo.status], ""); //add the current status as a label comboBox.options[comboBox.options.length] = currentOption; comboBox.options[comboBox.options.length - 1].selected = true; } } function hts_getSelectedComboValue(node,comboName) { var combo = node.ownerDocument.getElementById(comboName); var comboValue = combo.options[combo.selectedIndex].value; return comboValue } function hts_showWait(elementId) { //this function accepts element ids and elements so check here var content = typeof elementId == "string"?$(elementId):elementId; if (content) { var theId = typeof elementId == "string"?elementId:content.id; var innerDivId = theId+"_value"; var innerDivContent = innerDivId + "content"; var progressMarkup= ui_templates.get(ui_templates.contentTemplate, 'CONTENTID', innerDivContent); $(innerDivId).innerHTML=progressMarkup; content.style.display="block"; var cancelAnchor = $(theId + "_cancel"); cancelAnchor.innerHTML = PFM.JS.IDS_JS_BUTTON_CANCEL; var cancelDiv = $(theId + "_cancel_div"); var func = function() { if (dojo.byId(innerDivContent) != null){ cancelDiv.style.display = ""; } }; setTimeout(func, 500); } } function hts_hideButtons(elementId, disable) { var display = ""; var visibility = "visible"; if (disable) { display = "none"; visibility = "hidden"; } dojo.style(elementId,{"display":display,"visibility":visibility}); } function hts_hideWait(elementId) { } function hts_setUsersOrGroups(taskInfo,node) { var displayList=""; var organisationalEntities; //get the list of either groups or users, only can have one or the other not both if (taskInfo.users) { organisationalEntities = taskInfo.users; } else if (taskInfo.groups) { organisationalEntities = taskInfo.groups; } if(!organisationalEntities) return; //if only one then it is not an array if (organisationalEntities.length==undefined) { if (organisationalEntities.group!=undefined) { displayList = organisationalEntities.group; } else { displayList = organisationalEntities.user; } } //build the display string for (var i=0;i= t.cols) b+= Math.floor(text[x].length/t.cols); } b+= text.length; if (b > t.rows) t.rows = b; } } //set the notification deadline, if no deadline is found then reset the deadline label(it may contain a previous unexpired deadline from another notification) function hts_setNotificationDeadline(taskInfo,deadlineLabel) { if (taskInfo.formattedDeadlines) { if(taskInfo.formattedDeadlines.length){ deadlines = taskInfo.formattedDeadlines; }else { deadlines = new Array(); deadlines.push(taskInfo.formattedDeadlines); } for (var i=0; i < deadlines.length;i++) { var deadlineInstance = deadlines[i].deadlineInstance; //notifications have one deadline if (deadlineInstance.type=="START") { hts_setText(deadlineLabel,deadlineInstance.date); } } } //no deadline else { hts_setText(deadlineLabel,""); } } function hts_setText(elem,txt) { //is it a SPAN or DIV? if (elem && (elem.tagName=="SPAN" || elem.tagName=="DIV")) { if (elem.childNodes.length == 0) { var textNode = document.createTextNode(txt); elem.appendChild(textNode) } else { elem.firstChild.nodeValue = txt; } } else if (elem) { elem.value=txt; } } function hts_createButton(labelParam,onClickFunction,placeHolderId) { var params = { label: labelParam, onClick: onClickFunction }; var button = new dijit.form.Button( params,dojo.byId(placeHolderId) ); return button } function hts_utils(fragObj) { this.fragObj = fragObj; } function fragmentObj_retrieve(fragmentObj, sParams, dest, synchronous, excludeDescendantState) { // Add hts_client_caf sParams += "&" + _F_Strings.urlEncode("hts_client_caf") + "="; fragmentObj.retrieve(sParams, dest, synchronous, excludeDescendantState); } hts_utils.prototype = { refreshTaskViewer: function() { //get the tabs object var tabs = this.getTabsHolder('subbook'); //get the current tab object tabObject = tabs.tabs[tabs.activeTabID]; //flag a refresh and do it tabObject.refreshRequired=true; //the tab refresh calls frag.retrieve(). see webapps\p2pd\WEB-INF\fragments\producers\viewers\booklet\view\htabs.xslt tabObject.refresh(); }, /** * This function will obliterate a transient param * that may have over lived its required lifetime. * This is because all transients end up as globals * and they are never removed for the lifetime of a * fragment. Some fragment interactions stages are not * making good use of transient and they are picking * interaction params instead. Using this function * will delete an unwanted transient from all fragments. */ deleteTransient: function(sName,sChannel) { var sKey = sName + "[" + sChannel + "]"; for (var k in fragments) { if (fragments[k].transientGlobal[sKey]) { delete fragments[k].transientGlobal[sKey]; } } }, /* * Find a fragment by id, returns null if the fragment could not be found */ findById: function (fragId) { var root = this.fragObj.getRoot(); return this.find(root,fragId); }, find: function (parent,fragId) { var found = false; var fragment = null; var children = parent.getChildren(); for (var i=0;(i 0) { child = children[0]; } } return child; }, getTabsHolder: function(fragId) { var tabs = null; var firstChild = this.findFirstChildById(fragId); if (firstChild !== null) { var children = firstChild.getChildren(); //get the tabs object, catch any exceptions during the eval try { tabs = eval(firstChild.id+"tabs"); } catch(ex){ //nothing here } } return tabs; }, getCurrentTab: function(fragId) { //we should have been given a booklet which wraps the tabs, so get the first child var tab = null; var tabs = this.getTabsHolder(fragId); var firstChild = this.findFirstChildById(fragId); if (firstChild !== null) { var children = firstChild.getChildren(); var found=false; //all good, we have the tabs objects and the active tab id if (tabs !=null && tabs && tabs.activeTabID) { var activeTabID = tabs.activeTabID; //loop through the tabs, find the active one for (var i=0;i 0) { newYear+=additionalYears; } //determine the new month and year for past dates else { newYear= (newYear + additionalYears)-1; newMonth = 12 + newMonth; } //make the new date theDate.setMonth(newMonth); theDate.setFullYear(newYear); //set to midnight theDate.setHours(0); theDate.setMinutes(0); theDate.setSeconds(0); //console.log('date filter applied : last '+nbrOfMonths+' month(s), calc date: '+theDate+', current: '+new Date()); return theDate.getTime(); }, /* * Set the UI read only state * node - the node contains the contents to be disabled or enabled, note this can be the id or an actual object. * If it is an object then obj.id will be called to try and retrieve a valid id * taskStatus - The UI will be disabled if the taskStatus is completed, error or exited. * If the taskStatus value is boolean true then the ui will be disabled otherwise enabled, default is false * buttonsOnly - (optional) If defined and true then only disable buttons, default is false */ setUIState: function(node,taskStatus,buttonsOnly) { var id=null; var disabled = false; if (buttonsOnly==undefined) { buttonsOnly=false; } //check if object or string, if object then try and get id if (typeof node == "string") { id = node; } //check for null because a null is type 'object' else if (node !== null && typeof node == "object" && node.id) { id = node.id; } //set the disabled state if (id !== null && taskStatus!==undefined) { //check the task status if (taskStatus=='COMPLETED' || taskStatus=='ERROR' || taskStatus=='EXITED' || taskStatus=='OBSOLETE') { disabled=true; } //check for boolean else if (typeof taskStatus == "boolean"){ disabled = taskStatus; } else if (taskStatus=='READY') { disabled = false; } } //if the utils has the fragment defined and the buttonsOnly boolean is true then disable all buttons if (this.fragObj != undefined && buttonsOnly != undefined && buttonsOnly==true) { var fragId = this.fragObj.id; //check for a dojo widget by looking for the 'attr' function which is used to set the disabled attribute //note the use of dijit.byId and not dojo.byId, the former returns a dojo object var items = dojo.query('[id^= \"'+fragId+'button\"]').forEach( function(item, index, array){ var widget = dijit.byId(item.id); if (widget !== undefined) { widget.attr("disabled",disabled); } } ); } else { //the element may be a dojo widget so check here var widget = dijit.byId(id); if (widget !== undefined) { widget.attr("disabled",disabled); } //the element is a the dom object so just set the disabled attribute else { var node = dojo.byId(id); if (node!==undefined) { node.disabled = disabled; //set opacity, IE greys out correctly when the element is disabled but FF does not, so set the opacity here if (disabled) { dojo.style(node,"opacity","0.4"); } else { dojo.style(node,"opacity","1"); } } } } }, debug: function(message) { var debugDivId = 'debugDiv'; var debugDiv = $(debugDivId); var clearFunc = function clear() { var debugDiv = document.getElementById(debugDivId); if (debugDiv) { debugDiv.innerHTML=""; } }; //make the div once if (debugDiv == null) { debugDiv = xCreateElement("div"); debugDiv.id = "debugDiv"; debugDiv.style.width="1200px"; debugDiv.style.height="300px" debugDiv.style.border="1px solid red"; debugDiv.style.overflow="auto"; debugDiv.style.display="block"; document.body.appendChild(debugDiv); var btn = xCreateElement("input"); btn.type="button" btn.value="Clear"; btn.onclick=clearFunc; document.body.appendChild(btn); } if (debugDiv && document.createTextNode) { var messageNode=document.createTextNode(new Date()+"->"+message); var br = document.createElement('br'); debugDiv.appendChild(messageNode); debugDiv.appendChild(br); } } } var dojoEditor = null; function DOJOEditor(id,options) { this.id = id; this.editorHolder = dojo.byId(id); this.options = options; this.editor; this.setup(); } DOJOEditor.prototype.setup = function() { var body = document.getElementsByTagName("body")[0]; var currClass = dojo.attr( body, "class" ) || ""; if (currClass.indexOf ("tundra") == -1){ dojo.attr( body, "class", currClass + " tundra" ); } } DOJOEditor.prototype.create = function () { this.editor = new dijit.Editor(this.options, this.id); this.editorHolder = dojo.byId(this.id); }; DOJOEditor.prototype.destroy = function () { if(this.editor) { this.editor.destroyRecursive(true); this.cleanup(); } }; DOJOEditor.prototype.cleanup = function() { this.editorHolder.innerHTML = ""; this.editorHolder=null; this.editor=null; //Hack #1: Bug in dojo TablePlugin.js where subscribe to 'available' is not been unsubscribed when Plugin is destroyed. delete dojo._topics["available"]; //Hack #2: The plugin handler is global. So need to set it to uninitialised to get re-inited again. //tablePluginHandler.initialized = false; }; DOJOEditor.prototype.isEmpty = function () { var value = this.editor.getValue(); return value == "" || //.test(value); }; DOJOEditor.prototype.getValue = function () { var value = this.editor.getValue(); if (this.isEmpty()) { value = ""; } return value; }; DOJOEditor.prototype.setValue = function (value) { this.editor.setValue(value); }; var hts_tabDisabler = new HTSTabDisabler(); hts_productMode = new HTSProductMode();