| | |
| | | const termPath = term.path || term.name; |
| | | |
| | | field.selectedTerms.add(parseInt(term.id)); |
| | | |
| | | // Add to store's data map |
| | | this.selector.store.data.set(term.id, { |
| | | id: term.id, |
| | | name: term.name, |
| | |
| | | hasChildren: false, |
| | | slug: term.slug || termName.toLowerCase().replace(/\s+/g, '-') |
| | | }); |
| | | |
| | | this.selector.addTermToDisplay(field.id, term.id, term.name, termPath); |
| | | |
| | | field.input.value = Array.from(field.selectedTerms).join(','); |
| | |
| | | field.autocompleteDropdown.hidden = true; |
| | | if (input) input.value = ''; |
| | | |
| | | // Clear cache AND refresh this taxonomy's data |
| | | this.selector.store.clearCache(); |
| | | // Clear ALL cache for this taxonomy |
| | | // This forces next search to hit the server |
| | | await this.selector.store.clearCache(); |
| | | |
| | | // Trigger a background refresh for this taxonomy |
| | | await this.selector.store.setFilters({ |
| | | taxonomy: field.taxonomy, |
| | | page: 1, |
| | | search: '', |
| | | parent: 0 |
| | | }); |
| | | } else if (response.reason === 'exists' && response.term) { |
| | | const term = response.term; |
| | | field.selectedTerms.add(parseInt(term.id)); |