Phase 7: the client link
Staff make a link for a person (or "+ New client": a record with only the name they know, and its link); the client fills in their own record from their phone without a login, and presses Send. - Links (src/links.rs, migrations/0006): the table keeps the SHA-256 of the token only, as sessions do; the link is shown once, to copy, to email (mailto with the person's address) or as a QR code (qrcode crate, inline SVG). It is open 14 days, until Send, or until staff close it; a new link closes the earlier one. States open, opened, sent, closed, expired. - The client's pages at /c/<token> (src/web/client.rs, client_*.html in a frame of their own, phone first): About you, Passport (the photo reader; a zone fills in the personal details still empty), Address in Thailand, Contact, Documents, Send. Each part is saved on its own, straight into the record. Forms carry the link's own token plus the same-site check. A passport with the same number is changed; an address unlike the current one is added beside it, so the current one and its TM.30 receipt stay; a second save changes what the link added. Uploads (passport page, photo, visa, arrival stamp, TDAC, work permit, other) go through the same checks and encrypted store as staff uploads, tied to the person's newest record of their kind. - Audit: the client's views and changes carry the actor `link <id>`; actions send and close and entity link are new. The person's page shows the newest links, when they were opened and sent, and each record the client changed, with the fields, to check. - Demo data: Erika sent her link an hour ago (phone and email changed), Jane opened hers. - documents::read_upload returns why it refused, so the client's pages answer in their own words. Checks: fmt, clippy; 101 unit and 54 integration tests (tests/client.rs: the link shown once and kept as a hash, a new client, the whole client flow with the login on, forged, closed, expired and made-up links); layout check light/dark desk/phone on the client pages, the person page and the new client form: no problems; the camera reader on the client's passport page with a fake camera filled the form and Send closed the link.
This commit is contained in:
1 parent
a6ebdfc89c
commit
43ed75d81b
32 files changed
+2706
-40
No files matched your search
+112
@@ -1389,3 +1389,115 @@ textarea.mrz {
|
||||
gap: 12px;
|
||||
padding: 16px 16px max(16px, env(safe-area-inset-bottom));
|
||||
}
|
||||
|
||||
/* ---- the client link: the card on a person's page and the page that
|
||||
shows a new link once */
|
||||
.chip.plain {
|
||||
background: var(--panel2);
|
||||
color: var(--mute);
|
||||
}
|
||||
.changes {
|
||||
margin: 0;
|
||||
padding-left: 18px;
|
||||
}
|
||||
.linkrow {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
margin: 12px 0;
|
||||
}
|
||||
.linkrow input {
|
||||
flex: 1 1 280px;
|
||||
font-family: var(--mono);
|
||||
font-size: 13px;
|
||||
}
|
||||
.qr {
|
||||
width: 240px;
|
||||
max-width: 100%;
|
||||
padding: 10px;
|
||||
margin: 4px 0 14px;
|
||||
background: #ffffff;
|
||||
border-radius: 8px;
|
||||
}
|
||||
.qr svg {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
|
||||
/* ---- the client's pages (/c/<token>): one column, phone first */
|
||||
.cmain {
|
||||
max-width: 680px;
|
||||
margin: 0 auto;
|
||||
padding: 20px 16px 40px;
|
||||
}
|
||||
.cmain .card {
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
.chead {
|
||||
margin: 4px 0 8px;
|
||||
}
|
||||
.lead2 {
|
||||
margin: 0 0 16px;
|
||||
color: var(--mute);
|
||||
}
|
||||
.parts {
|
||||
list-style: none;
|
||||
margin: 0 0 16px;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
}
|
||||
.part {
|
||||
display: grid;
|
||||
grid-template-columns: 32px minmax(0, 1fr) auto;
|
||||
align-items: center;
|
||||
gap: 6px 12px;
|
||||
padding: 14px;
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 10px;
|
||||
background: var(--panel);
|
||||
color: var(--fg);
|
||||
text-decoration: none;
|
||||
}
|
||||
.part:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
.pmark {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 50%;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
font-weight: 700;
|
||||
background: var(--panel2);
|
||||
color: var(--hd);
|
||||
}
|
||||
.part.done .pmark {
|
||||
background: var(--ok-s);
|
||||
color: var(--ok);
|
||||
}
|
||||
.pbody {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
/* on phones the state goes under the text */
|
||||
@media (max-width: 520px) {
|
||||
.part {
|
||||
grid-template-columns: 32px minmax(0, 1fr);
|
||||
align-items: start;
|
||||
}
|
||||
.part .chip {
|
||||
grid-column: 2;
|
||||
justify-self: start;
|
||||
}
|
||||
}
|
||||
.sendcard h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
.cmain .upload .field {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.cmain .upload .drop {
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
@@ -18,6 +18,32 @@
|
||||
}
|
||||
});
|
||||
|
||||
// ---- a button with data-copy="#input" copies that input's text (the
|
||||
// client link); a field with data-select-all selects itself when focused
|
||||
document.addEventListener("click", function (ev) {
|
||||
var b = ev.target.closest && ev.target.closest("[data-copy]");
|
||||
if (!b) return;
|
||||
var input = document.querySelector(b.getAttribute("data-copy"));
|
||||
if (!input) return;
|
||||
input.select();
|
||||
var done = function () {
|
||||
b.textContent = "Copied";
|
||||
};
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
navigator.clipboard.writeText(input.value).then(done, function () {
|
||||
document.execCommand("copy");
|
||||
done();
|
||||
});
|
||||
} else {
|
||||
document.execCommand("copy");
|
||||
done();
|
||||
}
|
||||
});
|
||||
document.addEventListener("focusin", function (ev) {
|
||||
var t = ev.target;
|
||||
if (t && t.hasAttribute && t.hasAttribute("data-select-all")) t.select();
|
||||
});
|
||||
|
||||
// ---- forms with data-confirm ask first (archive, delete)
|
||||
document.addEventListener("submit", function (ev) {
|
||||
var f = ev.target;
|
||||
|
||||
Reference in new issue
Block a user