Jake Vanderwerf
2026-02-04 2127b1bdd73ecd2423e443992da4b442f5a3c1a3
assets/js/concise/TaxonomySelector.js
@@ -184,7 +184,7 @@
         },
         favourites: '.favourite-terms',
         field: {
            toggle: 'button.taxonomy-toggle, [data-filter="taxonomy"]',
            toggle: 'button.selector-toggle, [data-filter="taxonomy"]',
            value: 'input[type="hidden"]',
            selected: '.selected-items',
            dropdown: {
@@ -239,6 +239,13 @@
      const field = this.fields.get(fieldId);
      if (!fieldId || !field) return;
      if (this.creator) {
         let button = window.targetCheck(e, this.selectors.create.button);
         if (button) {
            this.maybeCreateTerm(e).then(()=>{});
         }
      }
      const autocomplete = window.targetCheck(e, '.item.autocomplete');
      if (autocomplete) {
@@ -320,14 +327,6 @@
            this.ui.search.input.value = '';
         }
      }
      if (this.creator) {
         let button = window.targetCheck(e, this.selectors.create.button);
         if (button) {
            this.maybeCreateTerm(e).then(()=>{});
         }
      }
   }
   handleChange(e) {
      if (!this.container.contains(e.target) && !e.target.closest('[data-type="selector"], [data-field-type="selector"]')) {
@@ -365,7 +364,7 @@
      }
      let query = e.target.value.trim();
      this.setMessage(true, `Searching for "${query}" in ${field.plural??'items'}`);
      this.setMessage(field,true, `Searching for "${query}" in ${field.plural??'items'}`);
      window.debouncer.schedule(
         `${fieldId}-search`,
         async () => {
@@ -390,7 +389,7 @@
         return;
      }
      this.activeField = fieldId;
      this.setMessage(true, `Loading ${field.plural}...`);
      this.setMessage(field,true, `Loading ${field.plural}...`);
      this.resetFilters({taxonomy: field.taxonomy});
   }
@@ -899,7 +898,7 @@
         if (this.store.filters.page??1 === 1) {
            window.removeChildren(this.ui.terms.list);
         }
         this.setMessage(true, this.store.filters.search === ''
         this.setMessage(field,true, this.store.filters.search === ''
            ? `No matching ${field.plural}.`
            : `No ${field.plural} found.`,
            false);
@@ -909,7 +908,7 @@
         return;
      }
      this.setCreateButton(true);
      this.setCreateButton(field,true);
      if (this.ui.terms.sentinel) {
         if (this.store.lastResponse?.has_more) {
@@ -930,7 +929,7 @@
      ).then(()=>{});
      if (terms.length > 0) {
         this.setMessage(false);
         this.setMessage(field,false);
      }
   }
   createTermElement(term) {
@@ -946,7 +945,7 @@
      window.removeChildren(dropdown);
      if (terms.length === 0) {
         this.setMessage(true, `No ${field.plural} found.`, false);
         this.setMessage(field,true, `No ${field.plural} found.`, false);
      } else {
         window.chunkIt(
            terms,
@@ -954,9 +953,9 @@
            (fragment) => dropdown.append(fragment)
         ).then(()=>{});
         this.setMessage(false);
         this.setMessage(field,false);
      }
      this.setCreateButton(true);
      this.setCreateButton(field,true);
      if (field.ui.dropdown.wrapper) {
         field.ui.dropdown.wrapper.hidden = false;
@@ -1084,7 +1083,6 @@
         handlers[event]?.(data);
      } catch (error) {
         console.error(`Error handling store event "${event}":`, error);
         this.setMessage(true, 'An error occurred loading data', false);
      }
   }
   handleDataLoaded() {
@@ -1103,11 +1101,9 @@
         this.showResults(true);
         return;
      }
      this.setMessage(false);
   }
   showResults(isAutoComplete = false) {
      this.setMessage(false);
      const terms = this.store.getFiltered();
      const filters = this.store.filters;
      const isSearch = filters.search && filters.search.length > 0;
@@ -1120,7 +1116,7 @@
      if (!this.activeField && isAutoComplete) {
         return;
      }
      this.setMessage(this.currentField(), false);
      if (isAutoComplete) {
         this.showAutocompleteTerms();
      } else {
@@ -1140,7 +1136,7 @@
         ? `Failed to load ${field.plural}`
         : 'Failed to load data';
      this.setMessage(true, message, false);
      this.setMessage(field,true, message, false);
      console.error('Store fetch error:', error);
   }
   async batchFetchTaxonomies() {
@@ -1171,14 +1167,14 @@
   /**************************************************
    LOADING
   **************************************************/
   setCreateButton(show = true) {
      const field = this.currentField();
      if (!field || !field.canCreate || !this.creator) return;
   setCreateButton(field, show = true) {
      if (!field.canCreate || !this.creator) return;
      const conf = (this.container.open) ? this.ui : field.ui;
      if (!conf.create?.button || !conf.create?.span) return;
      const createButton = conf.create.button;
      createButton.hidden = !show;
      const buttonSpan = conf.create.span;
      const input = (this.container.open) ? conf.search.input : conf.search;
      if (!input) return;
@@ -1212,8 +1208,8 @@
      }
      if (data.parent !== undefined && data.name) {
         this.setMessage(true, `Creating "${data.name}"...`);
         this.setCreateButton(false);
         this.setMessage(field,true, `Creating "${data.name}"...`);
         this.setCreateButton(field,false);
         if (this.container.open) {
            window.removeChildren(this.ui.terms.list);
@@ -1228,7 +1224,7 @@
         if (term) {
            // Stop any typeLoop animation and show success message WITHOUT typeLoop
            this.setMessage(true, `"${term.name}" created!`, false);
            this.setMessage(field,true, `"${term.name}" created!`, false);
            this.addSelected(term.id, field.id);
            this.updateFieldValue(field.id);
@@ -1242,10 +1238,10 @@
               }
            }
            this.scheduleHideDropdown(field.id, 300);
            this.setMessage(false);
            this.setMessage(field,false);
         } else {
            // Creation failed - hide immediately
            this.setMessage(false);
            this.setMessage(field,false);
            if (!this.container.open && field.ui.dropdown.wrapper) {
               field.ui.dropdown.wrapper.hidden = true;
            }
@@ -1257,10 +1253,7 @@
         }
      }
   }
   setMessage(show = true, message = '', type = true) {
      const field = this.currentField();
      if (!field) return;
   setMessage(field, show = true, message = '', type = true) {
      const conf = this.container.open||field.isFilter ? this.ui : (field.isFilter ? null : field.ui);
      if (!conf?.message?.message) return;