insert-form.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /**
  2. * Copyright © Magento, Inc. All rights reserved.
  3. * See COPYING.txt for license details.
  4. */
  5. define([
  6. 'Magento_Ui/js/form/components/insert-form',
  7. 'uiRegistry'
  8. ], function (Insert, registry) {
  9. 'use strict';
  10. return Insert.extend({
  11. defaults: {
  12. modalProvider: '${ $.parentName }',
  13. titlePrefix: '',
  14. imports: {
  15. changeModalTitle: '${ $.modalProvider }:state'
  16. },
  17. listens: {
  18. responseData: 'afterRetry'
  19. },
  20. modules: {
  21. modal: '${ $.modalProvider }',
  22. notificationListing: '${ $.columnsProvider }'
  23. }
  24. },
  25. /** @inheritdoc */
  26. initConfig: function () {
  27. var modalTitleProvider;
  28. this._super();
  29. modalTitleProvider = this.modalTitleProvider.split(':');
  30. this.modalTitleTarget = modalTitleProvider[0];
  31. this.modalTitlePath = modalTitleProvider[1];
  32. },
  33. /**
  34. * Change modal title.
  35. *
  36. * @param {Boolean} change
  37. */
  38. changeModalTitle: function (change) {
  39. if (change) {
  40. registry.get(this.modalTitleTarget, function (target) {
  41. this.modal().setTitle(this.titlePrefix + target.get(this.modalTitlePath));
  42. }.bind(this));
  43. } else {
  44. this.modal().setTitle('');
  45. }
  46. },
  47. /**
  48. * Action after retry operation.
  49. *
  50. * @param {Object} data
  51. */
  52. afterRetry: function (data) {
  53. if (!data.error) {
  54. this.modal().closeModal();
  55. this.notificationListing().reload();
  56. }
  57. }
  58. });
  59. });