contact.page.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. parasails.registerPage('contact', {
  2. // ╦╔╗╔╦╔╦╗╦╔═╗╦ ╔═╗╔╦╗╔═╗╔╦╗╔═╗
  3. // ║║║║║ ║ ║╠═╣║ ╚═╗ ║ ╠═╣ ║ ║╣
  4. // ╩╝╚╝╩ ╩ ╩╩ ╩╩═╝ ╚═╝ ╩ ╩ ╩ ╩ ╚═╝
  5. data: {
  6. // Main syncing/loading state for this page.
  7. syncing: false,
  8. // Form data
  9. formData: { /* … */ },
  10. // For tracking client-side validation errors in our form.
  11. // > Has property set to `true` for each invalid property in `formData`.
  12. formErrors: { /* … */ },
  13. // Server error state for the form
  14. cloudError: '',
  15. // Success state when form has been submitted
  16. cloudSuccess: false,
  17. },
  18. // ╦ ╦╔═╗╔═╗╔═╗╦ ╦╔═╗╦ ╔═╗
  19. // ║ ║╠╣ ║╣ ║ ╚╦╝║ ║ ║╣
  20. // ╩═╝╩╚ ╚═╝╚═╝ ╩ ╚═╝╩═╝╚═╝
  21. mounted: function() {
  22. this.$focus('[autofocus]');
  23. },
  24. // ╦╔╗╔╔╦╗╔═╗╦═╗╔═╗╔═╗╔╦╗╦╔═╗╔╗╔╔═╗
  25. // ║║║║ ║ ║╣ ╠╦╝╠═╣║ ║ ║║ ║║║║╚═╗
  26. // ╩╝╚╝ ╩ ╚═╝╩╚═╩ ╩╚═╝ ╩ ╩╚═╝╝╚╝╚═╝
  27. methods: {
  28. handleParsingForm: function() {
  29. // Clear out any pre-existing error messages.
  30. this.formErrors = {};
  31. var argins = this.formData;
  32. // Validate email:
  33. if(!argins.emailAddress) {
  34. this.formErrors.emailAddress = true;
  35. }
  36. // Validate name:
  37. if(!argins.fullName) {
  38. this.formErrors.fullName = true;
  39. }
  40. // Validate topic:
  41. if(!argins.topic) {
  42. this.formErrors.topic = true;
  43. }
  44. // Validate message:
  45. if(!argins.message) {
  46. this.formErrors.message = true;
  47. }
  48. // If there were any issues, they've already now been communicated to the user,
  49. // so simply return undefined. (This signifies that the submission should be
  50. // cancelled.)
  51. if (Object.keys(this.formErrors).length > 0) {
  52. return;
  53. }
  54. return argins;
  55. },
  56. submittedForm: function() {
  57. // Show the success message.
  58. this.cloudSuccess = true;
  59. },
  60. }
  61. });