diff options
| author | historia <[not public]> | 2026-07-05 18:52:51 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-07-05 18:52:51 -0400 |
| commit | 6bd5365cc22f84c047c1585e3f54571af46f53e5 (patch) | |
| tree | 72df0934c72baa1e31817d7db999832c6efb115f /internal/admin/static/itemeditor.js | |
| parent | 9b54188970c51070d86f4c87e909ea7836c86f07 (diff) | |
| download | thehouseoficarus-6bd5365cc22f84c047c1585e3f54571af46f53e5.tar.gz | |
feat: renameable directories and files in admin gui
Diffstat (limited to 'internal/admin/static/itemeditor.js')
| -rw-r--r-- | internal/admin/static/itemeditor.js | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/internal/admin/static/itemeditor.js b/internal/admin/static/itemeditor.js index 5ffb0cb..ac76f94 100644 --- a/internal/admin/static/itemeditor.js +++ b/internal/admin/static/itemeditor.js @@ -174,7 +174,7 @@ function loadItemEditor(id) { } function renderItemEditor(id, data) { - var html = '<h2>Item: ' + esc(id) + '</h2>'; + var html = renderRenameableHeader('Item', id); html += '<div class="tabs"><button class="tab active" onclick="switchTab(event,\'fields\')">Fields</button>'; html += '<button class="tab" onclick="switchTab(event,\'yaml\')">Raw YAML</button></div>'; @@ -460,8 +460,9 @@ function addEquipBlock(blockKey) { } function removeEquipBlock(blockKey) { + ced_syncDOMToData(itemData); if (itemData.equipment) delete itemData.equipment[blockKey]; - renderCurrent(); + renderItemEditor(itemID, itemData); } // ========================================================================= @@ -902,6 +903,7 @@ function toggleCardWidth(id) { function removeSection(id) { var sec = SECTIONS.find(function(s) { return s.id === id; }); if (!sec) return; + ced_syncDOMToData(itemData); if (sec.path) { delete itemData[sec.path]; } else { @@ -910,7 +912,7 @@ function removeSection(id) { if (sec.subtables) sec.subtables.forEach(function(st) { delete itemData[st.key]; }); } delete addedSections[id]; - renderCurrent(); + renderItemEditor(itemID, itemData); } function addSection() { @@ -952,9 +954,10 @@ function addArrayItem(cardID) { function removeArrayItem(cardID, idx) { var sec = SECTIONS.find(function(s) { return s.id === cardID; }); if (!sec || !sec.isArray) return; + ced_syncDOMToData(itemData); var arr = itemData[sec.path] || []; arr.splice(idx, 1); - renderCurrent(); + renderItemEditor(itemID, itemData); } // ========================================================================= @@ -991,6 +994,7 @@ function addSubRow(cardID, subKey) { function removeSubRow(cardID, subKey, idx) { var sec = SECTIONS.find(function(s) { return s.id === cardID; }); if (!sec) return; + ced_syncDOMToData(itemData); var p = cardPath(sec); var sectionRoot = p ? (itemData[p] || {}) : itemData; var raw = sectionRoot[subKey]; @@ -1004,7 +1008,7 @@ function removeSubRow(cardID, subKey, idx) { } arr.splice(idx, 1); sectionRoot[subKey] = arr; - renderCurrent(); + renderItemEditor(itemID, itemData); } // ========================================================================= @@ -1044,13 +1048,14 @@ function addSubSubRow(cardID, subKey, rowIdx, subSubKey) { function removeSubSubRow(cardID, subKey, rowIdx, subSubKey, subSubIdx) { var sec = SECTIONS.find(function(s) { return s.id === cardID; }); if (!sec) return; + ced_syncDOMToData(itemData); var p = cardPath(sec); var sectionRoot = p ? (itemData[p] || {}) : itemData; var arr = sectionRoot[subKey] || []; if (rowIdx >= arr.length) return; var subArr = arr[rowIdx][subSubKey] || []; subArr.splice(subSubIdx, 1); - renderCurrent(); + renderItemEditor(itemID, itemData); } // ========================================================================= |
