Simplify tags: free text only, no categories
Remove type system (ambiance/epoque/rythme/genre/theme). Tags are now plain strings. Old format auto-migrated. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+7
-7
@@ -1074,19 +1074,19 @@ function setupEditable(elId, section) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ── Tags ──
|
// ── Tags ──
|
||||||
const TAG_TYPES = ['ambiance', 'epoque', 'rythme', 'genre', 'theme'];
|
|
||||||
|
|
||||||
function renderTags() {
|
function renderTags() {
|
||||||
const container = document.getElementById('v-tags');
|
const container = document.getElementById('v-tags');
|
||||||
const row = visionData['tags'];
|
const row = visionData['tags'];
|
||||||
let tags = [];
|
let tags = [];
|
||||||
try { tags = JSON.parse(row?.Contenu || '[]'); } catch { tags = []; }
|
try { tags = JSON.parse(row?.Contenu || '[]'); } catch { tags = []; }
|
||||||
|
// Normalize: old format {label, type} → just strings
|
||||||
|
tags = tags.map(t => typeof t === 'string' ? t : t.label || '');
|
||||||
|
|
||||||
container.innerHTML = '';
|
container.innerHTML = '';
|
||||||
tags.forEach((t, i) => {
|
tags.forEach((label, i) => {
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
span.className = `tag ${t.type || 'ambiance'}`;
|
span.className = 'tag ambiance';
|
||||||
span.innerHTML = `${esc(t.label)}<span class="tag-remove" onclick="removeTag(${i})">×</span>`;
|
span.innerHTML = `${esc(label)}<span class="tag-remove" onclick="removeTag(${i})">×</span>`;
|
||||||
container.appendChild(span);
|
container.appendChild(span);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1096,8 +1096,7 @@ function renderTags() {
|
|||||||
addBtn.onclick = () => {
|
addBtn.onclick = () => {
|
||||||
const label = prompt('Nouveau tag :');
|
const label = prompt('Nouveau tag :');
|
||||||
if (!label) return;
|
if (!label) return;
|
||||||
const type = prompt('Type (ambiance, epoque, rythme, genre, theme) :', 'genre') || 'genre';
|
tags.push(label);
|
||||||
tags.push({ label, type });
|
|
||||||
saveVisionSection('tags', JSON.stringify(tags));
|
saveVisionSection('tags', JSON.stringify(tags));
|
||||||
renderTags();
|
renderTags();
|
||||||
};
|
};
|
||||||
@@ -1108,6 +1107,7 @@ function removeTag(index) {
|
|||||||
const row = visionData['tags'];
|
const row = visionData['tags'];
|
||||||
let tags = [];
|
let tags = [];
|
||||||
try { tags = JSON.parse(row?.Contenu || '[]'); } catch { return; }
|
try { tags = JSON.parse(row?.Contenu || '[]'); } catch { return; }
|
||||||
|
tags = tags.map(t => typeof t === 'string' ? t : t.label || '');
|
||||||
tags.splice(index, 1);
|
tags.splice(index, 1);
|
||||||
saveVisionSection('tags', JSON.stringify(tags));
|
saveVisionSection('tags', JSON.stringify(tags));
|
||||||
renderTags();
|
renderTags();
|
||||||
|
|||||||
Reference in New Issue
Block a user