| | |
| | | |
| | | handleFetchError(error) { |
| | | const field = this.currentField(); |
| | | const message = field |
| | | ? `Failed to load ${field.plural}` |
| | | : 'Failed to load data'; |
| | | this.setMessage(field, true, 'Something went wrong.', false); |
| | | |
| | | this.setMessage(field,true, message, false); |
| | | const conf = this.container.open || field?.isFilter ? this.ui : field?.ui; |
| | | const p = conf?.message?.message; |
| | | |
| | | if (p && !p.querySelector('.clear-cache-btn')) { |
| | | const btn = document.createElement('button'); |
| | | btn.className = 'clear-cache-btn'; |
| | | btn.type = 'button'; |
| | | btn.textContent = 'Clear cache and try again'; |
| | | btn.addEventListener('click', async () => { |
| | | btn.remove(); |
| | | this.store.clearCache(); |
| | | if (this.activeField && field) { |
| | | await this.store.setFilters({ |
| | | taxonomy: field.taxonomy, |
| | | page: 1, |
| | | search: '', |
| | | parent: 0 |
| | | }); |
| | | } |
| | | }); |
| | | p.appendChild(btn); |
| | | } |
| | | |
| | | console.error('Store fetch error:', error); |
| | | } |
| | | async batchFetchTaxonomies() { |