validatePromptButton.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. define(function () {
  2. "use strict";
  3. function validatePromptValue() {
  4. };
  5. validatePromptValue.prototype.draw = function (oControlHost) {
  6. //this.m_sName = oControlHost.configuration.name || "listBoxPL";
  7. var el = oControlHost.container;
  8. el.innerHTML =
  9. '<style>' +
  10. '.MyPromptButton' +
  11. '{' +
  12. 'background-color: white;' +
  13. 'border: 2px solid #4178BE;' +
  14. 'color: #4178be;' +
  15. 'font-size: 14px;' +
  16. 'height: 32px;' +
  17. 'width: 120px;' +
  18. 'margin-left: 20px;' +
  19. 'cursor: pointer;' +
  20. '} ' +
  21. '.MyPromptButton:hover' +
  22. '{' +
  23. 'background-color: #4178BE;' +
  24. 'color: white;' +
  25. '}' +
  26. '</style>' +
  27. '<button class="MyPromptButton btn1">Submit</button>' +
  28. '<button class="MyPromptButton btn2">Cancel</button>';
  29. el.querySelector(".btn1").onclick = this.MyPromptButtonFinishClick.bind(this, oControlHost);
  30. el.querySelector(".btn2").onclick = oControlHost.cancel.bind(oControlHost);
  31. };
  32. validatePromptValue.prototype.MyPromptButtonFinishClick = function (oControlHost)
  33. {
  34. var productLinePrompt = oControlHost.page.getControlByName("listBoxPL");
  35. var orderTypePrompt = oControlHost.page.getControlByName("listBoxOT");
  36. var plValues = productLinePrompt.getValues();
  37. if (plValues && plValues.length > 0) {
  38. var productLineSelection = plValues[0]['use'];
  39. var otValues = orderTypePrompt.getValues();
  40. if (otValues && otValues.length > 0) {
  41. var orderTypeSelection = otValues[0]['use'];
  42. if (productLineSelection == 'Camping Equipment' && orderTypeSelection == 'Fax') {
  43. // Pop up an error message for the user
  44. alert("You cannot select Camping Equipment and Fax.");
  45. // Clear the prompt selections
  46. productLinePrompt.clearValues();
  47. orderTypePrompt.clearValues();
  48. return ;
  49. }
  50. else {
  51. // Submit the prompt values calling the finish method
  52. oControlHost.finish()
  53. }
  54. }
  55. }
  56. };
  57. return validatePromptValue;
  58. });