| | |
| | | |
| | | if (this.ui.form) { |
| | | this.ui.form.addEventListener('change', (e) => { |
| | | console.log('Creator form change, prevents default'); |
| | | e.preventDefault(); |
| | | e.stopPropagation(); |
| | | }); |
| | |
| | | * Handle successful term creation |
| | | */ |
| | | async handleSuccessfulCreation(term, data) { |
| | | // Close create form |
| | | this.ui.details.open = false; |
| | | // Add term to store immediately - don't wait for fetch |
| | | const fullTerm = { |
| | | id: term.id, |
| | | name: term.name, |
| | | path: term.path || term.name, |
| | | slug: term.slug || term.name.toLowerCase().replace(/\s+/g, '-'), |
| | | parent: data.parent || 0, |
| | | taxonomy: data.taxonomy, |
| | | count: 0, |
| | | hasChildren: false |
| | | }; |
| | | |
| | | // Clear cache to ensure fresh data |
| | | // Add to store data immediately so addSelected can find it |
| | | this.selector.store.data.set(term.id, fullTerm); |
| | | |
| | | // Close create form |
| | | if (this.ui.details) { |
| | | this.ui.details.open = false; |
| | | } |
| | | |
| | | // Clear cache and refetch in background for accuracy |
| | | this.selector.store.clearCache(); |
| | | await this.selector.store.fetch(); |
| | | // Don't await - let it happen async |
| | | this.selector.store.fetch().catch(err => { |
| | | console.warn('Background fetch after term creation failed:', err); |
| | | }); |
| | | } |
| | | |
| | | /** |