fix(library): visibility hover + workspace filter + tab Repository pour Gitea
- CSS hover-only: visibility:hidden/visible au lieu de opacity (infaillible) - Workspace tab: filtré par workspace_id quand un workspace est actif - Tab Private remplacé par Repository (visible seulement si Gitea workspace actif) - Nouvel endpoint /api/library/repository pour le contenu Gitea - dashboard.py passe is_gitea_workspace, owner, repo au template
This commit is contained in:
+33
-11
@@ -12,6 +12,9 @@
|
||||
{% block content %}
|
||||
<div x-data="libraryPage()" x-init="init()" @keydown.escape="closePeek()">
|
||||
<div id="lib-workspace-id" style="display:none;">{{ active_workspace_id or 0 }}</div>
|
||||
<div id="lib-gitea-active" style="display:none;">{{ '1' if is_gitea_workspace else '0' }}</div>
|
||||
<div id="lib-gitea-owner" style="display:none;">{{ gitea_workspace_owner or '' }}</div>
|
||||
<div id="lib-gitea-repo" style="display:none;">{{ gitea_workspace_repo or '' }}</div>
|
||||
|
||||
<style>
|
||||
/* ── Library layout ── */
|
||||
@@ -62,18 +65,18 @@
|
||||
.row-title input{width:100%;font-size:13px;padding:2px 4px;background:var(--bg-primary);border:1px solid var(--accent);border-radius:4px;color:var(--text-primary);outline:none;}
|
||||
|
||||
/* ── Hover-only elements (appear on row hover) ── */
|
||||
.hover-only{opacity:0;transition:opacity 0.12s;flex-shrink:0;}
|
||||
.lib-row:hover .hover-only{opacity:1;}
|
||||
.hover-only{visibility:hidden;opacity:0;transition:opacity 0.12s, visibility 0s 0.12s;flex-shrink:0;}
|
||||
.lib-row:hover .hover-only{visibility:visible;opacity:1;transition:opacity 0.15s, visibility 0s 0s;}
|
||||
|
||||
/* Drag handle — 6 dots (hover-only, far left of name cell) */
|
||||
.drag-handle{display:flex;flex-wrap:wrap;width:14px;height:14px;cursor:grab;align-content:space-between;justify-content:space-between;flex-shrink:0;}
|
||||
.drag-handle{display:flex;flex-wrap:wrap;width:16px;height:16px;cursor:grab;align-content:space-between;justify-content:space-between;flex-shrink:0;}
|
||||
.drag-handle .dot{width:3px;height:3px;background:var(--text-tertiary);border-radius:50%;}
|
||||
.drag-handle:active{cursor:grabbing;}
|
||||
|
||||
/* Checkbox (hover-only) */
|
||||
.lib-checkbox{width:15px;height:15px;border:1.5px solid var(--text-tertiary);border-radius:3px;cursor:pointer;flex-shrink:0;display:flex;align-items:center;justify-content:center;transition:all 0.1s;}
|
||||
.lib-checkbox{width:15px;height:15px;border:1.5px solid var(--text-tertiary);border-radius:3px;cursor:pointer;flex-shrink:0;display:flex;align-items:center;justify-content:center;transition:border-color 0.1s;}
|
||||
.lib-checkbox:hover{border-color:var(--text-primary);}
|
||||
.lib-checkbox.checked{background:var(--accent);border-color:var(--accent);opacity:1;}
|
||||
.lib-checkbox.checked{background:var(--accent);border-color:var(--accent);visibility:visible;opacity:1;}
|
||||
.lib-checkbox.checked::after{content:'✓';color:#fff;font-size:10px;font-weight:700;}
|
||||
|
||||
/* OPEN button (hover-only, right side of name cell) */
|
||||
@@ -176,9 +179,12 @@
|
||||
<button class="lib-tab" :class="{ active: tab === 'published' }" @click="switchTab('published')">
|
||||
<span class="tab-icon">🌐</span> Published
|
||||
</button>
|
||||
<button class="lib-tab" :class="{ active: tab === 'private' }" @click="switchTab('private')">
|
||||
<button class="lib-tab" :class="{ active: tab === 'private' }" @click="switchTab('private')" x-show="!isGiteaActive">
|
||||
<span class="tab-icon">🔒</span> Private
|
||||
</button>
|
||||
<button class="lib-tab" :class="{ active: tab === 'repository' }" @click="switchTab('repository')" x-show="isGiteaActive">
|
||||
<span class="tab-icon">📦</span> Repository
|
||||
</button>
|
||||
<button class="lib-tab" :class="{ active: tab === 'workspace' }" @click="switchTab('workspace')">
|
||||
<span class="tab-icon">📁</span> Workspace
|
||||
</button>
|
||||
@@ -330,6 +336,9 @@ function libraryPage() {
|
||||
return {
|
||||
tab: 'recents',
|
||||
workspaceId: 0,
|
||||
isGiteaActive: false,
|
||||
giteaOwner: '',
|
||||
giteaRepo: '',
|
||||
items: [],
|
||||
loading: false,
|
||||
searchOpen: false,
|
||||
@@ -388,12 +397,13 @@ function libraryPage() {
|
||||
|
||||
// ── Empty states ──
|
||||
get emptyIcon() {
|
||||
var icons = {recents:'🕒',favorites:'⭐',shared:'👥',published:'🌐',private:'🔒',workspace:'📁'};
|
||||
var icons = {recents:'🕒',favorites:'⭐',shared:'👥',published:'🌐',private:'🔒',workspace:'📁',repository:'📦'};
|
||||
return icons[this.tab] || '📄';
|
||||
},
|
||||
get emptyTitle() {
|
||||
var titles = {recents:'No recent pages',favorites:'No favorites',shared:'No shared pages',
|
||||
published:'No published pages',private:'No private pages',workspace:'No workspace pages'};
|
||||
published:'No published pages',private:'No private pages',workspace:'No workspace pages',
|
||||
repository:'Empty repository'};
|
||||
return titles[this.tab] || 'No items';
|
||||
},
|
||||
get emptyText() {
|
||||
@@ -402,7 +412,8 @@ function libraryPage() {
|
||||
shared:'Shared pages from your team will appear here.',
|
||||
published:'Pages published to the web will appear here.',
|
||||
private:'Create a new page with the + button.',
|
||||
workspace:'Pages inside workspaces will appear here.'};
|
||||
workspace:'Pages inside workspaces will appear here.',
|
||||
repository:'Repository files and pages will appear here.'};
|
||||
return texts[this.tab] || '';
|
||||
},
|
||||
|
||||
@@ -410,9 +421,13 @@ function libraryPage() {
|
||||
init() {
|
||||
var wsEl = document.getElementById('lib-workspace-id');
|
||||
this.workspaceId = parseInt(wsEl ? wsEl.textContent : '0') || 0;
|
||||
var giteaEl = document.getElementById('lib-gitea-active');
|
||||
this.isGiteaActive = (giteaEl ? giteaEl.textContent : '0') === '1';
|
||||
this.giteaOwner = (document.getElementById('lib-gitea-owner') || {}).textContent || '';
|
||||
this.giteaRepo = (document.getElementById('lib-gitea-repo') || {}).textContent || '';
|
||||
var params = new URLSearchParams(window.location.search);
|
||||
var t = params.get('tab');
|
||||
if (t && ['recents','favorites','shared','published','private','workspace'].indexOf(t) !== -1) {
|
||||
if (t && ['recents','favorites','shared','published','private','workspace','repository'].indexOf(t) !== -1) {
|
||||
this.tab = t;
|
||||
}
|
||||
this.loadTab();
|
||||
@@ -420,6 +435,7 @@ function libraryPage() {
|
||||
|
||||
switchTab(t) {
|
||||
if (this.tab === t) return;
|
||||
if (t === 'repository' && !this.isGiteaActive) return;
|
||||
this.tab = t;
|
||||
this.items = [];
|
||||
this.selected = {};
|
||||
@@ -443,7 +459,13 @@ function libraryPage() {
|
||||
try {
|
||||
var url = '/api/library/' + this.tab;
|
||||
var sep = '?';
|
||||
if (this.workspaceId) { url += '?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);
|
||||
sep = '&';
|
||||
}
|
||||
var r = await fetch(url);
|
||||
var d = await r.json();
|
||||
this.items = d.items || [];
|
||||
|
||||
Reference in New Issue
Block a user