feat: définitions des catégories, suivi par conversation, lien marchés RLA, sauvegarde autonome
Définition de chaque catégorie écrite par Nabil (écran Catégories), lue par l'IA ; suivi découpé par clé Thread-Index pour les objets partagés (lue en arrière-plan, gardée en base) ; fiches des marchés RLA (table 1048, lecture seule) affichées depuis les références AO et numéros de PO ; sauvegarde quotidienne en un seul fichier, copiée chaque nuit vers le NAS. 199 tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XGaEeTZLvHXfYPUNWkgYoi
This commit is contained in:
1 parent
b8b08843d4
commit
14fb06deb3
13 files changed
+353
-15
No files matched your search
+27
-5
@@ -108,7 +108,7 @@
|
||||
}
|
||||
function chargerCats() {
|
||||
return api('/categories').then(function (r) {
|
||||
var l = (r.categories || []).map(function (c) { return { id: c.id, nom: c.name, couleur: c.couleur }; });
|
||||
var l = (r.categories || []).map(function (c) { return { id: c.id, nom: c.name, couleur: c.couleur, definition: c.definition || '', defIA: c.definition_ia || '' }; });
|
||||
l.sort(function (a, b) { return (a.nom === SYSTEME) - (b.nom === SYSTEME) || a.id - b.id; });
|
||||
S.cats = l;
|
||||
});
|
||||
@@ -234,13 +234,17 @@
|
||||
ouvrir(function (clore) {
|
||||
var champ = h('input', { id: 'cat-nom', type: 'text', maxlength: '100', 'data-focus': '', autocomplete: 'off', value: cat ? cat.nom : '' });
|
||||
if (systeme) { champ.setAttribute('readonly', ''); }
|
||||
var def = h('textarea', { id: 'cat-def', rows: '3', maxlength: '400', class: 'champ-def', placeholder: 'Par exemple : mails sur les ruptures et écarts de stock dans les magasins de la région' });
|
||||
def.value = cat ? (cat.definition || cat.defIA || '') : '';
|
||||
var err = h('div', { class: 'err', role: 'alert' });
|
||||
function enregistrer() {
|
||||
var nom = champ.value.trim();
|
||||
if (!nom) { err.textContent = 'Saisissez un nom de catégorie.'; champ.focus(); return; }
|
||||
if (S.cats.some(function (c) { return c.nom.toLowerCase() === nom.toLowerCase() && (!cat || c.id !== cat.id); })) { err.textContent = 'Cette catégorie existe déjà.'; champ.focus(); return; }
|
||||
var req = nouveau ? api('/categories', { method: 'POST', body: { name: nom } }) : api('/categories/' + cat.id, { method: 'PUT', body: { name: nom } });
|
||||
req.then(function () { clore(); return chargerMails(); }).then(function () { flash(nouveau ? 'Catégorie ajoutée.' : 'Catégorie renommée.'); })
|
||||
var texte = def.value.trim(), avant = cat ? (cat.definition || cat.defIA || '') : '';
|
||||
var req = (nouveau ? api('/categories', { method: 'POST', body: { name: nom } }) : (nom !== cat.nom ? api('/categories/' + cat.id, { method: 'PUT', body: { name: nom } }) : Promise.resolve(cat)))
|
||||
.then(function (c) { var id = (c && c.id) || (cat && cat.id); return texte !== avant && id ? api('/categories/' + id + '/definition', { method: 'PUT', body: { definition: texte } }) : null; });
|
||||
req.then(function () { clore(); return chargerMails(); }).then(function () { flash(nouveau ? 'Catégorie ajoutée.' : 'Catégorie enregistrée.'); })
|
||||
.catch(function (e) { if (e.message !== 'session') err.textContent = 'Enregistrement impossible. Réessayez.'; });
|
||||
}
|
||||
champ.addEventListener('keydown', function (e) { if (e.key === 'Enter' && !systeme) { e.preventDefault(); enregistrer(); } });
|
||||
@@ -251,7 +255,10 @@
|
||||
return h('section', { class: 'boite', role: 'dialog', 'aria-modal': 'true', 'aria-labelledby': 'dlg-t' },
|
||||
h('h2', { id: 'dlg-t' }, nouveau ? 'Nouvelle catégorie' : systeme ? SYSTEME : 'Modifier la catégorie'),
|
||||
systeme ? h('p', null, '« À classer » reçoit les mails qu\'aucune règle ne reconnaît. Elle ne peut être ni renommée ni supprimée.') : null,
|
||||
h('div', { class: 'champ' }, h('label', { for: 'cat-nom' }, 'Nom'), champ, err), acts, pied);
|
||||
h('div', { class: 'champ' }, h('label', { for: 'cat-nom' }, 'Nom'), champ),
|
||||
systeme ? null : h('div', { class: 'champ' }, h('label', { for: 'cat-def' }, 'Ce que contient cette catégorie'), def,
|
||||
h('p', { class: 'lect-ia-info', text: 'L\'IA lit cette phrase pour vous proposer un classement. Décrivez le contenu des mails, pas des mots-clés : rien n\'est classé sans votre validation.' })),
|
||||
err, acts, pied);
|
||||
});
|
||||
}
|
||||
function dialogueSuppression(cat) {
|
||||
@@ -498,6 +505,7 @@
|
||||
cadre.appendChild(champ); cadre.appendChild(bt); cadre.appendChild(msg);
|
||||
return cadre;
|
||||
}
|
||||
function dateFr(iso) { var x = /^(\d{4})-(\d{2})-(\d{2})/.exec(iso || ''); return x ? x[3] + '/' + x[2] + '/' + x[1] : (iso || ''); }
|
||||
function blocIA(m, r) {
|
||||
var id = r.message_id || m.id;
|
||||
var sect = h('section', { class: 'lect-ia', 'aria-label': 'Analyse IA' });
|
||||
@@ -515,6 +523,19 @@
|
||||
});
|
||||
sect.appendChild(lr);
|
||||
}
|
||||
var zoneRla = h('div', { class: 'lect-rla' });
|
||||
sect.appendChild(zoneRla);
|
||||
var texteRla = ((m.objet || r.objet || '') + ' ' + (f.resume || '') + ' ' + String(r.corps || '').slice(0, 4000)).slice(0, 5900);
|
||||
if (/\b(AO|AOI|march)|\d{7}/i.test(texteRla)) {
|
||||
api('/rla?texte=' + encodeURIComponent(texteRla)).then(function (x) {
|
||||
(x.marches || []).forEach(function (k) {
|
||||
var etat = k.actif ? 'actif' : 'clos';
|
||||
var det = [k.entrepreneur, k.region, k.projet, k.annee, k.fin_marche ? 'fin ' + dateFr(k.fin_marche) : '', k.taux_fin ? 'avancement financier ' + String(k.taux_fin).replace('.', ',') + ' %' : '', k.taux_phy ? 'physique ' + String(k.taux_phy).replace('.', ',') + ' %' : ''].filter(Boolean).join(' · ');
|
||||
zoneRla.appendChild(h('div', { class: 'carte-rla' }, h('p', null, h('strong', { text: 'Marché RLA ' + k.marche }), h('span', { class: 'etiq ' + (k.actif ? 'active' : 'propose'), text: etat })),
|
||||
h('p', { class: 'lect-ia-info', text: det }), k.note ? h('p', { class: 'lect-ia-info', text: k.note }) : null));
|
||||
});
|
||||
}).catch(function () { /* Baserow injoignable : rien n'est affiché */ });
|
||||
}
|
||||
var cat = h('p', null, 'Catégorie proposée : ', h('strong', { text: f.categorie }), ' · confiance ' + f.confiance + ' ');
|
||||
if (f.categorie !== m.cat && f.categorie !== 'À classer') cat.appendChild(h('button', { type: 'button', class: 'btn-ligne', onclick: function () { corriger(m, f.categorie); flash('Catégorie appliquée.'); } }, 'Appliquer'));
|
||||
sect.appendChild(cat);
|
||||
@@ -741,7 +762,8 @@
|
||||
var compte = {}; S.mails.forEach(function (m) { compte[m.cat] = (compte[m.cat] || 0) + 1; });
|
||||
var carte = h('section', { class: 'carte limite', 'aria-label': 'Catégories' });
|
||||
S.cats.forEach(function (c) {
|
||||
carte.appendChild(h('div', { class: 'rang' }, pastille(couleur(c.nom, c.id)), h('span', { class: 'nom', text: c.nom }),
|
||||
carte.appendChild(h('div', { class: 'rang' }, pastille(couleur(c.nom, c.id)), h('span', { class: 'nom' }, c.nom,
|
||||
c.nom !== SYSTEME && !c.defIA ? h('small', { class: 'a-definir', text: ' · définition à écrire' }) : null),
|
||||
h('span', { class: 'nb' }, h('b', { text: d2(compte[c.nom] || 0) }), ' ce jour'),
|
||||
h('button', { type: 'button', class: 'btn-petit', 'aria-label': (c.nom === SYSTEME ? 'Détails de ' : 'Modifier ') + c.nom, onclick: function () { dialogueCategorie(c); } }, c.nom === SYSTEME ? 'Détails' : 'Modifier')));
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user