1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684 |
- /********************************************************************************************************************************
- * 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<type.length;j++) {
- if (type[j] == 'to') {
- potentialOwners.append(camId,name,isGroup);
- }
-
- if (type[j] == 'cc') {
- stakeHolders.append(camId,name,isGroup);
- }
- }
- }
- stakeHolders.commit();
- potentialOwners.commit();
- }
- }
-
- ui_modal_dialog.close();
- hts_setFocusOnLink(divObjId);
- potentialOwners.focus();
- }
-
- var fileName = "add_entries.xts";
- if (dialogType == "humanTask") {
- fileName = "add_entries_task.xts";
- }
-
- // open the modal dialog to select the users or groups
- ui_modal_dialog.open('?b_action=xts.run&m=myinbox/' + fileName + '&m_name=' + presentationName +
- '&selectedStakeHoldersCamIds='+ stakeHolders.getValues() +
- '&selectedPotentialOwnersCamIds='+potentialOwners.getValues(), false, true, true);
- }
- }
- function HTSProductMode(){
- this.PLANNING="planning";
- this.PLATFORM="platform";
- this.mode=this.PLATFORM;
- }
- HTSProductMode.prototype.getMode = function(){
- return this.mode;
- }
- HTSProductMode.prototype.setMode = function(modeIn){
- this.mode = modeIn;
- }
- function HTSTabDisabler() {
- this.fragId=null;
- }
- HTSTabDisabler.prototype.setParentFragment = function(fragment) {
- //only set once by the primary tab
- if (this.fragId == null) {
- this.fragId = fragment + "tabs";
- }
- }
- HTSTabDisabler.prototype.setEnabled = function(enabled) {
-
- //guard clause
- if (this.fragId==null) {
- return;
- }
- try {
- var tabObj = eval(this.fragId);
- for(var i in tabObj.tabs) {
- var tab = tabObj.tabs[i];
- if (tab != undefined) {
- this.replaceEventHandlers(tab,enabled);
- }
- }
- } catch(exception) {
- //nothing here
- }
-
- }
- HTSTabDisabler.prototype.replaceEventHandlers = function(tab,enabled) {
- var elem = $(tab.tabID);
- if (elem != null) {
- if (!enabled) {
- xRemoveEventListener(elem,"click",tab.onclick);
- xRemoveEventListener(elem,"keypress",tab.onkeypress);
- xAddEventListener(elem, "click", _F_Document.associate(elem,this, "onclick"));
- xAddEventListener(elem, "keypress", _F_Document.associate(elem,this, "onkeypress"));
- dojo.style(elem, "opacity", 0.4);
- }
- else {
- xRemoveEventListener(elem, "click",this.onclick);
- xRemoveEventListener(elem, "keypress", this.onkeypress);
- xAddEventListener(elem,"click",_F_Document.associate(elem, tab, "onclick"));
- xAddEventListener(elem,"keypress",_F_Document.associate(elem, tab, "onkeypress"));
- dojo.style(elem, "opacity", 1);
- }
- }
- }
- HTSTabDisabler.prototype.onclick = function(e, tag) {
- //nothing here
- }
- HTSTabDisabler.prototype.onkeypress = function(evt) {
- //nothing here
- }
- function HTSLocker(contentId) {
- this.locked=false;
- this.utils = new hts_utils();
- this.contentId = contentId;
- this.oCallBack=null;
- }
- HTSLocker.prototype.lock = function () {
-
- //guard, already locked, returns true if successfully locked
- if(this.locked == undefined || this.locked) {
- return false;
- }
- else {
- this.locked=true;
- var content = $(this.contentId);
- this.utils.setUIState(content,this.locked);
- if (typeof this.oCallBack == 'function') {
- this.oCallBack(this.locked);
- }
- }
- };
- HTSLocker.prototype.unlock = function () {
-
- //guard, already unlocked, returns true if successfully unlocked
- if(this.locked == undefined || this.locked==false) {
- return false;
- }
- else {
- this.locked=false;
- var content = $(this.contentId);
- this.utils.setUIState(content,this.locked);
- if (typeof this.oCallBack =='function') {
- this.oCallBack(this.locked);
- }
- }
- };
- HTSLocker.prototype.isLocked = function () {
- return this.locked;
- };
- HTSLocker.prototype.setCallBack = function (func) {
- this.oCallBack = func;
- };
- /*
- * HTS Links object
- */
- function HTSLinks(cListObj,parentDiv) {
- this.cListObj = cListObj;
- this.parent=parentDiv;
-
- //set the equality function if we do not already have one, this will ensure
- //that the containsItem() function works properly and that duplicate links are not added
- //when cListObj.add() is called
- if (this.cListObj.getEqualityFunc()===null) {
- var eqFunc = function(clist,itemValue) {
- //get the cid from the table element
- var cid = itemValue.id;
-
- //find the item with the attribute 'cid' which matches the id of the link we are adding
- var results = dojo.query("[cid='"+cid+"']",clist.getListElement());
- return results.length > 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 <img/> 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,
- '<span style="padding-left:3px;padding-right:3px;vertical-align:top;">'+img+'</span>'+
- '<a class="cognos-anchor" id="'+itemValue+'" tabindex="'+tabIndex+'" title="'+entry.linkTitle+'">'+_F_Strings.htmlEncode(dispValue)+'</a>'
- );
- //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<formatted.length;i++) {
- if (formatted[i].group != undefined) {
- this.addRawDisplayValue(formatted[i].group);
- } else if (formatted[i].user != undefined) {
- this.addRawDisplayValue(formatted[i].user);
- }
- }
- };
- HTSHumanRole.prototype.commit = function () {
- this.setValues(dojo.toJson(this.getRawValues()));
- this.setDisplayValues(this.getRawDisplayValues().join(', '));
- };
- // clears the content of pot owner / stake holder does need further commit
- HTSHumanRole.prototype.clear =function() {
- this.rawValues = {};
- this.rawDisplayValues = new Array();
- this.rawValues.organizationalEntities = new Array();
- // effective blank values
- this.setValues('');
- this.setDisplayValues('');
-
- };
- HTSHumanRole.prototype.getValues = function () {
- var values = this.values.value;
- //backward compatibility - convert to comma separated list.
- if(values && values.indexOf('organizationalEntities') != -1){
- var valuesObj = dojo.fromJson(values);
- var valuesArr = new Array();
- dojo.forEach(valuesObj.organizationalEntities, function(value) {
- valuesArr.push(value.token);
- });
- values = valuesArr.join(',');
- }
- return values;
- };
- HTSHumanRole.prototype.getDisplayValues = function () {
- return this.displays.value;
- };
- HTSHumanRole.prototype.getRawValues = function () {
- return this.rawValues
- };
- HTSHumanRole.prototype.getRawDisplayValues = function () {
- return this.rawDisplayValues
- };
- HTSHumanRole.prototype.setValues = function (sValues) {
- hts_setText(this.values, sValues);
- };
- HTSHumanRole.prototype.setDisplayValues = function (sValues) {
- hts_setText(this.display, sValues);
- };
- HTSHumanRole.prototype.setRawValues = function (sRawValues) {
- this.rawValues = sRawValues;
- };
- HTSHumanRole.prototype.addRawValue = function (sRawValue,bGroup) {
- var obj = {};
- obj.token = sRawValue.toString();
- obj.isGroup = bGroup === "true" || bGroup === "false" ?bGroup:"false";
- this.rawValues.organizationalEntities.push(obj);
- };
- HTSHumanRole.prototype.setRawDisplayValues = function (sRawDisplayValues) {
- this.rawDisplayValues = sRawDisplayValues;
- };
- HTSHumanRole.prototype.addRawDisplayValue = function (sRawDisplayValue) {
- this.rawDisplayValues.push(sRawDisplayValue);
- };
- HTSHumanRole.prototype.setLogicalPeopleGroup = function (sLogicalPeopleGroup) {
- this.rawValues.logicalPeopleGroup = sLogicalPeopleGroup;
- };
- function hts_selectComboItem(comboBox,selectedValue) {
- for (var i=0;i<comboBox.options.length;i++) {
- if (comboBox.options[i].value==selectedValue) {
- comboBox.options[i].selected=true;
- }
- }
- }
- function hts_getButtonsInfo(taskInfo) {
- var infoButtons = null;
- if(taskInfo.capabilities) {
- infoButtons = taskInfo.capabilities;
- }
- return infoButtons;
- }
- function hts_populateStatusComboItem(comboBox,taskInfo, menuStrings){
- var currentStatus = false;
- comboBox.options.length = 0;
- var menus;
- if(taskInfo.menus && taskInfo.menus.length > 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<organisationalEntities.length;i++) {
- var organisationalEntity = organisationalEntities[i];
- if (organisationalEntity.group) {
- displayList += organisationalEntity.group;
- }
- else if (organisationalEntity.user) {
- displayList += organisationalEntity.user;
- }
- if ((i+1)<organisationalEntities.length) {
- displayList+=",";
- }
- }
- hts_setText(node,displayList);
- }
- // returns the KeyCode for any browser
- function _hts_getKeyCode(e) {
- var evtobj = window.event? event : e;
- var charCode = (evtobj.keyCode) ? evtobj.keyCode : evtobj.which
- return charCode;
- }
- //dynamically resize the text area.
- function hts_resizeTextArea(t) {
- text = t.value.split('\n');
- if (text == "") {
- rows_length = 1;
- t.rows = rows_length;
- }
- else {
- b=1;
- for (x=0;x < text.length; x++) {
- if (text[x].length >= 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<children.length && !found);i++) {
- var child = children[i];
- var parentId = child.parent.id;
- var childId = child.id.replace(parentId,"");
- var found = childId == fragId;
- if (found) {
- fragment = child;
- }
- else {
- fragment = this.find(child,fragId);
- }
- }
- return fragment;
- },
- /*
- * Refresh a fragment with the given id, no action is taken if the fragment could not be found
- */
- refresh: function(fragId) {
- var frag = this.findById(fragId);
- if (frag != null) {
- //frag.raiseEvent("fragment.refresh");
- fragmentObj_retrieve(frag, null, null, false, false);
- }
- },
- findFirstChildById: function(fragId) {
- var child = null;
- var frag = this.findById(fragId);
- if (frag !== null) {
- var children = frag.getChildren();
- if (children.length > 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<children.length && !found;i++) {
- tab = children[i];
- //if the tab fragment id contains the active tab id then flag as found
- if (tab.id.indexOf(activeTabID)!=-1) {
- found = true;
- }
- }
- }
- }
-
- return tab;
- },
- refreshCurrentTab: function(fragId) {
- //we should have been given a booklet which wraps the tabs, so get the first child
- var tab = this.getCurrentTab(fragId);
- //refresh the tab fragment
- if (tab!=null) {
- tab.raiseEvent("fragment.refresh");
- }
- },
- getDays: function(nbrOfDays,future) {
- var currentDate = new Date();
- var millisPerDay = 24*60*60*1000;
- var nbrOfHours = millisPerDay * nbrOfDays;
- var dateMillis = future?(currentDate.getTime() + nbrOfHours):(currentDate.getTime() - nbrOfHours);
- var theDate = new Date(dateMillis);
- //set to midnight
- theDate.setHours(0);
- theDate.setMinutes(0);
- theDate.setSeconds(0);
- //get the milliseconds
- var time = theDate.getTime();
- //console.log('date filter applied : last '+nbrOfDays+' day(s), from '+theDate+' to '+currentDate);
- return time;
- },
- getMonths: function(nbrOfMonths,future) {
- /*
- var currentDate = new Date();
- var daysPerMonth = 365 / 12;
- var millisPerDay = 24*60*60*1000;
- var calculatedDays = nbrOfMonths * daysPerMonth;
- var calculatedDaysMillis = millisPerDay * calculatedDays;
- var pastDateMillis = future?(currentDate.getTime() + calculatedDaysMillis):(currentDate.getTime() - calculatedDaysMillis);
- var pastDate = new Date(pastDateMillis);
- //set to midnight
- pastDate.setHours(0);
- pastDate.setMinutes(0);
- pastDate.setSeconds(0);
- var time = pastDate.getTime();
- //console.log('date filter applied : last '+nbrOfMonths+' month(s), from '+pastDate+' to '+currentDate);
- return time;
- */
- nbrOfMonths = parseInt(nbrOfMonths,10);
- var theDate = new Date();
- var year = theDate.getFullYear();
- var month = theDate.getMonth();
- var day = theDate.getDate();
- var newYear = year;
- var newMonth = future==true?(month + nbrOfMonths):(month - nbrOfMonths);
- //convert to integer
- var additionalYears = parseInt(newMonth/12,10);
- //add the carry over year(s) for a future date
- if (newMonth > 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 == "" || /<br.*_moz_editor_bogus_node.*\/>/.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();
|