From f601a40776843f6196221e74ba502c571a5b1bcd Mon Sep 17 00:00:00 2001
From: historia <[not public]>
Date: Sun, 12 Jul 2026 21:16:58 -0400
Subject: fix(admin): standardize most search dropdowns and radio buttons
---
internal/admin/static/cardeditor.js | 48 +++++++++++++++++++++++++++++++++++--
1 file changed, 46 insertions(+), 2 deletions(-)
(limited to 'internal/admin/static/cardeditor.js')
diff --git a/internal/admin/static/cardeditor.js b/internal/admin/static/cardeditor.js
index 1e8d259..1b2b76b 100644
--- a/internal/admin/static/cardeditor.js
+++ b/internal/admin/static/cardeditor.js
@@ -90,6 +90,46 @@ function ced_addKVRow(cardID, subKey) {
el.appendChild(row);
}
+function ced_buildDynamicSelect(fid, dpAttr, val, dynKey) {
+ var items = (window._dynOpts && window._dynOpts[dynKey]) ? window._dynOpts[dynKey].slice().sort() : [];
+ var s = '';
+ return s;
+}
+
+function ced_renderKVSearch(sec, il, data, getter) {
+ var sectionRoot = data[ced_cardPath(sec)] || data;
+ var map = getter ? getter(sectionRoot, il) : (sectionRoot[il.key] || {});
+ var entity = il.searchEntity || 'items';
+ var h = '
';
+ h += '
' + esc(il.label) + '';
+ h += '
';
+ Object.keys(map).forEach(function(k, idx) {
+ h += '
';
+ h += '
';
+ h += '
';
+ h += '
';
+ });
+ h += '
';
+ h += '
';
+ h += '
';
+ return h;
+}
+
+function ced_addKVSearchRow(cardID, subKey, entity) {
+ var el = document.querySelector('.obj-kv-list[data-sec="' + cardID + '"][data-key="' + subKey + '"]');
+ if (!el) return;
+ var row = document.createElement('div');
+ row.className = 'obj-kv-row';
+ row.innerHTML = '';
+ el.appendChild(row);
+ ced_setupSearchFields(row);
+}
+
// ---- Search autocomplete ----
function ced_setupSearchFields(root) {
@@ -114,7 +154,7 @@ function ced_setupSearchFields(root) {
if (entityType === 'drops' && data.drops) items = data.drops;
if (items.length === 0) {
results.style.display = 'block';
- results.innerHTML = 'No results
';
+ results.innerHTML = 'No results
';
return;
}
results.style.display = 'block';
@@ -315,6 +355,10 @@ function ced_renderField(sec, f, data, idx, subPath, optStyle, cardPathFn, field
return wrap('obj-field', '' + esc(label) + '');
}
if (type === 'select') {
+ if (hint && hint.indexOf('dyn:') === 0) {
+ var inner = '' + esc(label) + '' + ced_buildDynamicSelect(fid, dpAttr, val, hint.substring(4));
+ return wrap('obj-field', inner);
+ }
var opts = hint ? hint.split('|') : [];
var inner = '' + esc(label) + '