overview
1 year ago
campaign_builder_controller.js
1 year ago
chart_controller.js
2 months ago
chart_interval_controller.js
2 years ago
clipboard_controller.js
1 year ago
copy_report_controller.js
2 years ago
create_report_controller.js
1 year ago
delete_data_controller.js
1 year ago
delete_report_controller.js
2 years ago
easepick_controller.js
2 years ago
examiner_controller.js
2 months ago
examiner_header_controller.js
11 months ago
export_overview_controller.js
9 months ago
export_reports_controller.js
2 years ago
filters_controller.js
6 months ago
group_controller.js
2 years ago
import_reports_controller.js
2 years ago
journey_controller.js
6 months ago
map_controller.js
9 months ago
migration_redirect_controller.js
2 years ago
modal_controller.js
2 years ago
pause_emails_controller.js
6 months ago
pie_chart_controller.js
6 months ago
plugin_group_options_controller.js
1 year ago
pruner_controller.js
5 months ago
quick_stats_controller.js
1 year ago
real_time_controller.js
6 months ago
refresh_overview_controller.js
1 year ago
rename_report_controller.js
2 years ago
report_controller.js
2 months ago
reset_analytics_controller.js
1 year ago
reset_overview_controller.js
1 year ago
save_report_controller.js
2 years ago
select_input_controller.js
2 years ago
set_favorite_report_controller.js
2 years ago
sort_controller.js
2 years ago
sortable_reports_controller.js
2 years ago
table_columns_controller.js
2 years ago
tooltip_controller.js
6 months ago
woocommerce_settings_controller.js
1 year ago
delete_report_controller.js
64 lines
| 1 | import {Controller} from "@hotwired/stimulus" |
| 2 | |
| 3 | export default class extends Controller { |
| 4 | static targets = ['modal', 'modalButton', 'deleteButton'] |
| 5 | |
| 6 | static values = { |
| 7 | id: String |
| 8 | } |
| 9 | |
| 10 | connect() { |
| 11 | document.addEventListener('click', this.maybeClose) |
| 12 | } |
| 13 | |
| 14 | disconnect() { |
| 15 | document.removeEventListener('click', this.maybeClose) |
| 16 | } |
| 17 | |
| 18 | maybeClose = (event) => { |
| 19 | const isOpen = this.modalTarget.classList.contains('show') |
| 20 | const isInComponent = this.element.contains(event.target) |
| 21 | |
| 22 | |
| 23 | if (isOpen && !isInComponent) { |
| 24 | this.closeModal() |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | toggleModal(e) { |
| 29 | e.preventDefault(); |
| 30 | const isOpen = this.modalTarget.classList.contains('show') |
| 31 | isOpen ? this.closeModal() : this.openModal() |
| 32 | } |
| 33 | |
| 34 | openModal() { |
| 35 | this.modalTarget.classList.add('show') |
| 36 | this.modalButtonTarget.classList.add('open') |
| 37 | document.getElementById('iawp-layout').classList.add('modal-open'); |
| 38 | } |
| 39 | |
| 40 | closeModal() { |
| 41 | this.modalTarget.classList.remove('show') |
| 42 | this.modalButtonTarget.classList.remove('open') |
| 43 | document.getElementById('iawp-layout').classList.remove('modal-open'); |
| 44 | } |
| 45 | |
| 46 | delete() { |
| 47 | const data = { |
| 48 | ...iawpActions.delete_report, |
| 49 | id: this.idValue |
| 50 | }; |
| 51 | |
| 52 | this.deleteButtonTarget.setAttribute('disabled', 'disabled') |
| 53 | this.deleteButtonTarget.classList.add('sending') |
| 54 | jQuery.post(ajaxurl, data, (response) => { |
| 55 | this.deleteButtonTarget.classList.remove('sending') |
| 56 | this.deleteButtonTarget.classList.add('sent') |
| 57 | setTimeout(() => { |
| 58 | window.location = response.data.url |
| 59 | }, 1000) |
| 60 | }).fail(() => { |
| 61 | |
| 62 | }) |
| 63 | } |
| 64 | } |