feat: menu contextuel repertoire → Sauvegarder recherche + icone dossier
- ContextMenuManager: option Ajouter aux recherches sauvegardees pour repertoires - _saveDirectorySearch: POST /api/saved-searches avec include_paths=repertoire/** - Bascule automatique vers longlet Sauvegardes dans le sidebar - loadSavedSearches: icone folder-search + classe saved-search-dir pour recherches dossier - Recherches dossier affichent le chemin au lieu d'une query vide
This commit is contained in:
@@ -333,6 +333,9 @@ async function loadSavedSearches() {
|
|||||||
}
|
}
|
||||||
if (empty) empty.style.display = "none";
|
if (empty) empty.style.display = "none";
|
||||||
list.innerHTML = searches.map(s => {
|
list.innerHTML = searches.map(s => {
|
||||||
|
var isDirSearch = (!s.query || s.query.trim() === '') && s.include_paths;
|
||||||
|
var displayQuery = isDirSearch ? (s.include_paths || 'Dossier') : escapeHtml(s.query);
|
||||||
|
var dirIcon = isDirSearch ? '<i data-lucide="folder-search" style="width:14px;height:14px;margin-right:4px;color:var(--accent)"></i>' : '';
|
||||||
const badges = [];
|
const badges = [];
|
||||||
if (s.case_sensitive) badges.push('<span class="search-filter-badge">Aa</span>');
|
if (s.case_sensitive) badges.push('<span class="search-filter-badge">Aa</span>');
|
||||||
if (s.whole_word) badges.push('<span class="search-filter-badge">wd</span>');
|
if (s.whole_word) badges.push('<span class="search-filter-badge">wd</span>');
|
||||||
@@ -342,8 +345,8 @@ async function loadSavedSearches() {
|
|||||||
if (s.exclude_paths) pathFilters.push(`<span class="saved-search-path" title="Exclure: ${escapeHtml(s.exclude_paths)}">\u{1F4E4} ${escapeHtml(s.exclude_paths)}</span>`);
|
if (s.exclude_paths) pathFilters.push(`<span class="saved-search-path" title="Exclure: ${escapeHtml(s.exclude_paths)}">\u{1F4E4} ${escapeHtml(s.exclude_paths)}</span>`);
|
||||||
const vaultStr = s.vault && s.vault !== "all" ? `<span class="saved-search-vault">\u{1F4C1} ${escapeHtml(s.vault)}</span>` : "";
|
const vaultStr = s.vault && s.vault !== "all" ? `<span class="saved-search-vault">\u{1F4C1} ${escapeHtml(s.vault)}</span>` : "";
|
||||||
return `
|
return `
|
||||||
<div class="saved-search-item">
|
<div class="saved-search-item${isDirSearch ? ' saved-search-dir' : ''}">
|
||||||
<div class="saved-search-query">${escapeHtml(s.query)}</div>
|
<div class="saved-search-query">${dirIcon}${displayQuery}</div>
|
||||||
<div class="saved-search-meta">
|
<div class="saved-search-meta">
|
||||||
${badges.join("")}
|
${badges.join("")}
|
||||||
${vaultStr}
|
${vaultStr}
|
||||||
|
|||||||
@@ -1677,6 +1677,8 @@ export const ContextMenuManager = {
|
|||||||
this._addItem('folder-plus', 'Nouveau sous-dossier', () => this._createDirectory(), isReadonly);
|
this._addItem('folder-plus', 'Nouveau sous-dossier', () => this._createDirectory(), isReadonly);
|
||||||
this._addItem('file-plus', 'Nouveau fichier ici', () => this._createFile(), isReadonly);
|
this._addItem('file-plus', 'Nouveau fichier ici', () => this._createFile(), isReadonly);
|
||||||
this._addSeparator();
|
this._addSeparator();
|
||||||
|
this._addItem('bookmark-plus', 'Ajouter aux recherches sauvegardees', () => this._saveDirectorySearch(), false);
|
||||||
|
this._addSeparator();
|
||||||
this._addItem('edit', 'Renommer', () => this._renameItem(), isReadonly);
|
this._addItem('edit', 'Renommer', () => this._renameItem(), isReadonly);
|
||||||
this._addItem('trash-2', 'Supprimer', () => this._deleteDirectory(), isReadonly);
|
this._addItem('trash-2', 'Supprimer', () => this._deleteDirectory(), isReadonly);
|
||||||
} else if (type === 'file') {
|
} else if (type === 'file') {
|
||||||
@@ -1813,6 +1815,33 @@ export const ContextMenuManager = {
|
|||||||
} catch (err) { showToast("Erreur: " + err.message, "error"); }
|
} catch (err) { showToast("Erreur: " + err.message, "error"); }
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async _saveDirectorySearch() {
|
||||||
|
try {
|
||||||
|
var vault = this._targetVault || "all";
|
||||||
|
var dirPath = this._targetPath;
|
||||||
|
var dirName = dirPath.split("/").pop() || dirPath;
|
||||||
|
await api("/api/saved-searches", {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({
|
||||||
|
query: "",
|
||||||
|
vault: vault,
|
||||||
|
case_sensitive: false,
|
||||||
|
whole_word: false,
|
||||||
|
regex: false,
|
||||||
|
include_paths: dirPath + "/**",
|
||||||
|
exclude_paths: "",
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
showToast("Repertoire sauvegarde dans les recherches", "success");
|
||||||
|
// Switch to saved searches tab
|
||||||
|
var savedTab = document.getElementById("sidebar-tab-saved");
|
||||||
|
if (savedTab) savedTab.click();
|
||||||
|
// Reload saved searches
|
||||||
|
import('./viewer.js').then(function(m) { m.loadSavedSearches(); });
|
||||||
|
} catch (err) { showToast("Erreur: " + err.message, "error"); }
|
||||||
|
},
|
||||||
|
|
||||||
_openBackupViewer() {
|
_openBackupViewer() {
|
||||||
// Dynamically import the backup viewer module to avoid circular deps
|
// Dynamically import the backup viewer module to avoid circular deps
|
||||||
import('./backups.js').then(mod => {
|
import('./backups.js').then(mod => {
|
||||||
|
|||||||
@@ -1038,6 +1038,10 @@ export async function loadSavedSearches() {
|
|||||||
}
|
}
|
||||||
if (empty) empty.style.display = "none";
|
if (empty) empty.style.display = "none";
|
||||||
list.innerHTML = searches.map(s => {
|
list.innerHTML = searches.map(s => {
|
||||||
|
// Detect directory-based saved search (empty query + include_paths)
|
||||||
|
var isDirSearch = (!s.query || s.query.trim() === '') && s.include_paths;
|
||||||
|
var displayQuery = isDirSearch ? (s.include_paths || 'Dossier') : escapeHtml(s.query);
|
||||||
|
var dirIcon = isDirSearch ? '<i data-lucide="folder-search" style="width:14px;height:14px;margin-right:4px;color:var(--accent)"></i>' : '';
|
||||||
const badges = [];
|
const badges = [];
|
||||||
if (s.case_sensitive) badges.push('<span class="search-filter-badge">Aa</span>');
|
if (s.case_sensitive) badges.push('<span class="search-filter-badge">Aa</span>');
|
||||||
if (s.whole_word) badges.push('<span class="search-filter-badge">wd</span>');
|
if (s.whole_word) badges.push('<span class="search-filter-badge">wd</span>');
|
||||||
@@ -1047,8 +1051,8 @@ export async function loadSavedSearches() {
|
|||||||
if (s.exclude_paths) pathFilters.push(`<span class="saved-search-path" title="Exclure: ${escapeHtml(s.exclude_paths)}">📤 ${escapeHtml(s.exclude_paths)}</span>`);
|
if (s.exclude_paths) pathFilters.push(`<span class="saved-search-path" title="Exclure: ${escapeHtml(s.exclude_paths)}">📤 ${escapeHtml(s.exclude_paths)}</span>`);
|
||||||
const vaultStr = s.vault && s.vault !== "all" ? `<span class="saved-search-vault">📁 ${escapeHtml(s.vault)}</span>` : "";
|
const vaultStr = s.vault && s.vault !== "all" ? `<span class="saved-search-vault">📁 ${escapeHtml(s.vault)}</span>` : "";
|
||||||
return `
|
return `
|
||||||
<div class="saved-search-item">
|
<div class="saved-search-item${isDirSearch ? ' saved-search-dir' : ''}">
|
||||||
<div class="saved-search-query">${escapeHtml(s.query)}</div>
|
<div class="saved-search-query">${dirIcon}${displayQuery}</div>
|
||||||
<div class="saved-search-meta">
|
<div class="saved-search-meta">
|
||||||
${badges.join("")}
|
${badges.join("")}
|
||||||
${vaultStr}
|
${vaultStr}
|
||||||
|
|||||||
Reference in New Issue
Block a user