price-handler.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'Magento_Ui/js/form/element/abstract'
  7. ], function (Element) {
  8. 'use strict';
  9. return Element.extend({
  10. defaults: {
  11. linksPurchasedSeparately: '0',
  12. useDefaultPrice: false,
  13. listens: {
  14. linksPurchasedSeparately: 'changeDisabledStatus',
  15. useDefaultPrice: 'changeDisabledStatus'
  16. }
  17. },
  18. /**
  19. * Invokes initialize method of parent class,
  20. * contains initialization logic
  21. */
  22. initialize: function () {
  23. this._super();
  24. this.changeDisabledStatus();
  25. return this;
  26. },
  27. /**
  28. * Disable/enable price field
  29. */
  30. changeDisabledStatus: function () {
  31. if (this.linksPurchasedSeparately === '1') {
  32. if (this.useDefaultPrice) {
  33. this.disabled(true);
  34. } else {
  35. this.disabled(false);
  36. }
  37. } else {
  38. this.disabled(true);
  39. }
  40. }
  41. });
  42. });