From f6aaaa123f7a3151dd55987618f369eb6ac569fc Mon Sep 17 00:00:00 2001 From: bruno Date: Sat, 11 Jul 2026 14:05:54 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20cr=C3=A9ation=20fichier/dossier=20instan?= =?UTF-8?q?tan=C3=A9e=20sans=20refresh=20de=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avant: doCreate() appelait _reloadAfterAction() → page reload → le nouvel élément ne s'affichait pas immédiatement dans l'arbre. Après: insertion AJAX du nouveau node dans this.tree via _insertIntoParent(). Le parent est auto-expandé. displayTree mis à jour si aucun filtre actif. Plus besoin de refresh. Reste reload pour rename/delete/upload (complexité renderChildren). --- app/templates/local_workspace.html | 41 +++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/app/templates/local_workspace.html b/app/templates/local_workspace.html index 6e57e52..e2b524a 100644 --- a/app/templates/local_workspace.html +++ b/app/templates/local_workspace.html @@ -668,13 +668,52 @@ document.addEventListener('alpine:init', function() { body:JSON.stringify(body) }); if (r.ok) { + var d = await r.json(); this.showCreate = false; this.parentFolder = null; this.newName = ''; - this._reloadAfterAction(); + // Insert new node into tree without reload + var isFolder = this.createType === 'folder'; + var newNode = { + id: d.id, db_id: d.id, name: d.name || n, + is_folder: isFolder, type: isFolder ? 'folder' : 'page', + content_format: isFolder ? null : 'blocks', + children: [], has_children: false, depth: 0 + }; + if (this.parentFolder && this.parentFolder.db_id) { + // Insert as child of parent folder + this._insertIntoParent(this.tree, this.parentFolder.db_id, newNode); + // Auto-expand parent so the new item is visible + this.expanded[this.parentFolder.db_id] = true; + this.expanded = Object.assign({}, this.expanded); + } else { + // Insert at root + this.tree.unshift(newNode); + } + // Update displayTree + if (!this.searchQuery && !this.filterType) { + this.displayTree = this.tree; + } + this._saveExpandedState(); } }, + _insertIntoParent(nodes, parentId, newNode) { + for (var i=0; i