From 9b54188970c51070d86f4c87e909ea7836c86f07 Mon Sep 17 00:00:00 2001
From: historia <[not public]>
Date: Sun, 5 Jul 2026 16:42:01 -0400
Subject: fix: restructure steal yaml, update admin web gui
---
internal/admin/static/cardeditor.js | 78 +++++++++++----
internal/admin/static/dropeditor.js | 1 +
internal/admin/static/hazardeditor.js | 1 +
internal/admin/static/itemeditor.js | 54 ++++++-----
internal/admin/static/mobeditor.js | 15 +--
internal/admin/static/moduleeditor.js | 1 +
internal/admin/static/objecteditor.js | 177 ++++++++++++++++++++++++++--------
internal/admin/static/techeditor.js | 1 +
8 files changed, 241 insertions(+), 87 deletions(-)
(limited to 'internal/admin')
diff --git a/internal/admin/static/cardeditor.js b/internal/admin/static/cardeditor.js
index f2316e1..8ff5eaf 100644
--- a/internal/admin/static/cardeditor.js
+++ b/internal/admin/static/cardeditor.js
@@ -175,7 +175,7 @@ function ced_selectSearchResult(el) {
function ced_persistSearchToData(input, value) {
var ed = window._editorData;
- var dataPath = input.getAttribute('data-data-path');
+ var dataPath = input.getAttribute('data-field-path');
if (!ed || !dataPath) return;
var m = dataPath.match(/^(.+)\[(\d+)\]\.(.+)$/);
if (m) {
@@ -195,6 +195,48 @@ function ced_persistSearchToData(input, value) {
}
}
+function ced_setPathInData(ed, dataPath, value) {
+ if (!ed || !dataPath) return;
+ var m = dataPath.match(/^(.+)\[(\d+)\]\.(.+)$/);
+ if (m) {
+ if (!ed[m[1]]) ed[m[1]] = [];
+ if (!ed[m[1]][m[2]]) ed[m[1]][m[2]] = {};
+ ed[m[1]][m[2]][m[3]] = value;
+ } else {
+ var m2 = dataPath.match(/^(.+)\.(.+)$/);
+ if (m2) {
+ if (!ed[m2[1]]) ed[m2[1]] = {};
+ ed[m2[1]][m2[2]] = value;
+ } else {
+ ed[dataPath] = value;
+ }
+ }
+}
+
+function ced_syncDOMToData(ed) {
+ if (!ed) return;
+ var inputs = document.querySelectorAll('[data-field-path]');
+ for (var i = 0; i < inputs.length; i++) {
+ var el = inputs[i];
+ var dataPath = el.getAttribute('data-field-path');
+ if (!dataPath) continue;
+ var val;
+ if (el.tagName === 'TEXTAREA') {
+ val = el.value;
+ } else if (el.type === 'checkbox') {
+ val = el.checked;
+ } else if (el.type === 'number') {
+ var raw = el.value.trim();
+ val = raw === '' ? '' : (parseFloat(raw) || 0);
+ } else if (el.tagName === 'SELECT') {
+ val = el.value;
+ } else {
+ val = el.value;
+ }
+ ced_setPathInData(ed, dataPath, val);
+ }
+}
+
function ced_resolveDataPath(obj, path) {
return path.split('.').reduce(function(o, k) {
if (o === undefined || o === null) return undefined;
@@ -236,6 +278,17 @@ function ced_renderField(sec, f, data, idx, subPath, optStyle, cardPathFn, field
if (!showIf(sectionData)) hiddenStyle = ' style="display:none"';
}
+ var pfx = cardPathFn(sec);
+ var dp;
+ if (idx >= 0) {
+ dp = pfx + '[' + idx + '].' + key;
+ } else if (subPath) {
+ dp = (pfx ? pfx + '.' : '') + subPath + '.' + key;
+ } else {
+ dp = (pfx ? pfx + '.' : '') + key;
+ }
+ var dpAttr = ' data-field-path="' + escAttr(dp) + '"';
+
function wrap(cls, inner) {
var w = (wide === 'wide') ? ' obj-wide' : '';
if (wide === 'narrow') w = ' obj-narrow';
@@ -244,19 +297,19 @@ function ced_renderField(sec, f, data, idx, subPath, optStyle, cardPathFn, field
}
if (type === 'checkbox') {
- return wrap('obj-field obj-check', ' ' + esc(label) + '');
+ return wrap('obj-field obj-check', ' ' + esc(label) + '');
}
if (type === 'json') {
var jstr = typeof val === 'object' ? JSON.stringify(val) : String(val);
- return wrap('obj-field', '' + esc(label) + '');
+ return wrap('obj-field', '' + esc(label) + '');
}
if (type === 'textarea') {
var dstr = typeof val === 'object' ? (Array.isArray(val) ? val.map(function(v){return v.text||'';}).join('\n') : JSON.stringify(val)) : String(val);
- return wrap('obj-field', '' + esc(label) + '');
+ return wrap('obj-field', '' + esc(label) + '');
}
if (type === 'select') {
var opts = hint ? hint.split('|') : [];
- var inner = '' + esc(label) + '