From 1bedf06969b8ab8e51dd4301a0831200df5c8f59 Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Mon, 13 Jul 2026 18:36:29 -0400 Subject: feat(admin): tooltips added for confusing fields, hide more optional fields with buttons --- internal/admin/static/itemeditor.js | 74 +++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 15 deletions(-) (limited to 'internal/admin/static/itemeditor.js') diff --git a/internal/admin/static/itemeditor.js b/internal/admin/static/itemeditor.js index 04ad20b..2283c91 100644 --- a/internal/admin/static/itemeditor.js +++ b/internal/admin/static/itemeditor.js @@ -52,7 +52,7 @@ var SECTIONS = [ ['level', 'Level', 'number', '', 'narrow'], ['xp', 'XP', 'number', '', 'narrow'], ['ticks_per_cycle', 'Ticks/Cycle', 'number', '', 'narrow'], - ['output_qty', 'Output Qty', 'number', '', 'narrow'], + ['output_qty', 'Output Qty', 'number', '', 'narrow', null, null, 'Quantity produced per cycle, only relevant for stackable items.'], ['station', 'Station', 'select', 'dyn:stations'], ['tool', 'Tool', 'select', 'dyn:tools'], ['fail', 'Fail Item', 'search', 'burnt_fish', '', null, 'items'], @@ -65,10 +65,9 @@ var SECTIONS = [ ['end_message', 'End Message', 'text', 'You\'ve finished smithing.', 'wide'], ], fieldGroups: [ - ['type', 'subtype', 'level', 'xp', 'ticks_per_cycle', 'output_qty'], - {note: 'Output Qty is the quantity produced per cycle, only relevant for stackable items.'}, + ['type', 'subtype', 'level', 'xp', 'ticks_per_cycle', 'output_qty'], ['station', 'tool'], - {label: 'Success', fields: ['success_base', 'success_per_level', 'success_cap', 'fail']}, + {label: 'Success', fields: ['success_base', 'success_per_level', 'success_cap']}, ['start_message', 'success_message', 'fail_message', 'end_message'], ], subSubtables: [ @@ -120,6 +119,7 @@ var SECTIONS = [ ] }, ]; +var SKILL_KEYS = ['accuracy','strength','defense','hitpoints','ranged','science','technology','fishing','cooking','woodcutting','firemaking','mining','smithing','crafting','fletching','pharmacy','thieving','agility','construction','scavenging','hacking','assassin','farming']; function initItemEditor() { window._ieRenderCurrent = renderCurrent; @@ -220,7 +220,7 @@ function renderItemEditor(id, data) { setupCraftTypeChange(); setupEquipTypeChange(); updateOutputQtyVisibility(); - DropView.setupAllInter(); + if (typeof DropView !== 'undefined') DropView.setupAllInter(); setTimeout(function() { document.querySelectorAll('.color-field').forEach(function(el) { bindColorField(el); }); }, 50); @@ -333,7 +333,16 @@ function renderCoreCard(data) { h += renderField(sec, sec.fields[3], data, -1); h += ''; h += '
'; + var qualFid = fieldID(sec, 'max_quality', -1); + var qualVal = data.max_quality; + var qgid = 'qg_core_quality'; + var qShow = qualVal ? '' : 'display:none;'; + var qBtnShow = qualVal ? 'display:none;' : ''; + h += ''; h += renderField(sec, sec.fields[4], data, -1); + h += ''; + h += ''; + h += ''; h += '
'; h += ''; var descFid = fieldID(sec, 'description', -1); @@ -509,7 +518,7 @@ function renderEquipmentCard(data) { // Requirements KV (at root level, stored in itemData.requirements) h += '
'; - h += renderKV({id: 'equipment_req'}, {label:'Requirements', key:'requirements', type:'kv', valType:'number'}, data); + h += renderKV({id: 'equipment_req'}, {label:'Requirements', key:'requirements', type:'kv', valType:'number'}, data, SKILL_KEYS); h += '
'; return h; @@ -763,6 +772,13 @@ function renderSubtable(sec, st, data) { h += '
'; renderGroup(group.fields); h += '
'; + var failF = st.fields.find(function(sf) { return sf[0] === 'fail'; }); + if (failF) { + var failVal = item.fail || ''; + var fgid = 'fg_' + sec.id + '_' + st.key + '_' + idx; + h += '
' + renderSubFieldHTML(sec, st.key, idx, failF, failVal) + '
'; + h += ''; + } h += ''; h += ''; } else { @@ -832,6 +848,7 @@ function addConsumePair(secID, subKey, rowIdx, subSubKey, subIdx) { var btnRow = document.querySelector('.ingredients-pair-add[data-sec="' + secID + '"][data-subkey="' + subKey + '"][data-row="' + rowIdx + '"][data-subsub="' + subSubKey + '"][data-subidx="' + subIdx + '"]'); var itemFid = ingredientPairID(sec, subKey, rowIdx, subSubKey, subIdx, pairIdx, 'items'); var bypFid = ingredientPairID(sec, subKey, rowIdx, subSubKey, subIdx, pairIdx, 'byproducts'); + var bpgid = 'bp_' + secID + '_' + subKey + '_' + rowIdx + '_' + subSubKey + '_' + subIdx + '_' + pairIdx; var row = document.createElement('div'); row.className = 'ingredients-pair'; row.setAttribute('data-sec', secID); @@ -843,7 +860,7 @@ function addConsumePair(secID, subKey, rowIdx, subSubKey, subIdx) { row.innerHTML = '
' + '
' + '
' + renderConsumeSearchHTML(itemFid, '', 'items', 'Search items...') + '
' - + '
' + renderConsumeSearchHTML(bypFid, '', 'items', '(optional)') + '
' + + '
' + '
'; btnRow.parentNode.insertBefore(row, btnRow); setupSearchFields(); @@ -914,7 +931,12 @@ function renderSubSubtable(sec, st, rowIdx, sst, parentItem) { var bypVal = bypArr[p] || ''; var bypFid = ingredientPairID(sec, st.key, rowIdx, sst.key, subIdx, p, 'byproducts'); - h += '
' + renderConsumeSearchHTML(bypFid, bypVal, 'items', '(optional)') + '
'; + var bpgid = 'bp_' + sec.id + '_' + st.key + '_' + rowIdx + '_' + sst.key + '_' + subIdx + '_' + p; + if (bypVal) { + h += '
' + renderConsumeSearchHTML(bypFid, bypVal, 'items', '(optional)') + '
'; + } else { + h += '
'; + } h += '
'; @@ -974,15 +996,28 @@ function renderTags(sec, il, data) { return ''; } -function renderKV(sec, il, data) { +function renderKV(sec, il, data, keyOptions) { var p = cardPath(sec); var sectionRoot = p ? (itemData[p] || {}) : itemData; var map = sectionRoot[il.key] || {}; + var hasKeyOpts = Array.isArray(keyOptions) && keyOptions.length > 0; var h = '
'; h += '' + esc(il.label) + ''; - h += '
'; + h += '
'; Object.keys(map).forEach(function(k, idx) { - h += '
'; + h += '
'; + if (hasKeyOpts) { + var keyOpts = keyOptions.slice(); + if (k && keyOptions.indexOf(k) === -1) keyOpts.unshift(k); + h += ''; + } else { + h += ''; + } h += ''; h += '
'; }); @@ -1192,7 +1227,19 @@ function addKVRow(cardID, subKey) { if (!el) return; var row = document.createElement('div'); row.className = 'obj-kv-row'; - row.innerHTML = ''; + var keyOptsStr = el.getAttribute('data-key-options'); + if (keyOptsStr) { + var keyOpts = keyOptsStr.split(','); + var selHTML = ''; + row.innerHTML = selHTML + ''; + } else { + row.innerHTML = ''; + } el.appendChild(row); } @@ -1292,9 +1339,6 @@ function updateOutputQtyVisibility() { var lbl = el.closest('.obj-field'); if (lbl) lbl.style.display = isStackable ? '' : 'none'; }); - document.querySelectorAll('.output-qty-note').forEach(function(el) { - el.style.display = isStackable ? '' : 'none'; - }); } function setupSearchFields() { ced_setupSearchFields(); } -- cgit v1.2.3