aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/static/itemeditor.js
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/static/itemeditor.js')
-rw-r--r--internal/admin/static/itemeditor.js17
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);
}
// =========================================================================