From 709917f657eda63f10ea244546e8bb7fd4d839e8 Mon Sep 17 00:00:00 2001
From: historia <[not public]>
Date: Mon, 13 Jul 2026 16:49:22 -0400
Subject: feat(admin): hide irrelevant equipment fields
---
internal/admin/static/itemeditor.js | 67 ++++++++++++++++++++++++++++++++-----
1 file changed, 58 insertions(+), 9 deletions(-)
diff --git a/internal/admin/static/itemeditor.js b/internal/admin/static/itemeditor.js
index 6375c16..c28f273 100644
--- a/internal/admin/static/itemeditor.js
+++ b/internal/admin/static/itemeditor.js
@@ -218,6 +218,7 @@ function renderItemEditor(id, data) {
$('#editorMain').innerHTML = html;
setupSearchFields();
setupCraftTypeChange();
+ setupEquipTypeChange();
updateOutputQtyVisibility();
setTimeout(function() {
document.querySelectorAll('.color-field').forEach(function(el) { bindColorField(el); });
@@ -442,14 +443,18 @@ function renderEquipmentCard(data) {
var eq = data.equipment || {};
var h = '';
var isAmmo = eq.type === 'ammo';
+ var isWeapon = ['melee_weapon', 'ranged_weapon', 'tech_weapon'].indexOf(eq.type) >= 0;
+ var isMelee = eq.type === 'melee_weapon';
// Row 1: type, slot
h += '
';
h += renderEquipField('type', 'Type', 'select', 'melee_weapon|ranged_weapon|tech_weapon|armor|tool|ammo', eq.type);
- if (!isAmmo) {
+ if (!isAmmo && !isWeapon) {
h += renderEquipField('slot', 'Slot', 'select', 'head|neck|torso|legs|hands|feet|back|ammo|main_hand|off_hand|ring', eq.slot);
- } else {
+ } else if (isAmmo) {
h += '';
+ } else {
+ h += '';
}
h += '
';
@@ -459,16 +464,32 @@ function renderEquipmentCard(data) {
}
// Row 2: attack_type, speed, junk
- var isMelee = eq.type === 'melee_weapon';
- var isWeapon = ['melee_weapon', 'ranged_weapon', 'tech_weapon'].indexOf(eq.type) >= 0;
h += '';
if (isMelee) {
- h += renderEquipField('attack_type', 'Attack Type', 'select', 'stab|slash|crush', eq.attack_type);
+ var atkVal = eq.attack_type || 'stab';
+ var atkOpts = ['stab', 'slash', 'crush'];
+ var atkIdx = atkOpts.indexOf(atkVal);
+ if (atkIdx < 0) atkIdx = 0;
+ h += '
';
+ h += '
Atk Type';
+ h += '
';
+ atkOpts.forEach(function(t, i) {
+ h += '';
+ });
+ h += '
';
+ h += '
';
+ h += '
';
}
if (isWeapon) {
- h += renderEquipField('speed', 'Speed', 'number', '', eq.speed, 'narrow');
+ h += renderEquipField('speed', 'Speed', 'number', '5', eq.speed, 'narrow');
}
- h += renderEquipField('junk', 'Junk', 'search', '', eq.junk, '', 'items');
+ var junkItems = ['solarjunk','hydrojunk','cosmicjunk','chaosjunk','ecojunk','biojunk','naturejunk','lawjunk','deathjunk','bloodjunk'];
+ h += '
';
h += '
';
// 3 buttons row
@@ -526,6 +547,25 @@ function removeEquipBlock(blockKey) {
renderItemEditor(itemID, itemData);
}
+function eq_atkPillSelect(val, btn) {
+ var pill = btn.closest('.eq-atktype-pill');
+ if (!pill) return;
+ var opts = pill.querySelectorAll('.seg-opt');
+ var idx = -1;
+ opts.forEach(function(o, i) {
+ if (o.getAttribute('data-v') === val) {
+ o.classList.add('seg-active');
+ idx = i;
+ } else {
+ o.classList.remove('seg-active');
+ }
+ });
+ pill.className = pill.className.replace(/seg-idx-\d/g, 'seg-idx-' + idx);
+ var hidden = document.getElementById('f_equipment_attack_type');
+ if (hidden) hidden.value = val;
+ renderCurrent();
+}
+
// =========================================================================
// Generic field render (unchanged)
// =========================================================================
@@ -989,7 +1029,7 @@ function addSection() {
if (sec.path) {
if (sec.id === 'equipment') {
- itemData.equipment = {type:'', slot:'', attack_type:'', speed:0, junk:''};
+ itemData.equipment = {type:'', slot:'', attack_type:'stab', speed:0, junk:''};
} else if (sec.isArray && sec.interactionStyle) {
itemData[sec.path] = [];
} else {
@@ -1228,6 +1268,14 @@ function setupCraftTypeChange() {
});
}
+function setupEquipTypeChange() {
+ var el = document.getElementById('f_equipment_type');
+ if (!el) return;
+ var newEl = el.cloneNode(true);
+ el.parentNode.replaceChild(newEl, el);
+ newEl.addEventListener('change', renderCurrent);
+}
+
function updateOutputQtyVisibility() {
var isStackable = false;
var stackableEl = document.getElementById('f_core_stackable');
@@ -1415,12 +1463,13 @@ function saveItem() {
['type', 'slot', 'attack_type', 'junk'].forEach(function(k) {
var el = document.getElementById('f_equipment_' + k);
if (!el) return;
- var val = collectFieldValue(el, k === 'type' || k === 'slot' ? 'select' : (k === 'junk' ? 'search' : 'text'));
+ var val = collectFieldValue(el, k === 'type' || k === 'slot' ? 'select' : (k === 'junk' ? 'select' : 'text'));
if (val !== '' && val !== false && val !== 0 && val !== null) hasEq = true;
eq[k] = val;
});
if (eq.type === 'ammo') eq.slot = 'ammo';
+ if (eq.type === 'melee_weapon' || eq.type === 'ranged_weapon' || eq.type === 'tech_weapon') eq.slot = 'main_hand';
var speedEl = document.getElementById('f_equipment_speed');
if (speedEl) {
--
cgit v1.2.3