validatePromptButton.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. define( function() {
  2. "use strict";
  3. function validatePromptValue()
  4. {
  5. };
  6. validatePromptValue.prototype.draw = function( oControlHost )
  7. {
  8. //this.m_sName = oControlHost.configuration.name || "listBoxPL";
  9. var el = oControlHost.container;
  10. el.innerHTML =
  11. '<style>' +
  12. '.myButton { margin-right:8px; color:#6793CB; font-size:20px; padding:6px 12px 6px 12px; background-color:white; border:1px solid #6793CB; }' +
  13. '.myButton:hover { background-color:#6793CB; color:white; border:1px solid #6793CB; }' +
  14. '</style>' +
  15. '<button class="myButton btnCancel" type="button">Cancel</button>' +
  16. '<button class="myButton btnFinish" type="button">Finish</button>' ;
  17. el.querySelector( ".btnCancel" ).onclick = oControlHost.cancel.bind( oControlHost );
  18. el.querySelector( ".btnFinish" ).onclick = this.finishButtonClick.bind(this, oControlHost);
  19. };
  20. validatePromptValue.prototype.finishButtonClick = function( oControlHost)
  21. {
  22. var productLinePrompt=oControlHost.page.getControlByName("listBoxPL");
  23. var orderTypePrompt=oControlHost.page.getControlByName("listBoxOT");
  24. var plValues=productLinePrompt.getValues();
  25. if(plValues && plValues.length > 0) {
  26. var productLineSelection = plValues[0]['use'];
  27. var otValues = orderTypePrompt.getValues();
  28. if (otValues && otValues.length > 0) {
  29. var orderTypeSelection = otValues[0]['use'];
  30. if (productLineSelection == 'Camping Equipment' && orderTypeSelection == 'Fax') {
  31. // Pop up an error message for the user
  32. alert("You cannot select Camping Equipment and Fax.");
  33. // Clear the prompt selections
  34. productLinePrompt.clearValues();
  35. orderTypePrompt.clearValues();
  36. return;
  37. }
  38. else{
  39. oControlHost.finish()
  40. }
  41. }
  42. }
  43. };
  44. return validatePromptValue;
  45. });