//register ps dojo library to dojo
dojo.registerModulePath('com', '../../ps/portal/js/com');
if (hts_productMode && hts_productMode.getMode() == hts_productMode.PLANNING) {
dojo.registerModulePath("email", "../../pmpjs/email");
dojo.registerModulePath("common", "../../pmpjs/common");
dojo.registerModulePath("myinbox", "../../pmpjs/myinbox");
dojo.require("myinbox.PSWrapper");
dojo.require("email.RecipientDialog");
dojo.require("myinbox.ListApplicationDialog");
}
dojo.require("dijit.Editor");
dojo.require("com.ibm.cognos.ps.dojo.editor.plugins.TablePlugins");
var _THIS_dateFrom="";
var _THIS_dateTo="";
var _THIS_toggler = new hts_toggler();
var _THIS_dojoEditor;
_THIS_.addEventListener("fragment.load", "_THIS_init");
_THIS_.parent.addEventListener("cognos.hts.buildGenericTaskEditor", "_THIS_buildDojoEditor");
var defaultStkHolder ;
//messages used by TablePlugins.js
var IDS_EMAIL_OPTIONS_BACKGRD = '';
var IDS_EMAIL_OPTIONS_BORDER = '';
function _THIS_init() {
//the picker text boxes by default are set to the current date. set them to display nothing.
//this fixes the issue of todays date getting displayed when no deadlines exist
//also set the correct tab index and the correct label to be read by JAWs screen reader
var dueDateEle = $('txtDate'+'_THIS_'+'taskOptions_dueDate');
if (dueDateEle) {
dijit.setWaiState(dueDateEle,'label','');
dueDateEle.value="";
dueDateEle.tabIndex=6;
}
var startByEle = $('txtDate'+'_THIS_'+'taskOptions_startBy');
if (startByEle) {
dijit.setWaiState(startByEle,'label','');
startByEle.value="";
startByEle.tabIndex=5;
}
var uiStyle = new CUIStyle("CList_li", "CList_over", "CList_selected", "", null);
// global cList
cListGenTask = new CList("myCList",false, "CList_ul",uiStyle);
//hts_setCurrentUser('_THIS__stakeHolders', '', '');
defaultStkHolder = '';
var currentUser = new HTSHumanRole("_THIS__stakeHolders");
//We are running in Planning mode so hide the links.
if (hts_productMode && hts_productMode.getMode() == hts_productMode.PLANNING) {
dojo.attr("_THIS_linksContainer","style",{display:"none"});
//And set the proper security mode
var psWrapper = new myinbox.PSWrapper();
//Get the securityMode first.
psWrapper.getSecurityMode(function(response) {
currentUser.setLogicalPeopleGroup(response);
});
}
currentUser.addRawDisplayValue('');
currentUser.addRawValue('','false');
currentUser.commit();
if (!_THIS_dojoEditor) {
_THIS_dojoEditor = new DOJOEditor("_THIS__taskMessageValue",{height: '150px' ,extraPlugins:['|',{name: 'com.ibm.cognos.ps.dojo.editor.plugins.TablePlugins', command: 'insertTableWithValidation', label:''},{name: 'com.ibm.cognos.ps.dojo.editor.plugins.TablePlugins', command: 'modifyTableWithValidation', label:''}]});
} else {
//just incase.
_THIS_dojoEditor.destroy();
}
//This will cater for both notification and generic tasks as well as the task details pages.
hts_datePickerListener();
}
function _THIS_buildDojoEditor() {
_THIS_dojoEditor.create();
setTimeout(function(){var input = dojo.byId('_THIS__potentialOwners_display');input.focus();}, 500);
var iframe = dojo.byId('_THIS__taskMessageValue_iframe');
iframe.tabIndex=8;
if (dojo.isMoz) {
var contentDoc =_THIS_getEditorIFrameDocument();
dojo.connect(contentDoc, 'onkeydown',_THIS_editor_handleTabKeyDown);
}
}
function _THIS_getEditorIFrameDocument() {
var iframe = dojo.byId('_THIS__taskMessageValue_iframe');
var contentDoc =(iframe.contentWindow || iframe.contentDocument);
if (contentDoc.document) {
contentDoc=contentDoc.document;
}
return contentDoc;
}
/* HACK alert!! There is a firefox/dojo bug which means that you cannot tab out of the editor and therefore cannot
* access the ui below the editor using the keyboard. Attach a key listener to the editor iframe
* and capture tab keys. When tab is pressed focus the element with the next tab index.
*/
function _THIS_editor_handleTabKeyDown(e) {
var keyCode = _THIS_getKeyCode(e);
var iframe = dojo.byId('_THIS__taskMessageValue_iframe');
if(keyCode == dojo.keys.TAB && !e.shiftKey && !e.ctrlKey && !e.altKey && iframe){
//iframe.focus(); //does not work
//get the control with the next tabindex
var nextTabIndex = iframe.tabIndex + 1;
var done=false;
//get all pform controls with a tabIndex
dojo.query('#_THIS_pform [tabIndex]').forEach(function(ele){
if (ele.id && ele.tabIndex==nextTabIndex && !done) {
ele.focus();
done=true;
}
});
dojo.stopEvent(e);
}
}
function _THIS_handleDeleteKeyDown(e) {
//delete key
var keynum;
var keychar;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
if(keynum == 46) {
cListGenTask.removeSelected();
}
return true;
}
function _THIS_getKeyCode(e) {
var keynum;
if(window.event) // IE
{
keynum = e.keyCode;
}
else if(e.which) // Netscape/Firefox/Opera
{
keynum = e.which;
}
return keynum;
}
var GLOBAL_SUBSCRIBE = "GLOBAL_SUBSCRIBE";
var GLOBAL_UNSUBSCRIBE = "GLOBAL_UNSUBSCRIBE";
function _THIS_getSubscriptionParams() {
var checkboxes = _THIS_getSubscriptionCheckboxes();
var params = "&events=";
var events = new Object();
for (var i=0;i<checkboxes.length;i++) {
var cb = checkboxes[i];
//we are setting the subscriptions here
if (cb.checked) {
events[cb.value]=GLOBAL_SUBSCRIBE;
}else{
events[cb.value]=GLOBAL_UNSUBSCRIBE;
}
}
params += dojo.toJson(events);
return params;
}
function _THIS_getSubscriptionCheckboxes() {
var node = $('_THIS_taskOptions_advanced');
var subscriptionCheckboxes = new Array();
var checkboxes = new Object();
var checkboxes = node.getElementsByTagName('INPUT');//_F_DOM.selectNodes(node,"//input[@type='checkbox']");
var count=0;
for (var i=0;i<checkboxes.length;i++) {
if (checkboxes[i].type =='checkbox' && checkboxes[i].id.match("^"+'_THIS_sub_')=='_THIS_sub_' ) {
subscriptionCheckboxes[count]=checkboxes[i];
count++;
}
}
return subscriptionCheckboxes;
}
function _THIS_save() {
var links = new HTSLinks(cListGenTask,$('linksDivGen'));
document.getElementById('_THIS__linksList_value').value = links.getValues();
document.getElementById('_THIS__linksList_display').value = links.getDisplayValues();
var subscriptions = _THIS_getSubscriptionParams();
if (hts_createGenericTask(_THIS_,'_THIS_',subscriptions)) {
_THIS_done();
//reload the task list to show new task if need be
var _THIS_utils = new hts_utils(_THIS_);
_THIS_utils.refreshCurrentTab('poolTaskList');
}
}
function _THIS_done() {
_THIS_dojoEditor.destroy();
_THIS_.raiseEvent('cognos.hts.hideAll');
}
function _THIS_cancel() {
// check if user has done some editing and warn before cancel
var editedInfo = (document.getElementById('_THIS__subject_value').value );
editedInfo +=(document.getElementById('_THIS__potentialOwners_value').value );
if(document.getElementById('_THIS__stakeHolders_display').value != defaultStkHolder ){
editedInfo +=(document.getElementById('_THIS__stakeHolders_value').value );
}
editedInfo += _THIS_dojoEditor.getValue();
editedInfo += document.getElementById('txtDate'+'_THIS_'+'taskOptions_startBy').value ;
editedInfo += document.getElementById('txtDate'+'_THIS_'+'taskOptions_dueDate').value ;
var priortyChanged = false;
if( document.getElementById('_THIS_'+'taskOptions_priority').value != 3 ){
priortyChanged = true;
}
var links = new HTSLinks(cListGenTask,$('linksDivNot'));
editedInfo += links.getValues();
var promptYes ;
if(priortyChanged || editedInfo.length>0){
promptYes = confirm( '' );
if(!promptYes){
return false;
}
else{
// Lets manually clean each item on the task page
document.getElementById('_THIS__subject_value').value = '';
document.getElementById('txtDate'+'_THIS_'+'taskOptions_startBy').value = '';
document.getElementById('txtDate'+'_THIS_'+'taskOptions_dueDate').value = '';
document.getElementById('_THIS_'+'taskOptions_priority').value = 3;
hts_removeAllLinks(cListGenTask);
var currentUser = new HTSHumanRole("_THIS__stakeHolders");
currentUser.addRawDisplayValue('');
currentUser.addRawValue('','false');
currentUser.commit();
var potUser = new HTSHumanRole("_THIS__potentialOwners");
potUser.clear();
}
}
_THIS_dojoEditor.destroy();
_THIS_.raiseEvent('cognos.hts.displayPreviousDiv');
_THIS_.raiseEvent('cognos.hts.unlock_list');
}
//declare the error messages
var _THIS_msg_array = new Array();
_THIS_msg_array['MSG_ERR_INCOMPATIBLE_DATES'] = '';
_THIS_msg_array['MSG_ERR_INVALID_END_DATE'] = '';
_THIS_msg_array['MSG_ERR_INVALID_START_DATE'] = '';
_THIS_msg_array['MSG_ERR_INVALID_DATE'] = '';
_THIS_msg_array['MSG_ERR_INVALID_ASSIGNMENT'] = '';
_THIS_msg_array['MSG_ERR_EQUAL_DATES'] = '';
//_THIS_msg_array['MSG_ERR_START_CANNOT_USE_CURRENT_DATE'] = '';
_THIS_msg_array['MSG_ERR_COMPLETE_CANNOT_USE_CURRENT_DATE'] = '';
_THIS_msg_array['MSG_ERR_ASSIGNEDTO_OR_STAKEHOLDER_NOT_SELECTED'] = '';
_THIS_msg_array['MSG_ERR_TASKVIEWER_WARN_GENERICTASK_NO_SUBJECT'] = '';
try {
if (typeof oCV=="undefined") {
oCV=window;
}
} catch(e) {
oCV=window;
}
var G_PM_THIS_ = new C_PromptManager();
oCV.preProcessControlArray=[];
p_sSkinFolder=_F_Config.webContent + "/skins/";
p_sWebContentURI=_F_Config.webContent;
oCV.gbPromptRequestSubmitted=false;
oCV.bCanFinish=true;oCV.bNextPage=true;
oCV.pageNavigationObserverArray=[];
oCV.rangeObserverArray=[];
oCV.multipleObserverArray=[];
oCV.datePickerObserverArray=[];
oCV.hasPromptKeyDown=false;
_THIS_monitor = function (evt) {
if (evt.eventPhase == evt.AT_TARGET) //only want to execute this on downstream events
return;
var assignAndClose = $('_THIS_btnAssignAndClose');
if (assignAndClose){
if (evt.name == "fragment.retrieve.before"){
assignAndClose.disabled = true;
} else {
assignAndClose.disabled = false;
}
}
}
_THIS_.parent.addEventListener("fragment.retrieve.before", "_THIS_monitor", true);
_THIS_.parent.addEventListener("fragment.retrieve.after", "_THIS_monitor", true);