Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

V-3099 ADD disable submit button for multi tenant (#12713)

brozek7d5441b29b3d
diff --git a/admin/app/javascript/spree/admin/application.js b/admin/app/javascript/spree/admin/application.js
index fa2f956248..0b6387e253 100644
--- a/admin/app/javascript/spree/admin/application.js
+++ b/admin/app/javascript/spree/admin/application.js
@@ -81,6 +81,7 @@ import VariantsFormController from 'spree/admin/controllers/variants_form_contro
import WebhooksSubscriberEventsController from 'spree/admin/controllers/webhook_subscriber_events_controller'
import AddressAutocompleteController from 'spree/core/controllers/address_autocomplete_controller'
import AddressFormController from 'spree/core/controllers/address_form_controller'
+import DisableSubmitButtonController from 'spree/core/controllers/disable_submit_button_controller'
import EnableButtonController from 'spree/core/controllers/enable_button_controller'
application.register('active-storage-upload', ActiveStorageUpload)
@@ -99,6 +100,7 @@ application.register('checkbox-select-all', CheckboxSelectAll)
application.register('clipboard', Clipboard)
application.register('color-palette', ColorPaletteController)
application.register('color-picker', ColorPickerController)
+application.register('disable-submit-button', DisableSubmitButtonController)
application.register('enable-button', EnableButtonController)
application.register('filters', FiltersController)
application.register('font-picker', FontPickerController)
diff --git a/core/app/javascript/spree/core/controllers/disable_submit_button_controller.js b/core/app/javascript/spree/core/controllers/disable_submit_button_controller.js
new file mode 100644
index 0000000000..d0a06af319
--- /dev/null
+++ b/core/app/javascript/spree/core/controllers/disable_submit_button_controller.js
@@ -0,0 +1,19 @@
+import { Controller } from "@hotwired/stimulus";
+
+export default class extends Controller {
+ static targets = ["button"]
+
+ connect() {
+ this.element.addEventListener('submit', this.toggleDisabledButton)
+ }
+
+ disconnect() {
+ this.element.removeEventListener('submit', this.toggleDisabledButton)
+ }
+
+ toggleDisabledButton = () => {
+ if (this.hasButtonTarget) {
+ this.buttonTarget.disabled = !this.buttonTarget.disabled
+ }
+ }
+}