supressValidation.js 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  1. /********************************************************************************************************************************
  2. * Licensed Materials - Property of IBM *
  3. * *
  4. * IBM Cognos Products: AGS *
  5. * *
  6. * (C) Copyright IBM Corp. 2005, 2009 *
  7. * *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. *
  9. *********************************************************************************************************************************/
  10. // Handles Suppression Validation
  11. var Filter_ongoing_changed = "Filter_changed";
  12. var Filter_ongoing_unchanged = "Filter_unchanged";
  13. var Filter_new = "Filter_new";
  14. var Filter_stopped = "Filter_deleted";
  15. var Action_topic_filter = "Action_topic_filter";
  16. var Task_level_filter_checkbox = "action_task_filter_checkbox";
  17. var RunCondition = "runCondition";
  18. var topicError = false;
  19. /**
  20. * validate the whole agent, the summary event key is checked and all the actions
  21. * if there are no actions, then the wizard is moved to the end
  22. */
  23. function validateAgent(){
  24. var agent = parent.getAgentDefinition();
  25. var valid = agent.summaryEventKey.size() > 0 || document.pform.Event_Key[0].checked ;
  26. if(!valid){
  27. //You must select at least one item to uniquely identify the event.
  28. window.alert(parent.getConfigFrame().suppEvtKeyWarn_string);
  29. return valid;
  30. }
  31. var items = agent.summaryEventKey.items();
  32. for(var i = 0; valid && i < items.length; i++){
  33. valid = valid & validateEventKeyTopic(items[i]);
  34. }
  35. if(topicError){
  36. topicError = false;
  37. return false;
  38. }
  39. if(valid){ //& agent.getActionCount() == 0){
  40. valid = validateOngoingFilterTopics();
  41. //we can bin out if there are no more actions
  42. // how?
  43. }else{
  44. return false;
  45. }
  46. return valid;
  47. }
  48. /**
  49. * A new topic is added to the current selected actions filter topics
  50. * check if it exists in the sumary event key and ban it if it does
  51. */
  52. function validateActionFilterTopic(newActionFilterTopic){
  53. var inValid = true;
  54. if(document.pform.Event_Key[0].checked){
  55. inValid = false;
  56. }else{
  57. inValid = !parent.getAgentDefinition().summaryEventKey.containsItem(newActionFilterTopic);
  58. }
  59. if(!inValid){
  60. var remove_newItem = window.confirm( parent.getConfigFrame().suppOngFilAddWarn_string.replace('zzxx',newActionFilterTopic) );
  61. if(remove_newItem){
  62. setTabVisible('taskExecutionRulesPane',false);
  63. setTabVisible('setEventKeyPane',true);
  64. }
  65. inValid = remove_newItem;
  66. }
  67. return inValid;
  68. }
  69. /**
  70. * A new topic is added to the summary event key. check that it doesnt exist in any of the ongoing filter topics of any
  71. * of the actions. if it does allow the user to remove that topic from the actions, or allow the addition to become invalid
  72. */
  73. function validateEventKeyTopic(newEventKeyTopic){
  74. var valid = true;
  75. var offending_task;
  76. //check for a containing action, till we get nothing back
  77. if((offending_task = parent.getAgentDefinition().validateSummaryEventKeyTopic(newEventKeyTopic)) != undefined) {
  78. //This query item's value is in the event key of task "taskname"
  79. //OK if you want to remove this query item or Cancel.
  80. // zpzp is the placeholder which gets replaced in the message with the task name
  81. var remove_newItem = window.confirm(parent.getConfigFrame().suppOngEvntKeyWarn_string.replace('zpzp',offending_task).replace('zzxx',newEventKeyTopic));
  82. if(remove_newItem){
  83. parent.getAgentDefinition().removeActionFilterItem(newEventKeyTopic);
  84. removeEventFilterItem(newEventKeyTopic);
  85. changeTaskLevelFilterState();
  86. }else{
  87. // SelectAll uses this info to check if there was any conflict,
  88. topicError = true;
  89. }
  90. valid = false;//remove_newItem;
  91. }
  92. return valid;
  93. }
  94. // Removes Event Filter topic
  95. function removeEventFilterItem(topic){
  96. var mylist = getActionTopicFilterElementProcessor().list ;
  97. for(var i=0; i< mylist.size(); i++){
  98. var node = mylist.getNodeByIndex(i);
  99. if(node.innerText == topic){
  100. mylist.remove(i);
  101. break;
  102. }
  103. }
  104. }
  105. /**
  106. * check the ongoing filter topics for all actions and warn if any are in the summary event key.
  107. * if they are remove them.
  108. */
  109. function validateOngoingFilterTopics(){
  110. //check that the items in the summary
  111. var valid = parent.getAgentDefinition().validateOngoingFilterTopics();
  112. if(!valid){
  113. //This query item cannot be inserted because it is used in the event key.
  114. window.alert(parent.getConfigFrame().suppOngFilAddWarn_string);
  115. parent.getAgentDefinition().removeInvalidFilterTopics();
  116. }
  117. return valid;
  118. }
  119. /**
  120. * make sure that this action has the required minimum, do the warning if necessary
  121. * the action must have at least one filter type and if it has ongoing changed or unchanged then
  122. * topics must have been specified for the filter
  123. */
  124. function validateAgentAction(action){
  125. var valid = true;
  126. var f_new = action.getParams().getParamValue(Filter_new) != undefined;
  127. var f_stopped = action.getParams().getParamValue(Filter_stopped) != undefined;
  128. var f_changed = action.getParams().getParamValue(Filter_ongoing_changed) != undefined;
  129. var f_unchanged = action.getParams().getParamValue(Filter_ongoing_unchanged) != undefined;
  130. var f_none = action.getParams().getParamValue(Filter_no_events) != undefined;
  131. var f_taskLevelFilter = action.getParams().getParamValue(Task_level_filter_checkbox) != undefined;
  132. var f_runCondition = action.runCondition == "runOnFailure";
  133. valid = f_new || f_stopped || f_changed || f_unchanged || f_none || f_runCondition;
  134. if(!valid){
  135. window.alert(parent.getConfigFrame().suppFilWarn_string);
  136. }else{
  137. if(valid & (f_changed || f_unchanged) & ! (f_changed & f_unchanged)){
  138. valid = action.getParams().getParamValue(Action_topic_filter);
  139. if(!valid){
  140. //You must select at least one query item
  141. //window.alert(parent.getConfigFrame().suppOngFiltWarn_string);
  142. window.alert(parent.getConfigFrame().suppNoItemForEventWarn_string);
  143. }
  144. }
  145. if (f_taskLevelFilter) {
  146. valid = action.taskLevelFilter && action.taskLevelFilter.length > 0;
  147. if (!valid) {
  148. window.alert(parent.getConfigFrame().suppTaskLvlFiltWarn_string);
  149. }
  150. }
  151. if (valid && (f_changed ^ f_unchanged) && parent.getAgentDefinition().summaryEventKey.size() == 0) {
  152. valid = false;
  153. alert(parent.getConfigFrame().suppnoEvtKeyWarn_string);
  154. }
  155. }
  156. //valid = valid & validateOngoingFilterTopics();
  157. return valid;
  158. }
  159. /**
  160. * If there are no filter parameters set... then set the defualt values for this agent
  161. */
  162. function addDefaultFilterValues(action){
  163. var f_new = action.getParams().getParamValue(Filter_new) != undefined;
  164. var f_stopped = action.getParams().getParamValue(Filter_stopped) != undefined;
  165. var f_changed = action.getParams().getParamValue(Filter_ongoing_changed) != undefined;
  166. var f_unchanged = action.getParams().getParamValue(Filter_ongoing_unchanged) != undefined;
  167. var f_none = action.getParams().getParamValue(Filter_no_events) != undefined;
  168. var none_set = !f_new & !f_stopped & !f_changed & !f_unchanged & !f_none ;
  169. if(none_set){
  170. //we can safely set the defaults
  171. action.getParams().setParam(Filter_new, 'new');
  172. action.getParams().setParam(Filter_ongoing_changed, 'changed');
  173. action.getParams().setParam(Filter_ongoing_unchanged, 'unchanged');
  174. }
  175. }
  176. function setIndicAllTopicsInTree(){
  177. var dataItemTree = parent.getDataItemsTree();
  178. var elements = parent.getTreeChildNodes(dataItemTree);
  179. for (var i=0;i < elements.length;i++) {
  180. var item = elements[i];
  181. parent.setIndicator(item);
  182. // Fill items in the items area
  183. /*var items = this.list.getAllItems();
  184. for (var i=0;i < items.length;i++) {
  185. var dropValue = items[i].nodeValue;
  186. parent.removeIndicator(dropValue.replace(";",''));
  187. }*/
  188. //var node = document.createTextNode(item);
  189. //this.list.add(node);
  190. }
  191. return true;
  192. }
  193. // ********** Initialisations *************
  194. // moved From suppressionDialog.xts
  195. var eventKeyElementProcessor;
  196. var actionTopicFilterElementProcessor;
  197. function initActionTopicFilter() {
  198. //call the js to display the tasks
  199. loadAgentsToPage();
  200. //register the dz and the delete listener
  201. var id = getSelectedAction() ? getSelectedAction().id : undefined;
  202. var uiStyle = new CUIStyle("CList_li", "CList_over", "CList_selected", "", null);
  203. var cList = new CList("myCList",false, "CList_ul",uiStyle);
  204. var div = document.getElementById('Action_topic_filter');
  205. div.className = "CList_hintText_inactive";
  206. var textNode = document.createTextNode("");
  207. //This will need to be merged with the one in start.xts
  208. var elementProcessor = new ElementProcessor("Action_topic_filter","",false);
  209. setActionTopicFilterElementProcessor(elementProcessor) ;
  210. elementProcessor.defaultNode = textNode;
  211. elementProcessor.list = cList;
  212. elementProcessor.element.appendChild(cList.getListElement());
  213. elementProcessor.element.appendChild(textNode);
  214. elementProcessor.DELIM = ';';
  215. elementProcessor.remove = function() {
  216. if (this.list.isDisabled()) {
  217. return;
  218. }
  219. this.list.removeSelected();
  220. try {this.element.focus();} catch(e) {}
  221. this.element.blur();
  222. updateActionListValues();
  223. }
  224. elementProcessor.doSelectAction = function() {
  225. //Always use getSelectedAction just incase it changes
  226. //the action becuase it is not a valid.
  227. if (onSelectAction()) {
  228. this.list.removeAllNodes();
  229. this.setElementValue(getSelectedAction().getParams().getParamValue('Action_topic_filter'));
  230. cList.deSelectAll();
  231. this.updateList();
  232. }
  233. }
  234. elementProcessor.updateList = function () {
  235. var disable = document.pform.Filter_ongoing_specified_value.selectedIndex == 0;
  236. disable = disable || document.getElementById('event_rules_table').disabled;
  237. disable = disable || !document.pform.Filter_ongoing_group.checked;
  238. this.list.setDisabled(disable);
  239. }
  240. elementProcessor.setElementValue = function (value) {
  241. var canDrop = document.pform.Filter_ongoing_specified_value.selectedIndex != 0;
  242. canDrop = canDrop && !document.getElementById('event_rules_table').disabled;
  243. canDrop = canDrop && document.pform.Filter_ongoing_group.checked;
  244. if (!value || value.localeCompare("") == 0 || !canDrop) {
  245. if (!this.isDefaultMode()) {
  246. this.list.removeAllNodes();
  247. this.setDefaultValue();
  248. }
  249. //This is remove is helping to avoid
  250. //recursive calls. This should be
  251. //looked at and resolved.
  252. return;
  253. }
  254. //No event key so notify.
  255. //Make sure we only pop the message when there is nothing in the liste already and we are trying to add a new item.
  256. //The other case is where an item is already there and Event key is removed.
  257. //&& !document.pform.Event_Key[0].checked : DIALOG_SUPPRESSION_NO_EVENT_KEY_WARNING
  258. if (parent.getAgentDefinition().summaryEventKey.size() == 0 && getSelectedAction().nonDuplication.size() == 0 ) {
  259. alert(parent.getConfigFrame().suppnoEvtKeyWarn_string);
  260. return;
  261. }
  262. var elements = value.split(this.DELIM);
  263. for (var i=0;i < elements.length;i++) {
  264. if (elements[i].localeCompare("") != 0) {
  265. var sItem = elements[i] + this.DELIM;
  266. if (validateActionFilterTopic(sItem)) {
  267. var node = document.createTextNode(sItem);
  268. this.list.add(node);
  269. //If we are in default mode and we have just added
  270. //Remove the default.
  271. if (this.isDefaultMode()) {
  272. this.removeDefaultValue();
  273. }
  274. }
  275. }
  276. }
  277. updateActionListValues();
  278. }
  279. elementProcessor.getElementValue = function () {
  280. var textNodes = this.list.getAllItems();
  281. var result = '';
  282. for (var i=0;i<textNodes.length;i++) {
  283. result = result + textNodes[i].nodeValue;
  284. }
  285. return result;
  286. }
  287. elementProcessor.updateElementValue = function(value) {
  288. if (!value && value == 'undefined') {
  289. return;
  290. }
  291. if (this.isDefaultMode()) {
  292. this.removeDefaultValue();
  293. }
  294. if (this.overwrite) {
  295. this.listObject.removeAllNodes();
  296. this.setElementValue(value);
  297. } else {
  298. this.setElementValue(value);
  299. }
  300. }
  301. elementProcessor.updateStyle = function (useDefault) {
  302. // check to see if we have got hint text
  303. if (this.defaultValue.length > 0 && useDefault) {
  304. this.element.className="CList_hintText_active";
  305. } else {
  306. this.element.className="CList_hintText_inactive";
  307. }
  308. }
  309. elementProcessor.isDefaultMode = function () {
  310. var node = this.element.firstChild;
  311. var result = false;
  312. if (node && node.nodeType == 3) {
  313. result = node.nodeValue.localeCompare(this.defaultValue) == 0;
  314. }
  315. return result;
  316. }
  317. elementProcessor.isEmpty = function () {
  318. return this.getElementValue().localeCompare("") == 0;
  319. }
  320. elementProcessor.setDefaultValue = function () {
  321. //This is just a guard. Some calls do not check
  322. //if we arleady are in default and mode.
  323. if (!this.isDefaultMode()) {
  324. this.element.removeChild(this.list.getListElement());
  325. this.element.appendChild(this.defaultNode);
  326. this.updateStyle(true);
  327. }
  328. }
  329. elementProcessor.removeDefaultValue = function() {
  330. if (this.isDefaultMode()) {
  331. this.element.removeChild(this.defaultNode);
  332. this.element.appendChild(this.list.getListElement());
  333. this.updateStyle(false);
  334. }
  335. }
  336. elementProcessor.setDropLocation = function(event) {
  337. return false;
  338. }
  339. /**
  340. * Drop text is an array of text.
  341. */
  342. elementProcessor.process = function(dropText) {
  343. if (dropText) {
  344. if (this.overwrite) {
  345. if (dropText.length == 1) {
  346. this.list.removeAllNodes();
  347. } else {
  348. alert(parent.singleItemAllowed_string);
  349. return;
  350. }
  351. }
  352. this.setElementValue(dropText.join(this.DELIM));
  353. } else {
  354. return;
  355. }
  356. }
  357. // cool have a built in on load handler
  358. droppy.registerDropZone("Action_topic_filter","","", true, '', "", false, elementProcessor);
  359. cList.setOnDropFunc(actionTopicFilterListOnDrop);
  360. cList.setEqualityFunc(listEqualityCheck);
  361. droppy.setDropZoneValue(getSelectedAction().nonDuplication.items().join(''),'Action_topic_filter');
  362. cList.deSelectAll();
  363. }
  364. //<!-- page specific init and validate functions -->
  365. //<!-- Page calls init upon each load
  366. function initEventKey() {
  367. //disable the pasting into this control
  368. //parent.setPasteEnabled("Summary_event_key",false);
  369. var uiStyle = new CUIStyle("CList_li", "CList_over", "CList_selected", "", null);
  370. var cList = new CList("myCList",false, "CList_ul",uiStyle);
  371. var div = document.getElementById('Summary_event_key');
  372. div.className = "CList_hintText_inactive";
  373. var defaultSpan = document.createElement('P');
  374. var textNode = document.createTextNode(parent.getConfigFrame().diaActionKeyTip_string);
  375. defaultSpan.appendChild(textNode);
  376. defaultSpan.style.border = "0px";
  377. defaultSpan.style.padding = '0px';
  378. defaultSpan.style.margin = '0px';
  379. defaultSpan.style.cursor = 'default';
  380. defaultSpan.ondragenter = function(evt) { event.cancelBubble = true;return false};
  381. defaultSpan.ondragleave = function(evt) { event.cancelBubble = true;return false};
  382. var elementProcessor = new ElementProcessor("Summary_event_key", parent.getConfigFrame().diaActionKeyTip_string, false);
  383. setEventKeyElementProcessor(elementProcessor) ;
  384. elementProcessor.defaultNode = textNode;
  385. elementProcessor.list = cList;
  386. elementProcessor.element.appendChild(cList.getListElement());
  387. elementProcessor.element.appendChild(textNode);
  388. elementProcessor.DELIM = ';';
  389. elementProcessor.remove = function() {
  390. if (this.list.isDisabled()) {
  391. return;
  392. }
  393. var items = this.list.getAllSelectedItems();
  394. for (var i=0;i < items.length;i++) {
  395. var dropValue = items[i].nodeValue;
  396. parent.removeIndicator(dropValue.replace(";",''));
  397. }
  398. this.list.removeSelected();
  399. this.element.focus();
  400. this.element.blur();
  401. //this.indicateAll();
  402. updateEventKeyListValues();
  403. }
  404. elementProcessor.selectAll = function() {
  405. /*if (this.list.isDisabled()) {
  406. return;
  407. }*/
  408. // this.list.removeAllNodes();
  409. this.element.focus();
  410. this.element.blur();
  411. this.indicateAll();
  412. //updateEventKeyListValues();
  413. showEventKeys();
  414. if(topicError){
  415. topicError = false;
  416. document.pform.Event_Key[1].checked = true;
  417. }else{
  418. disableEventKey();
  419. }
  420. }
  421. elementProcessor.indicateNone = function() {
  422. var items = parent.getTreeChildNodes(parent.getDataItemsTree());
  423. for (var i=0;i < items.length;i++) {
  424. // var dropValue = items[i].nodeValue;
  425. parent.removeIndicator('['+items[i].getName()+']');
  426. }
  427. //updateEventKeyListValues();
  428. return true;
  429. }
  430. elementProcessor.indicateAll = function() {
  431. var items = parent.getTreeChildNodes(parent.getDataItemsTree());
  432. for (var i=0;i < items.length;i++) {
  433. // var dropValue = items[i].nodeValue;
  434. parent.setIndicator('['+items[i].getName()+']');
  435. }
  436. }
  437. elementProcessor.indicateSelected = function() {
  438. var items = this.list.getAllSelectedItems();
  439. for (var i=0;i < items.length;i++) {
  440. var nodeValue = items[i].nodeValue;
  441. parent.setIndicator(nodeValue.replace(";",''));
  442. }
  443. }
  444. elementProcessor.setElementValue = function (value) {
  445. if (!value || value.localeCompare("") == 0) {
  446. if (!this.isDefaultMode()) {
  447. this.list.removeAllNodes();
  448. this.setDefaultValue();
  449. }
  450. return;
  451. }
  452. if(!document.pform.Event_Key[1].checked){
  453. getEventKeyElementProcessor().indicateNone();
  454. }
  455. if (this.isDefaultMode()) {
  456. this.removeDefaultValue();
  457. }
  458. var elements = value.split(this.DELIM);
  459. for (var i=0;i < elements.length;i++) {
  460. if (elements[i].localeCompare("") != 0) {
  461. var sItem = elements[i] + this.DELIM;
  462. if (validateEventKeyTopic(sItem)) {
  463. parent.setIndicator(elements[i]);
  464. var node = document.createTextNode(sItem);
  465. this.list.add(node);
  466. }
  467. }
  468. }
  469. updateEventKeyListValues();
  470. }
  471. elementProcessor.getElementValue = function () {
  472. var textNodes = this.list.getAllItems();
  473. var result = '';
  474. for (var i=0;i<textNodes.length;i++) {
  475. result = result + textNodes[i].nodeValue;
  476. }
  477. return result;
  478. }
  479. elementProcessor.updateElementValue = function(value) {
  480. if (!value && value == 'undefined') {
  481. return;
  482. }
  483. if (this.isDefaultMode()) {
  484. this.removeDefaultValue();
  485. }
  486. if (this.overwrite) {
  487. this.listObject.removeAllNodes();
  488. this.setElementValue(value);
  489. } else {
  490. this.setElementValue(value);
  491. }
  492. }
  493. elementProcessor.updateStyle = function (useDefault) {
  494. // check to see if we have got hint text
  495. if (this.defaultValue.length > 0 && useDefault) {
  496. this.element.className="CList_hintText_active";
  497. } else {
  498. this.element.className="CList_hintText_inactive";
  499. }
  500. }
  501. elementProcessor.isDefaultMode = function () {
  502. var node = this.element.firstChild;
  503. var result = false;
  504. if (node && node.nodeType == 3) {
  505. result = node.nodeValue.localeCompare(this.defaultValue) == 0;
  506. }
  507. return result;
  508. }
  509. elementProcessor.isEmpty = function () {
  510. return this.getElementValue().localeCompare("") == 0;
  511. }
  512. elementProcessor.setDefaultValue = function () {
  513. //This is just a guard. Some calls do not check
  514. //if we arleady are in default and mode.
  515. if (!this.isDefaultMode()) {
  516. this.element.removeChild(this.list.getListElement());
  517. this.element.appendChild(this.defaultNode);
  518. this.updateStyle(true);
  519. }
  520. }
  521. elementProcessor.removeDefaultValue = function() {
  522. if (this.isDefaultMode()) {
  523. this.element.removeChild(this.defaultNode);
  524. this.element.appendChild(this.list.getListElement());
  525. this.updateStyle(false);
  526. }
  527. }
  528. elementProcessor.setDropLocation = function(event) {
  529. return false;
  530. }
  531. /**
  532. * Drop text is an array of text.
  533. */
  534. elementProcessor.process = function(dropText) {
  535. if (dropText) {
  536. if (this.overwrite) {
  537. if (dropText.length == 1) {
  538. this.list.removeAllNodes();
  539. } else {
  540. alert(parent.singleItemAllowed_string);
  541. return;
  542. }
  543. }
  544. this.setElementValue(dropText.join(this.DELIM));
  545. } else {
  546. return;
  547. }
  548. }
  549. // cool have a built in on load handler
  550. droppy.registerDropZone("Summary_event_key","","Please enter a topic", true, "SummaryEventKey", "", false, elementProcessor);
  551. cList.setOnDropFunc(eventKeyListOnDrop);
  552. cList.setEqualityFunc(listEqualityCheck);
  553. //This is the default. setting the summary event key using setDropZone will change this default accordingly.
  554. disableEventKey();
  555. //showEventKeys();
  556. //crap
  557. var eventKeys = parent.getAgentDefinition().summaryEventKey.items().join('') ;
  558. // if there is no key been selected it would mean all the keys are event keys
  559. if(eventKeys!=''){
  560. droppy.setDropZoneValue(eventKeys, 'Summary_event_key');
  561. }else{
  562. getEventKeyElementProcessor().indicateAll();
  563. showEventKeys();
  564. }
  565. }
  566. function listEqualityCheck(list,node) {
  567. var result = false;
  568. var items = list.getAllItems();
  569. for (var i=0; items && i < items.length;i++) {
  570. result = result || items[i].nodeValue.localeCompare(node.nodeValue) == 0;
  571. }
  572. return result;
  573. }
  574. function getEventKeyElementProcessor() {
  575. return eventKeyElementProcessor;
  576. }
  577. function getActionTopicFilterElementProcessor() {
  578. return actionTopicFilterElementProcessor;
  579. }
  580. function setEventKeyElementProcessor(elementProcessor) {
  581. eventKeyElementProcessor = elementProcessor;
  582. }
  583. function setActionTopicFilterElementProcessor(elementProcessor) {
  584. actionTopicFilterElementProcessor = elementProcessor;
  585. }
  586. function actionTopicFilterListOnDrop() {
  587. //get the change or unchange value
  588. droppy.handleInsert('Action_topic_filter');
  589. }
  590. function eventKeyListOnDrop() {
  591. droppy.handleInsert('Summary_event_key');
  592. }
  593. function failTaskRadioProcess(flag) {
  594. //document.getElementById("filter_ongoing_div").disabled = flag;
  595. document.getElementById('event_rules_table').disabled=flag;
  596. document.getElementById('id_Action_topic_filter').disabled=flag;
  597. //Default action.
  598. getSelectedAction().runCondition = "runOnSuccess";
  599. if (flag) {
  600. document.pform.Filter_new.checked = false;
  601. document.pform.Filter_ongoing_group.checked = false;
  602. document.pform.Filter_nil.checked = false;
  603. document.pform.Filter_deleted.checked = false;
  604. droppy.setDropZoneValue('','Action_topic_filter');
  605. //Reset everything else.
  606. getSelectedAction().setParams(new parent.Params());
  607. getSelectedAction().taskLevelFilter = "";
  608. getSelectedAction().runCondition = "runOnFailure";
  609. updateTaskLevelFilter("");
  610. } else {
  611. document.pform.Filter_new.checked = true;
  612. document.pform.Filter_ongoing_group.checked = true;
  613. checkTheBox(document.pform.Filter_new);
  614. checkTheBox(document.pform.Filter_ongoing_group);
  615. }
  616. changeTaskLevelFilterState();
  617. if (getActionTopicFilterElementProcessor()) {
  618. //At init this may not have been defined yet.
  619. getActionTopicFilterElementProcessor().updateList();
  620. }
  621. }
  622. function disableEventKey() {
  623. document.getElementById('event_keys_div').disabled = true;
  624. getEventKeyElementProcessor().list.setDisabled(true);
  625. document.pform.Event_Key[0].checked = true;
  626. // droppy.setDropZoneValue('','Summary_event_key');
  627. // need to put all nodes in the keys
  628. }
  629. function showEventKeys(){
  630. var dataItemTree = parent.getDataItemsTree();
  631. var elements = parent.getTreeChildNodes(dataItemTree);
  632. var str='';
  633. for (var i=0;i < elements.length;i++) {
  634. var nodeName = elements[i].getName();
  635. if(nodeName.length>0 && nodeName!='undefined'){
  636. str += '['+elements[i].getName()+'];';
  637. }
  638. }
  639. droppy.setDropZoneValue(str, 'Summary_event_key');
  640. var b = 0;
  641. }
  642. function changeTaskLevelFilterState() {
  643. var checked = document.pform.Filter_new.checked || document.pform.Filter_deleted.checked || document.pform.Filter_ongoing_group.checked;
  644. if (checked) {
  645. enableFilterTask()
  646. } else {
  647. disableFilterTask();
  648. }
  649. }
  650. function updateTaskLevelFilter(text) {
  651. var element = document.getElementById('task_filter_input');
  652. //If the table is disabled then we should not set the task filter unless
  653. //reset value is used
  654. var shouldSet = !document.getElementById('event_rules_table').disabled;
  655. if (element && shouldSet || text == "") {
  656. element.value = text?text:"";
  657. getSelectedAction().taskLevelFilter = text;
  658. document.pform.action_task_filter_checkbox.checked = text && text.length > 0;
  659. }
  660. }
  661. function setActionTopicDropAreaState(flag) {
  662. if (!flag) {
  663. getSelectedAction().nonDuplication.clear();
  664. droppy.setDropZoneValue('','Action_topic_filter');
  665. }
  666. var ongoingChecked = document.pform.Filter_ongoing_group.checked;
  667. var topicAreaFlag = document.pform.Filter_ongoing_specified_value.selectedIndex == 0;
  668. document.getElementById("actionTopicDropArea").disabled = topicAreaFlag || !ongoingChecked;
  669. document.pform.Filter_ongoing_specified_value.disabled = !ongoingChecked;
  670. getActionTopicFilterElementProcessor().updateList();
  671. changeTaskLevelFilterState();
  672. }
  673. function updateActionListValues() {
  674. //Do the nonDuplication
  675. getSelectedAction().nonDuplication.clear();
  676. getSelectedAction().setParam('Action_topic_filter', null);
  677. getSelectedAction().nonDuplication.parseFromString(droppy.getDropZoneValue('Action_topic_filter'));
  678. getSelectedAction().setParam('Action_topic_filter', droppy.getDropZoneValue('Action_topic_filter'));
  679. //var selectedIndex = document.pform.Filter_ongoing_specified_value.selectedIndex;
  680. //selectOngoing(false, selectedIndex == 0, true);
  681. changeTaskLevelFilterState();
  682. }
  683. function updateEventKeyListValues() {
  684. //get the change or unchange value
  685. parent.getAgentDefinition().summaryEventKey.clear();
  686. var eventKey = droppy.getDropZoneValue('Summary_event_key');
  687. parent.getAgentDefinition().summaryEventKey.parseFromString(eventKey);
  688. if (eventKey && eventKey.length > 0 && parent.getTreeChildNodes(parent.getDataItemsTree()).length!=parent.getAgentDefinition().summaryEventKey.size()) {
  689. document.getElementById('event_keys_div').disabled = false;
  690. getEventKeyElementProcessor().list.setDisabled(false);
  691. document.pform.Event_Key[1].checked = true;
  692. } else {
  693. // disableEventKey();
  694. //getEventKeyElementProcessor().indicateAll();
  695. //showEventKeys();
  696. //document.pform.Event_Key[0].checked = true;
  697. }
  698. }
  699. function ongoingClicked(flag) {
  700. if (flag) {
  701. enableOngoing();
  702. } else {
  703. disableOngoing();
  704. }
  705. checkTheBox(document.pform.Filter_ongoing_group);
  706. }
  707. function disableOngoing() {
  708. getSelectedAction().nonDuplication.clear();
  709. droppy.setDropZoneValue('','Action_topic_filter');
  710. document.pform.Filter_ongoing_specified_value.selectedIndex = 0;
  711. document.pform.Filter_ongoing_specified_value.disabled = true;
  712. getSelectedAction().setParam('Filter_changed',null);
  713. getSelectedAction().setParam('Filter_unchanged',null);
  714. getActionTopicFilterElementProcessor().updateList();
  715. disableActionTopics();
  716. }
  717. function enableOngoing() {
  718. document.pform.Filter_ongoing_specified_value.disabled = false;
  719. document.pform.Filter_ongoing_specified_value.selectedIndex = 0;
  720. getActionTopicFilterElementProcessor().updateList();
  721. disableActionTopics();
  722. storeOngoingActionDetails();
  723. }
  724. function disableFilterTask() {
  725. var filterTableSection = document.getElementById('taskLevelFilterSection');
  726. if (filterTableSection) {
  727. //Disable or enable the task level filter input.
  728. filterTableSection.disabled = true;
  729. document.pform.action_task_filter_checkbox.disabled = true;
  730. document.pform.task_filter_input.disabled = true;
  731. updateTaskLevelFilter('');
  732. }
  733. }
  734. function enableFilterTask() {
  735. var filterTableSection = document.getElementById('taskLevelFilterSection');
  736. if (filterTableSection) {
  737. //Disable or enable the task level filter input.
  738. filterTableSection.disabled = false;
  739. document.pform.action_task_filter_checkbox.disabled = false;
  740. document.pform.task_filter_input.disabled = false;
  741. }
  742. }
  743. function processActionTopicState() {
  744. if (document.pform.Filter_ongoing_specified_value.selectedIndex == 0) {
  745. disableActionTopics();
  746. } else {
  747. enableActionTopics()
  748. }
  749. document.pform.Filter_ongoing_group.checked = true;
  750. getActionTopicFilterElementProcessor().updateList();
  751. storeOngoingActionDetails();
  752. }
  753. function disableActionTopics() {
  754. getSelectedAction().nonDuplication.clear();
  755. droppy.setDropZoneValue('','Action_topic_filter');
  756. document.getElementById("actionTopicDropArea").disabled = true;
  757. }
  758. function enableActionTopics() {
  759. document.getElementById("actionTopicDropArea").disabled = false;
  760. }
  761. function validate(){
  762. //updateEventKeyListValues();
  763. var valid = false;
  764. if (getSelectedAction().runCondition == "runOnFailure") {
  765. //It is a failed task to no need to check anything.
  766. valid = true;
  767. } else {
  768. valid = validateAgent();
  769. if(valid){
  770. //validate the currently visible action first
  771. valid = validateAgentAction(getSelectedAction());
  772. //then all other actions
  773. for(var i = 0; i < parent.getAgentDefinition().getActionCount() && valid; i++) {
  774. var action = parent.getAgentDefinition().getActionAt(i);
  775. valid = validateAgentAction(action);
  776. if(!valid) {
  777. onSelectAction(action);
  778. setSelectedActionDisplay(action.name_id);
  779. }
  780. }
  781. if (!valid) {
  782. setTabVisible('setEventKeyPane',false);
  783. setTabVisible('taskExecutionRulesPane',true);
  784. }
  785. } else {
  786. setTabVisible('taskExecutionRulesPane',false);
  787. setTabVisible('setEventKeyPane',true);
  788. }
  789. }
  790. return valid;
  791. }
  792. function onCancel() {
  793. cf.hideDialogFrame();
  794. //var msgFrame = cf.getMessageIFrame();
  795. //if (msgFrame != null) {
  796. //var frameElement = cf.agsFormUtils.getElementByIdOrName(msgFrame.name);
  797. //frameElement.style.display = '';
  798. //}
  799. }
  800. function setTabVisible(id,isVisible)
  801. {
  802. if (null != document.getElementById(id)) {
  803. if (isVisible) {
  804. if (cf.browserCheck.isIE5Up()) {
  805. document.getElementById(id).style.display="block";
  806. } else {
  807. document.getElementById(id).style.display="table";
  808. }
  809. }
  810. else {
  811. document.getElementById(id).style.display="none";
  812. }
  813. } else {
  814. alert('Null...');
  815. }
  816. }