Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. validatePostalCode() {
  2.  
  3. const debouncedValid = debounce(()=> {
  4. console.log('debounced valid')
  5. const postalCodeField = this.getFieldByRole('POSTAL_CODE');
  6. if ((postalCodeField.blured || this.formWasSubmited)) {
  7.  
  8. if(!this.isPoland(this.newAddress.countryId)) {
  9. postalCodeField.setErrorCanBeShown(true);
  10.  
  11. this.ValidationEndpoints.getPostalCodeValid({
  12. countryId: this.newAddress.countryId,
  13. postalCode: this.newAddress.postalCode
  14. }).then(res => {
  15. postalCodeField.setErrorMessage([]);
  16. postalCodeField.hideTooltip();
  17. }).catch((err) => {
  18. postalCodeField.setErrorMessage([err.error.message]);
  19. // this.$timeout(()=> {
  20. //method execution must waits for hide tooltip event propagation ends
  21. postalCodeField.showTooltip();
  22. // },200);
  23. });
  24. }
  25.  
  26.  
  27. }
  28. }, 1000);
  29.  
  30. debouncedValid();
  31.  
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement