From 034187d1c434b6bee32aeb539ea543f6ec537376 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Fri, 3 Jul 2026 16:55:23 -0400 Subject: feat: card ui added to drops, hazards, techs, and mods in admin gui --- internal/admin/static/admin.css | 2 + internal/admin/static/dropeditor.js | 224 ++++++++++++++++++++++++ internal/admin/static/hazardeditor.js | 226 ++++++++++++++++++++++++ internal/admin/static/itemeditor.js | 11 +- internal/admin/static/mobeditor.js | 13 +- internal/admin/static/moduleeditor.js | 318 ++++++++++++++++++++++++++++++++++ internal/admin/static/objecteditor.js | 11 +- internal/admin/static/techeditor.js | 191 ++++++++++++++++++++ 8 files changed, 992 insertions(+), 4 deletions(-) create mode 100644 internal/admin/static/dropeditor.js create mode 100644 internal/admin/static/hazardeditor.js create mode 100644 internal/admin/static/moduleeditor.js create mode 100644 internal/admin/static/techeditor.js (limited to 'internal/admin/static') diff --git a/internal/admin/static/admin.css b/internal/admin/static/admin.css index b44adcd..8c3ee8e 100644 --- a/internal/admin/static/admin.css +++ b/internal/admin/static/admin.css @@ -272,6 +272,8 @@ g.ud-hover:hover text{font-weight:bold} .obj-card-arrow{font-size:10px;width:14px;color:#888} .obj-card-label{flex:1;color:var(--text)} .obj-card-remove{padding:2px 6px;font-size:10px;min-width:auto} +.obj-card-expand{padding:2px 5px;font-size:11px;min-width:auto;background:transparent;color:#888;border:1px solid transparent;border-radius:3px;cursor:pointer;font-family:monospace;line-height:1} +.obj-card-expand:hover{color:var(--text);border-color:var(--border);background:rgba(255,255,255,.05)} .obj-card-body{padding:10px 12px} .obj-card-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(140px,1fr));gap:6px 8px} .obj-field{display:flex;flex-direction:column;gap:2px;font-size:11px} diff --git a/internal/admin/static/dropeditor.js b/internal/admin/static/dropeditor.js new file mode 100644 index 0000000..1569a04 --- /dev/null +++ b/internal/admin/static/dropeditor.js @@ -0,0 +1,224 @@ +var dropData = null; +var dropID = null; +var expandedCards = {}; +var cardWidths = {}; + +var DROP_SECTIONS = [ + { + id: 'drops', label: 'Drops', always: true, path: 'drops', isArray: true, + fields: [ + ['item_id', 'Item ID', 'search', '', '', null, 'items'], + ['table', 'Table', 'search', '', '', null, 'drops'], + ['weight', 'Weight', 'number', '', 'narrow'], + ['quantity', 'Quantity', 'number', '1', 'narrow'], + ['level', 'Level', 'number', '', 'narrow'], + ['xp', 'XP', 'number', '', 'narrow'], + ['depletes', 'Depletes', 'checkbox'], + ['success_message', 'Success Message', 'text', '', 'wide'], + ] + } +]; + +function initDropEditor() { + editorType = 'drops'; + editorFields = []; + loadList(); + if (window.location.hash) loadDropEditor(window.location.hash.substring(1)); +} + +function cardPath(sec) { return sec.path || ''; } + +function getVal(data, sec, key) { + return ced_getVal(data, sec, key); +} + +function fieldID(sec, key, idx) { + return ced_fieldID(sec, key, idx); +} + +function setupSearchFields() { ced_setupSearchFields(); } + +function collectFieldValue(el, type) { return ced_collectFieldValue(el, type); } + +function loadDropEditor(id) { + dropID = id; + currentID = id; + renderList(''); + window.location.hash = id; + API.get('/api/drops/' + encodeURIComponent(id)).then(function(data) { + dropData = data; + renderDropEditor(id, data); + }).catch(function(e) { + $('#editorMain').innerHTML = '
Failed to load: ' + esc(e.message) + '
'; + }); +} + +function loadItem(id) { loadDropEditor(id); } + +function renderDropEditor(id, data) { + var html = 'Deleted
'; + loadList(); + }).catch(function(e) { notify('Delete failed: ' + e.message, 'error'); }); +} diff --git a/internal/admin/static/hazardeditor.js b/internal/admin/static/hazardeditor.js new file mode 100644 index 0000000..b07456e --- /dev/null +++ b/internal/admin/static/hazardeditor.js @@ -0,0 +1,226 @@ +var hazardData = null; +var hazardID = null; +var expandedCards = {}; +var addedSections = {}; +var cardWidths = {}; + +var HAZARD_SECTIONS = [ + { + id: 'core', label: 'Core', always: true, + fields: [ + ['name', 'Name', 'text'], + ['description', 'Description', 'textarea', '', 'wide'], + ['warn_message', 'Warn Message', 'text', '', 'wide'], + ['hit_message', 'Hit Message', 'text'], + ['miss_message', 'Miss Message', 'text'], + ['required_item', 'Required Item', 'text'], + ['speed', 'Speed', 'number', '', 'narrow'], + ] + }, + { + id: 'combat', label: 'Combat', + detect: function(d) { return d.attack_type || d.attack || d.attack_bonus || d.max_hit; }, + fields: [ + ['attack_type', 'Attack Type', 'select', 'stab|slash|crush|ranged|science'], + ['attack', 'Attack', 'number', '', 'narrow'], + ['attack_bonus', 'Attack Bonus', 'number', '', 'narrow'], + ['max_hit', 'Max Hit', 'number', '', 'narrow'], + ] + } +]; + +function initHazardEditor() { + editorType = 'hazards'; + editorFields = []; + loadList(); + if (window.location.hash) loadHazardEditor(window.location.hash.substring(1)); +} + +function cardPath(sec) { return sec.path || ''; } + +function getVal(data, sec, key) { + return ced_getVal(data, sec, key); +} + +function fieldID(sec, key, idx) { + return ced_fieldID(sec, key, idx); +} + +function setupSearchFields() { ced_setupSearchFields(); } + +function collectFieldValue(el, type) { return ced_collectFieldValue(el, type); } + +function loadHazardEditor(id) { + hazardID = id; + currentID = id; + renderList(''); + window.location.hash = id; + API.get('/api/hazards/' + encodeURIComponent(id)).then(function(data) { + hazardData = data; + renderHazardEditor(id, data); + }).catch(function(e) { + $('#editorMain').innerHTML = 'Failed to load: ' + esc(e.message) + '
'; + }); +} + +function loadItem(id) { loadHazardEditor(id); } + +function renderHazardEditor(id, data) { + var html = 'Deleted
'; + loadList(); + }).catch(function(e) { notify('Delete failed: ' + e.message, 'error'); }); +} diff --git a/internal/admin/static/itemeditor.js b/internal/admin/static/itemeditor.js index 215baf0..641f064 100644 --- a/internal/admin/static/itemeditor.js +++ b/internal/admin/static/itemeditor.js @@ -2,6 +2,7 @@ var itemData = null; var itemID = null; var expandedCards = {}; var addedSections = {}; +var cardWidths = {}; var SECTIONS = [ { @@ -231,9 +232,12 @@ function renderCurrent() { function renderCard(sec, data) { var collapsed = expandedCards[sec.id] === false; - var h = 'Failed to load: ' + esc(e.message) + '
'; + }); +} + +function loadItem(id) { loadModuleEditor(id); } + +function renderModuleEditor(id, data) { + var html = 'Deleted
'; + loadList(); + }).catch(function(e) { notify('Delete failed: ' + e.message, 'error'); }); +} diff --git a/internal/admin/static/objecteditor.js b/internal/admin/static/objecteditor.js index d45c26e..3cbb37a 100644 --- a/internal/admin/static/objecteditor.js +++ b/internal/admin/static/objecteditor.js @@ -1,6 +1,7 @@ var objectData = null; var objectID = null; var expandedCards = {}; +var cardWidths = {}; var SECTIONS = [ { @@ -220,9 +221,12 @@ function fieldIDSub(sec, subKey, idx, fieldKey) { function renderCard(sec, data) { var collapsed = expandedCards[sec.id] === false; - var h = 'Failed to load: ' + esc(e.message) + '
'; + }); +} + +function loadItem(id) { loadTechEditor(id); } + +function renderTechEditor(id, data) { + var html = 'Deleted
'; + loadList(); + }).catch(function(e) { notify('Delete failed: ' + e.message, 'error'); }); +} -- cgit v1.2.3