| | |
| | | this.updateBulkOptions(); |
| | | |
| | | // Initialize components |
| | | this.store = window.jvbStore.register( |
| | | const store = window.jvbStore.register( |
| | | this.content, |
| | | { |
| | | storeName: this.content, |
| | | keyPath: 'id', |
| | | endpoint: 'content', |
| | | headers: { |
| | |
| | | order: 'desc' |
| | | }, |
| | | TTL: 30 * 60 * 1000, //30 minutes cache |
| | | showLoading: true, |
| | | }); |
| | | this.store = store[this.content]; |
| | | |
| | | this.status = 'all'; |
| | | this.filterTimeout = null; |
| | |
| | | break; |
| | | } |
| | | } |
| | | if (window.targetCheck(e, 'select[data-filter]')) { |
| | | this.handleFilterChange(e); |
| | | } |
| | | } |
| | | handleTableChange(e) { |
| | | const row = e.target.closest('tr[data-id]'); |
| | |
| | | let filter = target.dataset.filter; |
| | | if (filter === 'taxonomies') { |
| | | let taxonomy = target.dataset.taxonomy; |
| | | this.store.setFilter(`tax_${taxonomy}`, filter.value); |
| | | this.store.setFilter(`tax_${taxonomy}`, target.value); |
| | | } else { |
| | | this[target.dataset.filter] = target.value; |
| | | this.store.setFilter(target.dataset.filter, target.value); |
| | |
| | | } |
| | | |
| | | setupFilters() { |
| | | document.querySelectorAll('[data-filter]').forEach(filter => { |
| | | this.settings.addSetting(filter) |
| | | filter.addEventListener('change', (e) => { |
| | | if (this.filterTimeout) { |
| | | clearTimeout(this.filterTimeout); |
| | | } |
| | | this.filterTimeout = setTimeout(() => { |
| | | this.filterHandler(e); |
| | | }, 300); |
| | | }); |
| | | }); |
| | | |
| | | // Search |
| | | const searchInput = document.querySelector('input[type="search"]'); |
| | | if (searchInput) { |