regions-tax-select.js 886 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'Magento_Ui/js/form/element/select'
  7. ], function (Select) {
  8. 'use strict';
  9. return Select.extend({
  10. defaults: {
  11. filterBy: {
  12. field: 'country',
  13. target: '${ $.parentName }.country:value'
  14. }
  15. },
  16. /** @inheritdoc */
  17. filter: function () {
  18. this._super();
  19. this.disableSelect();
  20. },
  21. /**
  22. * Disables select if there's no regions/states
  23. *
  24. * @returns {*} instance - Chainable
  25. */
  26. disableSelect: function () {
  27. var empty = !this.options().length;
  28. this.disabled(empty);
  29. if (empty) {
  30. this.error('');
  31. }
  32. return this;
  33. }
  34. });
  35. });