aboutsummaryrefslogtreecommitdiff
path: root/internal/admin/static/editor.js
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin/static/editor.js')
-rw-r--r--internal/admin/static/editor.js29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/admin/static/editor.js b/internal/admin/static/editor.js
index 37bc797..35bdbe6 100644
--- a/internal/admin/static/editor.js
+++ b/internal/admin/static/editor.js
@@ -233,3 +233,32 @@ function esc(s) { return String(s || '').replace(/&/g,'&amp;').replace(/</g,'&lt
function escAttr(s) { return String(s || '').replace(/&/g,'&amp;').replace(/"/g,'&quot;'); }
window.refreshPage = function() { loadList(); if (currentID) loadItem(currentID); };
+
+function renderMoveBar() {
+ var dirs = Object.keys(treeData.dirs).sort();
+ var html = '<div class="add-section-bar">';
+ html += '<select id="moveDirSelect">';
+ html += '<option value="">Move to directory...</option>';
+ html += '<option value="">Root</option>';
+ dirs.forEach(function(dir) {
+ html += '<option value="' + escAttr(dir) + '">' + esc(dir) + '</option>';
+ });
+ html += '</select>';
+ html += '<button class="btn btn-primary btn-sm" onclick="moveToDirectory()">Move</button>';
+ html += '</div>';
+ return html;
+}
+
+function moveToDirectory() {
+ var sel = $('#moveDirSelect');
+ var idx = sel.selectedIndex;
+ if (idx === 0) return;
+ var dir = sel.value;
+ if (!confirm('Move ' + currentID + ' to ' + (dir || 'Root') + '?')) return;
+ API.post('/api/' + editorType + '/move', {id: currentID, dir: dir}).then(function() {
+ notify('Moved ' + currentID + ' to ' + (dir || 'Root'), 'success');
+ updateUndoBar();
+ loadList();
+ loadItem(currentID);
+ }).catch(function(e) { notify('Move failed: ' + e.message, 'error'); });
+}