feat: implémenter modal confirmation actions bulk avec preview liste liens (ID + titre), styles dédiés (max-width 520px, list scrollable 320px, boutons colorés par action delete/public/private), synchronisation mode thème vers bookmark via fetch/POST formulaire, refactoring actions bulk (delete/visibility) avec URLs GET params au lieu de forms POST, ajout token shaarli dans includes.html, correction tag config bookmark (shaarit_config→themes), et support fermeture modal ESC/overlay-click
This commit is contained in:
+21
-6
@@ -655,12 +655,20 @@
|
||||
async function syncThemeToBookmark(themeId) {
|
||||
try {
|
||||
// We fetch the current config bookmark if any
|
||||
const res = await fetch(shaarli.basePath + '/?searchtags=shaarit_config');
|
||||
const res = await fetch(shaarli.basePath + '/?searchtags=themes');
|
||||
const text = await res.text();
|
||||
const parser = new DOMParser();
|
||||
const doc = parser.parseFromString(text, 'text/html');
|
||||
|
||||
let config = { version: 1, theme: themeId, collections: [] };
|
||||
// Get current mode from localStorage
|
||||
const currentMode = localStorage.getItem('theme') || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light');
|
||||
|
||||
let config = {
|
||||
version: 2,
|
||||
themes: THEMES,
|
||||
default: themeId,
|
||||
mode: currentMode
|
||||
};
|
||||
let editUrl = null;
|
||||
|
||||
// Find existing config
|
||||
@@ -670,7 +678,13 @@
|
||||
if (descEl) {
|
||||
try {
|
||||
const parsed = JSON.parse(descEl.textContent.trim());
|
||||
config = Object.assign({}, parsed, { theme: themeId });
|
||||
// Preserve existing themes list if it exists and is valid
|
||||
if (parsed.themes && Array.isArray(parsed.themes)) {
|
||||
config.themes = parsed.themes;
|
||||
}
|
||||
// Update default and mode
|
||||
config.default = themeId;
|
||||
config.mode = currentMode;
|
||||
} catch(e) {}
|
||||
}
|
||||
const editBtn = linkCard.querySelector('.link-action-edit');
|
||||
@@ -679,10 +693,11 @@
|
||||
|
||||
// Prepare form data
|
||||
const formData = new FormData();
|
||||
formData.append('lf_title', 'collections');
|
||||
formData.append('lf_url', 'https://shaarit.app/config/collections');
|
||||
formData.append('lf_tags', 'shaarit_config');
|
||||
formData.append('lf_title', 'themes');
|
||||
formData.append('lf_url', 'https://shaarit.app/config/themes');
|
||||
formData.append('lf_tags', 'themes');
|
||||
formData.append('lf_description', JSON.stringify(config));
|
||||
formData.append('lf_private', 'on'); // Private bookmark
|
||||
formData.append('save_edit', 'Save');
|
||||
|
||||
let token = '';
|
||||
|
||||
Reference in New Issue
Block a user