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
table_columns_controller.js
41 lines
| 1 | import {Controller} from "@hotwired/stimulus" |
| 2 | |
| 3 | export default class extends Controller { |
| 4 | static targets = [''] // TODO - Use targets for cells, data table, and data table container |
| 5 | |
| 6 | connect() { |
| 7 | document.addEventListener('iawp:changeColumns', this.updateTableUI) |
| 8 | } |
| 9 | |
| 10 | disconnect() { |
| 11 | document.removeEventListener('iawp:changeColumns', this.updateTableUI) |
| 12 | } |
| 13 | |
| 14 | updateTableUI = (e) => { |
| 15 | const columnIds = e.detail.optionIds |
| 16 | const columnCount = columnIds.length |
| 17 | const cells = document.querySelectorAll('.cell[data-column]') |
| 18 | |
| 19 | // Hide and show the correct cells |
| 20 | cells.forEach((cell) => { |
| 21 | const isPresent = columnIds.includes(cell.dataset.column) |
| 22 | |
| 23 | cell.classList.toggle('hide', !isPresent) |
| 24 | cell.setAttribute('data-test-visibility', isPresent ? 'visible' : 'hidden') |
| 25 | }) |
| 26 | |
| 27 | // Update data-column-count so table knows how many columns are showing |
| 28 | document.getElementById('data-table').setAttribute('data-column-count', columnCount.toString()) |
| 29 | document.getElementById('data-table').style.setProperty('--columns', columnCount.toString()) |
| 30 | document.getElementById('data-table').style.setProperty('--columns-mobile', (columnCount - 1).toString()) |
| 31 | |
| 32 | // Adapt table size |
| 33 | document.getElementById('data-table').style.setProperty('min-width', (columnCount * 170) + 'px'); |
| 34 | if (document.getElementById('data-table').offsetWidth > document.getElementById('data-table-container').offsetWidth) { |
| 35 | document.getElementById('data-table-container').classList.add('horizontal'); |
| 36 | } else { |
| 37 | document.getElementById('data-table-container').classList.remove('horizontal'); |
| 38 | } |
| 39 | } |
| 40 | } |
| 41 |