From d7e7d248cbe41cd7a9ef9c2fb022b6c4831f99a3 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 31 May 2026 15:22:56 +0000
Subject: [PATCH] =jakevan complete
---
assets/js/concise/TaxonomyCreator.js | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/assets/js/concise/TaxonomyCreator.js b/assets/js/concise/TaxonomyCreator.js
index 11281e3..922c3a4 100644
--- a/assets/js/concise/TaxonomyCreator.js
+++ b/assets/js/concise/TaxonomyCreator.js
@@ -55,7 +55,6 @@
if (this.ui.form) {
this.ui.form.addEventListener('change', (e) => {
- console.log('Creator form change, prevents default');
e.preventDefault();
e.stopPropagation();
});
@@ -83,21 +82,22 @@
if (!data.name || data.name.length < 2) return false;
try {
const response = await this.createTerm(data);
-
+ let currentField = this.selector.currentField();
if (!response.success) {
// Term already exists - still add it
if (response.term && response.term.id) {
- this.selector.setMessage(true, `Using existing "${response.term.name}"`);
+ this.selector.setMessage(currentField,true, `Using existing "${response.term.name}"`);
return response.term;
}
// Other failure
- this.selector.setMessage(true, response.message || 'Creation failed', false);
+ this.selector.setMessage(currentField,true, response.message || 'Creation failed', false);
return false;
}
if (response.term?.pending) {
// Term requires approval
this.selector.setMessage(
+ currentField,
true,
`"${data.name}" submitted for approval`,
false
@@ -120,12 +120,32 @@
* 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);
+ });
}
/**
--
Gitblit v1.10.0