0;
var icon = c.is_folder ? '📁' : '📄';
- html += '
';
+ var escName = this.esc(c.name);
+ html += '
';
if (c.is_folder && hasKids) {
- html += '';
+ html += '';
} else {
html += '';
}
@@ -364,17 +371,19 @@ document.addEventListener('alpine:init', function() {
if (c.is_folder) {
html += ''+c.name+'';
} else {
- html += ''+c.name+'';
+ html += ''+c.name+'';
}
html += '
';
if (c.is_folder) {
html += '';
- html += '';
- html += '';
+ html += '';
+ html += '';
html += '';
}
- html += '';
- html += '';
+ html += '';
+ html += '';
html += '
';
if (hasKids) {
html += '
'+this.renderChildren(c.children, depth+1)+'
';
@@ -389,6 +398,32 @@ document.addEventListener('alpine:init', function() {
return s.replace(/\\/g,'\\\\').replace(/'/g,"\\'").replace(/"/g,'"');
},
+ // ── Event delegation for renderChildren action buttons ──
+ handleTreeAction(ev) {
+ var btn = ev.target.closest('[data-ws-action]');
+ if (!btn) return;
+ ev.stopPropagation();
+ var action = btn.getAttribute('data-ws-action');
+ var id = parseInt(btn.getAttribute('data-ws-id'));
+ var name = btn.getAttribute('data-ws-name') || '';
+ if (!id) return;
+
+ switch(action) {
+ case 'new-file':
+ this.openModal('file', {db_id: id, name: name});
+ break;
+ case 'new-folder':
+ this.openModal('folder', {db_id: id, name: name});
+ break;
+ case 'rename':
+ this.startRename({db_id: id, name: name});
+ break;
+ case 'delete':
+ this.startDelete({db_id: id, name: name});
+ break;
+ }
+ },
+
toggleExpand(id, btn) {
this.expanded[id] = !(this.expanded[id] || false);
this.expanded = Object.assign({}, this.expanded);