synchro du labo (0bf0da65) : app.blade.php, README.md

This commit is contained in:
cloudion
2026-11-03 22:41:28 +00:00
parent e229415ca6
commit bde40c2bad
2 changed files with 65 additions and 2 deletions

View File

@@ -1,3 +1,21 @@
# ploxion-documents # 📄 Documents
PLOXION · Les documents de la zone : bail, état des lieux, contrats, assurances, garanties, manuels, factures — fiche + photo + fichier sur le boxion, échéances qui deviennent des tâches. Module civ, par zone. · fournit: documents, bail, garanties, archives, zone Les documents de la zone : bail, état des lieux, contrats, assurances, garanties, manuels, factures — fiche + photo + fichier sur le boxion, échéances qui deviennent des tâches. Module civ, par zone.
| | |
| --- | --- |
| id | `documents` |
| fournit | `documents` `bail` `garanties` `archives` `zone` |
| bions qu'il nomme | `jOSApps` `jOSBoxion` `jOSCiv` `jOSStore` `jOSZone` |
| fichiers | `app.blade.php` |
| dans le labo | `resources/views/ploxions/documents/` (dépôt `my_website2`) |
## Contribuer
- **Dans le xer** : https://labo.j0bot.ch/px/atelier?ploxion=documents — prends-le, modifie-le, vois-le tourner, « ⧗ envoyer le tsoin ».
- **Dans VS Code** : `xb prendre documents` (ou l'extension xerboxion › ⇩ Prendre), puis ⧗ Envoyer.
- Le chemin complet : https://labo.j0bot.ch/px/contribuer
Ce dépôt est un **miroir** du labo (synchronisé par `bin/ploxions-forge.mjs`, depuis le commit `0bf0da65`) : une modif se propose par un tsoin ou une branche du labo, pas directement ici.
© 2026 chill-tekk · ne pas nuire

45
app.blade.php Normal file
View File

@@ -0,0 +1,45 @@
{{-- PL0XI0N documents 📄 — LES DOCUMENTS de la zone (module civ, vague 2 appart) : bail, état des lieux, contrats,
garanties, manuels, factures. Par zone : la FICHE vit dans jOSStore zone:<id>:documents (titre, type, dates
signature/échéance, référence, notes, miniature) ; le FICHIER va sur le boxion via jOSBoxion.uploadFile (catégorie
'documents') ou reste une photo réduite (natif : jOSiOS.capture / jOSiOS.files). Échéances → tâches en un tap.
describe() = nombre + échéances proches. --}}
<script>
(function () {
var ID = 'documents';
var TYPES = [['bail', '📜 bail'], ['edl', '🔍 état des lieux'], ['contrat', '🧾 contrat (élec, internet…)'], ['assurance', '🛡️ assurance'], ['garantie', '🧰 garantie / ticket'], ['manuel', '📘 manuel'], ['facture', '💳 facture'], ['identite', '🪪 identité / admin'], ['autre', '📄 autre']];
function mount(container, ctx) {
var C = window.jOSCiv, U = C && C.ui; if (!C) { container.innerHTML = '<div style="padding:20px">cœur civ absent</div>'; return { unmount: function () { container.innerHTML = ''; } }; }
U.style(); container.classList.add('cv'); container.style.position = 'relative';
var Z = (ctx && ctx.zone && jOSZone.get(ctx.zone.id)) || jOSZone.current(); if (!Z) { container.innerHTML = '<div class="cv__empty">aucune zone — ouvre 🫧 zone</div>'; return { unmount: function () { container.innerHTML = ''; } }; }
var S = jOSStore('zone:' + Z.id + ':documents'), tab = 'tous', offS = null, pendingPhoto = null;
function all() { return S.all().filter(function (d) { return d && d.id; }).sort(function (a, b) { return (b.m || 0) - (a.m || 0); }); }
function label(t) { var x = TYPES.filter(function (y) { return y[0] === t; })[0]; return x ? x[1] : t; }
function row(d) { var ech = d.echeance ? U.dans(d.echeance) : ''; var soon = d.echeance && U.days(U.parse(d.echeance), U.today()) <= 30; return '<div class="cv__row ' + (soon ? 'u2' : '') + '" data-id="' + d.id + '"><span class="ic">' + (d.photo ? '<img src="' + d.photo + '" style="width:30px;height:30px;object-fit:cover;border-radius:6px">' : label(d.type).slice(0, 2)) + '</span><div class="tx"><b>' + U.esc(d.titre) + '</b><small>' + U.esc([label(d.type).slice(3), d.ref, d.signe ? 'signé ' + U.dateFr(d.signe) : '', ech ? 'échéance ' + ech : '', d.fichier ? '📎 boxion' : ''].filter(Boolean).join(' · ')) + '</small></div>' + (d.fichier && d.fichier.url ? '<a class="cv__btn" href="' + U.esc(d.fichier.url) + '" target="_blank" rel="noopener" data-open-file>↗</a>' : '') + '</div>'; }
function render() {
var list = all().filter(function (d) { return tab === 'tous' || d.type === tab; });
var h = U.zoneHd(Z, 'Documents', '📄') + '<div class="cv__tabs"><button data-tab="tous" class="' + (tab === 'tous' ? 'on' : '') + '">tous (' + all().length + ')</button>' + TYPES.filter(function (t) { return all().some(function (d) { return d.type === t[0]; }); }).map(function (t) { return '<button data-tab="' + t[0] + '" class="' + (tab === t[0] ? 'on' : '') + '">' + t[1] + '</button>'; }).join('') + '</div><div class="cv__bd">';
var ech = all().filter(function (d) { return d.echeance && U.days(U.parse(d.echeance), U.today()) <= 60; }).sort(function (a, b) { return a.echeance < b.echeance ? -1 : 1; });
if (tab === 'tous' && ech.length) h += '<div class="cv__sec"><span>échéances (60 j)</span><span>' + ech.length + '</span></div>' + ech.map(row).join('') + '<div class="cv__sec"><span>tout</span></div>';
h += list.map(row).join('') || '<div class="cv__empty">Aucun document. Commence par le bail et l\'état des lieux d\'entrée : photos + dates. Les fichiers vont sur ton boxion.</div>';
h += '</div><button class="cv__fab" data-add>+</button>'; container.innerHTML = h;
}
function form(d) {
U.form(container, d ? 'Document' : 'Nouveau document', [{ k: 'titre', label: 'titre', val: d ? d.titre : '' }, { k: 'type', label: 'type', type: 'chips', opts: TYPES.map(function (t) { return { v: t[0], l: t[1] }; }), val: d ? d.type : 'bail' }, { k: 'ref', label: 'référence / n° de contrat', val: d ? d.ref : '' }, { k: 'signe', label: 'signé le', type: 'date', val: d ? d.signe || '' : '' }, { k: 'echeance', label: 'échéance / fin (garantie, résiliation…)', type: 'date', val: d ? d.echeance || '' : '' }, { k: 'notes', label: 'notes', type: 'textarea', val: d ? d.notes : '' }],
function (v) { var it = Object.assign({ id: d ? d.id : 'd' + Date.now().toString(36), m: Date.now(), photo: d ? d.photo : pendingPhoto, fichier: d ? d.fichier : null }, v); if (d) S.set(d.id, it); else S.upsert(function (x) { return x.id === it.id; }, it); pendingPhoto = null; render(); },
'<div style="margin-top:8px;display:flex;gap:6px;flex-wrap:wrap">' + (window.jOSiOS && jOSiOS.capture ? '<button type="button" class="cv__btn" data-photo>📷 photo</button>' : '') + '<label class="cv__btn" style="cursor:pointer">📎 fichier <input type="file" data-file style="display:none" accept="image/*,application/pdf"></label><span data-st style="font-size:.75rem;color:#8aa0c0;align-self:center"></span></div>' + (d && d.echeance ? '<div style="margin-top:8px"><button type="button" class="cv__btn" data-tache>☑️ créer la tâche « échéance »</button></div>' : '') + (d ? '<div style="margin-top:8px"><button type="button" class="cv__btn" data-del>🗑 supprimer</button></div>' : ''));
function thumb(file, cb) { var r = new FileReader(); r.onload = function () { if (!/^image\//.test(file.type)) { cb(null); return; } var img = new Image(); img.onload = function () { var c = document.createElement('canvas'), s = Math.min(1, 320 / Math.max(img.width, img.height)); c.width = img.width * s; c.height = img.height * s; c.getContext('2d').drawImage(img, 0, 0, c.width, c.height); cb(c.toDataURL('image/jpeg', 0.6)); }; img.src = r.result; }; r.readAsDataURL(file); }
function upload(file, st) { thumb(file, function (data) { if (data) { if (d) S.set(d.id, { photo: data }); else pendingPhoto = data; } if (st) st.textContent = '⧗ envoi…'; try { if (window.jOSBoxion && jOSBoxion.authed && jOSBoxion.authed() && jOSBoxion.uploadFile) { jOSBoxion.uploadFile(file, 'documents', file.name).then(function (it) { if (st) st.textContent = it ? '✓ sur le boxion' : '✓ photo gardée (boxion indispo)'; if (it && d) S.set(d.id, { fichier: it }); else if (it) pendingFile = it; }); } else if (st) st.textContent = '✓ photo gardée (connecte-toi pour envoyer le fichier)'; } catch (e) { if (st) st.textContent = '✓ photo gardée'; } }); }
var pendingFile = null;
var ph = container.querySelector('[data-photo]'); if (ph) ph.addEventListener('click', function () { jOSiOS.capture({}).then(function (f) { if (f) upload(f, container.querySelector('[data-st]')); }); });
var fi = container.querySelector('[data-file]'); if (fi) fi.addEventListener('change', function () { if (fi.files && fi.files[0]) upload(fi.files[0], container.querySelector('[data-st]')); });
var tk = container.querySelector('[data-tache]'); if (tk && d) tk.addEventListener('click', function () { try { C.taches(Z).add({ titre: 'Échéance : ' + d.titre, type: 'tache', due: d.echeance, cat: 'admin', rappel: 1440, notes: d.ref || '' }); tk.textContent = '✓ tâche créée'; } catch (e) {} });
var del = container.querySelector('[data-del]'); if (del && d) del.addEventListener('click', function () { S.remove(d.id); container.querySelector('.cv__form').remove(); render(); });
}
container.addEventListener('click', function (e) { var b; if ((b = e.target.closest('[data-tab]'))) { tab = b.getAttribute('data-tab'); render(); return; } if (e.target.closest('[data-open-file]')) return; if (e.target.closest('[data-add]')) { form(null); return; } var r = e.target.closest('[data-id]'); if (r) form(S.get(r.getAttribute('data-id'))); });
render(); offS = S.on(function () { render(); });
return { unmount: function () { try { offS(); } catch (e) {} container.classList.remove('cv'); container.innerHTML = ''; } };
}
function describe() { var Z = window.jOSZone && jOSZone.current(); if (!Z || !window.jOSStore || !window.jOSCiv) return null; var U = jOSCiv.ui, S = jOSStore('zone:' + Z.id + ':documents'), all = S.all(), ech = all.filter(function (d) { return d.echeance && U.days(U.parse(d.echeance), U.today()) <= 60; }); return { v: 1, id: ID, title: 'Documents', icon: '📄', items: [{ p: 1, kind: 'stat', label: 'documents', value: all.length }, { p: 2, kind: 'list', label: 'échéances', items: ech.slice(0, 7).map(function (d) { return { label: d.titre, value: U.dans(d.echeance) }; }) }] }; }
window.jOSApps = window.jOSApps || {}; window.jOSApps[ID] = { manifest: { id: ID, name: 'Documents', icon: '📄' }, mount: mount, describe: describe };
})();
</script>