From 2c955cebb5f1e01fbdb866b50d296fe9fbd852b8 Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 06 Jan 2026 20:40:03 +0000
Subject: [PATCH] =TaxonomySelector.js and creator refactor complete

---
 inc/ui/CRUDSkeleton.php |   39 ++++++++++++++++++++++++++-------------
 1 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/inc/ui/CRUDSkeleton.php b/inc/ui/CRUDSkeleton.php
index 10b30cb..1268132 100644
--- a/inc/ui/CRUDSkeleton.php
+++ b/inc/ui/CRUDSkeleton.php
@@ -36,7 +36,7 @@
 	protected string $dataType = '';
 	protected string $singular = '';
 	protected string $plural = '';
-	protected string $icon = 'triangle';
+	protected string $icon;
 
 	// Capabilities
 	protected array $caps = [];
@@ -134,6 +134,7 @@
 	protected array $additionalClasses = [];
 
 	public function __construct() {
+		$this->icon = jvbDefaultIcon();
 		$this->user = wp_get_current_user();
 		$this->user_id = $this->user->ID;
 	}
@@ -229,6 +230,20 @@
 		return $this;
 	}
 
+	protected function taxConfig(string $taxonomy, string $label = ''):array
+	{
+		$isVerified = jvbUserIsVerified();
+		$label = ($label === '') ? JVB_TAXONOMY[$taxonomy]['plural'] : $label;
+		return [
+			'type'		=> 'taxonomy',
+			'label'		=> $label,
+			'taxonomy'	=> $taxonomy,
+			'createNew' => $isVerified,
+			'multiple'	=> true,
+			'mode'		=> 'append',
+		];
+	}
+
 	public function addSearch():self
 	{
 		$this->hasSearch = true;
@@ -1037,7 +1052,6 @@
 			$temp = array_filter($this->fields, function ($field) {
 				return in_array($field, $this->timelineUniqueFields);
 			}, ARRAY_FILTER_USE_KEY);
-			jvbDump($temp);
 			$form = new MetaForm();
 			echo '<template class="timelineItem">';
 			$form->renderImagePreview(null,['fields' => $temp]);
@@ -1585,7 +1599,6 @@
 					$temp = array_filter($fields, function ($field) {
 						return in_array($field, $this->timelineUniqueFields);
 					}, ARRAY_FILTER_USE_KEY);
-
 					$config = [
 						'type'		=> 'gallery',
 						'subtype'	=> 'timeline',
@@ -1596,6 +1609,9 @@
 					$content = '';
 					foreach ($fields as $slug=> $field) {
 						if (in_array($slug, $this->timelineSharedFields)) {
+							if (in_array($field['type'], ['taxonomy', 'selector'])) {
+								$field = array_merge($field, $this->taxConfig($field['taxonomy'], $field['label']));
+							}
 							$content .= $this->form->render($slug, null, $field, false, true);
 						}
 					}
@@ -1611,6 +1627,9 @@
 						$section = (array_key_exists('section', $config)) ? $config['section'] : 'basic';
 						$tabs[$section]['content'] .= $this->meta->render('form', $n, $config, false, true);
 					} else {
+						if (in_array($config['type'], ['taxonomy', 'selector'])) {
+							$config = array_merge($config, $this->taxConfig($config['taxonomy'], $config['label']));
+						}
 						$this->meta->render('form', $n, $config);
 					}
 				}
@@ -1656,17 +1675,11 @@
 					<div class="taxonomies">
 						<?php
 						foreach ($this->taxonomies as $taxonomy => $config) {
-							$this->meta->render(
-								'form',
+							$this->form->renderSelectorField(
 								'bulk-edit-'.$taxonomy,
-								[
-									'type'		=> 'taxonomy',
-									'label'		=> $config['label'],
-									'taxonomy'	=> $taxonomy,
-									'createNew'	=> jvbUserIsVerified(),
-									'multiple'	=> true,
-									'mode'		=> 'append'
-								]
+								'',
+								$this->taxConfig($taxonomy, $config['label']),
+								'taxonomy'
 							);
 						}
 						?>

--
Gitblit v1.10.0