contentTask.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Licensed Materials - Property of IBM
  2. //
  3. // IBM Cognos Products: ps
  4. //
  5. // (C) Copyright IBM Corp. 2010, 2011
  6. //
  7. // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  8. // Copyright (C) 2008 Cognos Incorporated. All rights reserved.
  9. // Cognos and the Cognos logo are trademarks of Cognos Incorporated.
  10. dojo.provide("ps.contentTask");
  11. dojo.declare("ps.contentTask",null, {
  12. validateConsistencyOptions: function() {
  13. var isValid = true;
  14. if (!this._isValidForm()) {
  15. isValid = false;
  16. } else if (this._isSelectExternalNamespaces()) {
  17. isValid = false;
  18. // At least one namespace checkbox must be checked to be valid
  19. var namespaceNodes = dojo.query('input[name^="m_namespace_"]');
  20. for (i=0; i < namespaceNodes.length;i++){
  21. if (namespaceNodes[i].checked) {
  22. isValid = true;
  23. }
  24. }
  25. }
  26. return isValid;
  27. },
  28. _isValidForm: function() {
  29. var hiddenInputNodes = dojo.query('input[name="cto_consistency_check"][type="hidden"]');
  30. var formIsValid = hiddenInputNodes.length <= 1;
  31. return formIsValid;
  32. },
  33. _isSelectExternalNamespaces: function() {
  34. var result = this._isExternalRef()
  35. && (this._isRadioButtonSelected("cto_externalnamespace","select"));
  36. return result;
  37. },
  38. _isExternalRef: function() {
  39. var result = (this._isRadioButtonSelected("cto_consistency_check","externalRef") || this._hiddenInputExists("cto_consistency_check","externalRef"));
  40. return result;
  41. },
  42. _isRadioButtonSelected: function(radioGroupName, selectedValue) {
  43. var radioGroupNodes = dojo.query('input[name="' + radioGroupName + '"][type="radio"]');
  44. var isSelected = false;
  45. if (radioGroupNodes) {
  46. if (radioGroupNodes.length > 1) {
  47. for (i=0; i < radioGroupNodes.length; i++) {
  48. if (radioGroupNodes[i].value == selectedValue) {
  49. isSelected = radioGroupNodes[i].checked;
  50. }
  51. }
  52. }
  53. }
  54. return isSelected;
  55. },
  56. _hiddenInputExists: function(radioGroupName, selectedValue) {
  57. var radioGroupNodes = dojo.query('input[name="' + radioGroupName + '"][type="hidden"]');
  58. var exists = false;
  59. if (radioGroupNodes) {
  60. if (radioGroupNodes.length == 1) {
  61. if (radioGroupNodes[0].value == selectedValue) {
  62. exists = true;
  63. }
  64. }
  65. }
  66. return exists;
  67. }
  68. });