fix(library): SQL workspace — (workspace != '' OR workspace_id IS NOT NULL)
Les pages du workspace local ont workspace='' mais workspace_id=27. Le filtre workspace != '' les excluait, retournant 0 items. Ajout de OR workspace_id IS NOT NULL pour inclure les pages locales. Simplification du frontend: le workspace tab appelle l'API standard avec workspace_id.
This commit is contained in:
@@ -445,7 +445,7 @@ async def library_workspace(
|
||||
source_type = "all"
|
||||
|
||||
uid = _get_user_id(request)
|
||||
query = f"{BASE_SELECT} FROM pages p WHERE p.workspace != '' AND p.parent_section != 'Trash' AND p.deleted_at IS NULL"
|
||||
query = f"{BASE_SELECT} FROM pages p WHERE (p.workspace != '' OR p.workspace_id IS NOT NULL) AND p.parent_section != 'Trash' AND p.deleted_at IS NULL"
|
||||
params: list = []
|
||||
|
||||
if workspace_id:
|
||||
|
||||
@@ -464,14 +464,8 @@ function libraryPage() {
|
||||
try {
|
||||
var url = '/api/library/' + this.tab;
|
||||
var sep = '?';
|
||||
// Workspace tab: if local workspace is active, show local workspace items
|
||||
if (this.tab === 'workspace' && this.workspaceId && !this.isGiteaActive) {
|
||||
url = '/api/library/local-workspace' + sep + 'workspace_id=' + this.workspaceId;
|
||||
sep = '&';
|
||||
} else {
|
||||
if (this.workspaceId && (this.tab === 'recents')) {
|
||||
url += sep + 'workspace_id=' + this.workspaceId; sep = '&';
|
||||
}
|
||||
if (this.workspaceId && (this.tab === 'recents' || this.tab === 'workspace')) {
|
||||
url += sep + 'workspace_id=' + this.workspaceId; sep = '&';
|
||||
}
|
||||
if (this.tab === 'repository' && this.isGiteaActive) {
|
||||
url += sep + 'gitea_owner=' + encodeURIComponent(this.giteaOwner) + '&gitea_repo=' + encodeURIComponent(this.giteaRepo);
|
||||
@@ -528,12 +522,7 @@ function libraryPage() {
|
||||
this.expanded = Object.assign({}, this.expanded);
|
||||
if (!item.children || !item.children.length) {
|
||||
try {
|
||||
// Route to correct children endpoint based on source type
|
||||
var childrenUrl = '/api/library/children/' + item.id;
|
||||
if (item.source_type === 'local-ws') {
|
||||
childrenUrl = '/api/library/local-workspace-children/' + item.id;
|
||||
}
|
||||
var r = await fetch(childrenUrl);
|
||||
var r = await fetch('/api/library/children/' + item.id);
|
||||
var d = await r.json();
|
||||
item.children = d.items || [];
|
||||
// Mark the tree for depth calculation
|
||||
|
||||
Reference in New Issue
Block a user