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
save_report_controller.js
62 lines
| 1 | import {Controller} from "@hotwired/stimulus" |
| 2 | |
| 3 | export default class extends Controller { |
| 4 | static targets = ['button', 'warning'] |
| 5 | |
| 6 | static values = { |
| 7 | 'id': String |
| 8 | } |
| 9 | |
| 10 | changes = {} |
| 11 | saving = false |
| 12 | |
| 13 | connect() { |
| 14 | document.addEventListener('iawp:changedOption', this.handleChangedOption) |
| 15 | } |
| 16 | |
| 17 | handleChangedOption = ({ detail }) => { |
| 18 | this.changes = { |
| 19 | ...this.changes, |
| 20 | ...detail |
| 21 | } |
| 22 | this.showWarning() |
| 23 | } |
| 24 | |
| 25 | save() { |
| 26 | if(this.saving) { |
| 27 | return; |
| 28 | } |
| 29 | |
| 30 | this.saving = true |
| 31 | |
| 32 | const data = { |
| 33 | ...iawpActions.save_report, |
| 34 | id: this.idValue, |
| 35 | changes: JSON.stringify(this.changes) |
| 36 | }; |
| 37 | |
| 38 | this.buttonTarget.classList.add('sending') |
| 39 | jQuery.post(ajaxurl, data, (response) => { |
| 40 | this.saving = false |
| 41 | this.hideWarning() |
| 42 | this.changes = {} |
| 43 | this.buttonTarget.classList.remove('sending') |
| 44 | this.buttonTarget.classList.add('sent') |
| 45 | |
| 46 | setTimeout(() => { |
| 47 | this.buttonTarget.classList.remove('sent') |
| 48 | }, 1000) |
| 49 | }).fail(() => { |
| 50 | this.saving = false |
| 51 | }) |
| 52 | } |
| 53 | |
| 54 | showWarning() { |
| 55 | this.warningTarget.style.display = 'block' |
| 56 | } |
| 57 | |
| 58 | hideWarning() { |
| 59 | this.warningTarget.style.display = 'none' |
| 60 | } |
| 61 | } |
| 62 |