pause_emails_controller.js
| 1 | import { Controller } from "@hotwired/stimulus"; |
| 2 | |
| 3 | export default class extends Controller { |
| 4 | connect() {} |
| 5 | |
| 6 | pause() { |
| 7 | this.setStatus(true); |
| 8 | } |
| 9 | |
| 10 | resume() { |
| 11 | this.setStatus(false); |
| 12 | } |
| 13 | |
| 14 | setStatus(paused) { |
| 15 | const data = { |
| 16 | ...iawpActions.pause_email_reports, |
| 17 | paused, |
| 18 | }; |
| 19 | |
| 20 | this.element.disabled = true; |
| 21 | |
| 22 | jQuery |
| 23 | .post(ajaxurl, data, (response) => { |
| 24 | window.location.reload(); |
| 25 | }) |
| 26 | .fail(() => { |
| 27 | window.location.reload(); |
| 28 | }); |
| 29 | } |
| 30 | } |
| 31 |