Agreements the client signs on the link (task 7.6)
Built into the app rather than a separate signing service: any number of agreements (the processing of the client's data first, legal services and consultations later), each in versions whose text never changes. - Staff (Agreements in the sidebar, src/web/agreements.rs): paste the lawyers' text (empty line = paragraph, "# " heading, "- " list item), preview it as the client reads it, publish version 1; a changed text is the next version, the same text again is refused, and the database refuses any change to a published one (migrations/0007, trigger). Switch an agreement off and links stop asking for it. - Client: every active agreement is the first step of every link. The client reads it, ticks that they accept, types their name and signs with a finger or the mouse (static/signature.js; a PNG of the pad). A text changed while they read it is refused. A new version is asked for again at the next link. - The signed copy (src/agreements/pdf.rs, Sarabun so Thai prints, long Thai words cut without parting marks from their letter): the text, the name, the record, the time, the drawing, the link, the forwarded address, the browser and the text's SHA-256; kept as the person's encrypted document of kind "agreement", all in one transaction with the signature and the audit rows (actor link N). - The person's page shows each agreement's state (signed, not signed, to sign again) and every signed copy. - Phones: the section row now scrolls sideways instead of wrapping, so it keeps one height with five sections and Sign out. - Demo data: an invented agreement with a Thai paragraph. Checks: fmt, clippy; 105 unit and 56 integration tests (tests/agreements.rs: versions that never change, signing with a drawing, address and browser recorded, the PDF, signing again after a change, a stale version refused, switched off); layout check light/dark desk/phone on the agreement pages, the client's agreement page, the person page and the people list: no problems; a drawn signature in Edge at 390x844 signed and printed.
This commit is contained in:
1 parent
43ed75d81b
commit
d0e13dffd2
28 files changed
+2469
-57
No files matched your search
@@ -0,0 +1,15 @@
|
||||
{#- An agreement's text, in its blocks: headings, paragraphs and list
|
||||
items, as `agreements::blocks` reads them. -#}
|
||||
{% macro text(blocks) -%}
|
||||
<div class="agtext">
|
||||
{%- set ns = namespace(open=false) %}
|
||||
{%- for b in blocks %}
|
||||
{%- if b.kind == "item" and not ns.open %}<ul>{% set ns.open = true %}{% endif %}
|
||||
{%- if b.kind != "item" and ns.open %}</ul>{% set ns.open = false %}{% endif %}
|
||||
{%- if b.kind == "heading" %}<h3>{{ b.text }}</h3>
|
||||
{%- elif b.kind == "item" %}<li>{{ b.text }}</li>
|
||||
{%- else %}<p>{{ b.text }}</p>{% endif %}
|
||||
{%- endfor %}
|
||||
{%- if ns.open %}</ul>{% endif %}
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
@@ -0,0 +1,51 @@
|
||||
{% extends "base.html" %}
|
||||
{% import "_fields.html" as fm %}
|
||||
{% import "_agreement_text.html" as ag %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="/agreements">Agreements</a></div>
|
||||
<div class="pagehead">
|
||||
<h1>{{ a.title }}</h1>
|
||||
<div class="actions">
|
||||
<form method="post" action="/agreements/{{ a.id }}/active" class="inline-form"{% if a.active %} data-confirm="Switch this agreement off? Client links stop asking for it; signed copies stay."{% endif %}>
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<input type="hidden" name="active" value="{% if a.active %}0{% else %}1{% endif %}">
|
||||
<button type="submit" class="btn sm ghost">{% if a.active %}Switch off{% else %}Switch on{% endif %}</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<p class="meta">{% if a.active %}<span class="chip ok">asked for</span> Every client link asks for version {{ current }}.{% else %}<span class="chip plain">switched off</span> Client links do not ask for it.{% endif %}</p>
|
||||
<div class="cols agcols">
|
||||
<section class="card" id="text">
|
||||
<header><h2>Version {{ shown }}{% if shown != current %} <span class="chip plain">earlier</span>{% endif %}</h2></header>
|
||||
{{ ag.text(blocks) }}
|
||||
</section>
|
||||
<section class="card" id="versions">
|
||||
<header><h2>Versions</h2></header>
|
||||
{% for v in versions %}
|
||||
<div class="item{% if v.version != shown %} old{% endif %}">
|
||||
<div class="row"><a class="strong" href="/agreements/{{ a.id }}/versions/{{ v.version }}">Version {{ v.version }}</a>{% if v.version == current %}<span class="tag">current</span>{% endif %}<span class="muted small">{{ v.signed }} signed</span></div>
|
||||
<div class="muted small">published {{ v.published }} by {{ v.by }}</div>
|
||||
<div class="muted small mono fname" title="SHA-256 of the text">{{ v.sha256 }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</section>
|
||||
</div>
|
||||
<form method="post" action="/agreements/{{ a.id }}/versions" class="form" id="publish-form">
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<section class="card">
|
||||
<header><h2>A new version</h2></header>
|
||||
<p class="hint lead">Change the text below and publish it as version {{ current + 1 }}. Clients who signed an earlier version sign again at their next link. A published text can never be changed.</p>
|
||||
{{ fm.area("body", "Text", draft, err=errors.body, rows=16, fcls="wide") }}
|
||||
<div class="formactions">
|
||||
<button type="submit" name="action" value="preview" class="btn" formnovalidate>Preview</button>
|
||||
<button type="submit" name="action" value="publish" class="btn pri" id="publish">Publish version {{ current + 1 }}</button>
|
||||
</div>
|
||||
</section>
|
||||
</form>
|
||||
{% if is_preview %}
|
||||
<section class="card" id="preview">
|
||||
<header><h2>The new text as the client reads it</h2></header>
|
||||
{{ ag.text(preview) }}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,28 @@
|
||||
{% extends "base.html" %}
|
||||
{% import "_fields.html" as fm %}
|
||||
{% import "_agreement_text.html" as ag %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="/agreements">Agreements</a></div>
|
||||
<div class="pagehead"><h1>New agreement</h1></div>
|
||||
<form method="post" action="/agreements" class="form" id="agreement-form">
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<section class="card">
|
||||
<div class="grid">
|
||||
{{ fm.text("title", "Title", d.title, err=errors.title, req=true, cls="wide", hint="As the client sees it, for example: How B4L processes your personal data.") }}
|
||||
{{ fm.area("body", "Text", d.body, err=errors.body, rows=18, fcls="wide", hint="Paste it as legal wrote it. An empty line starts a new paragraph, # and a space a heading, - and a space a list item.") }}
|
||||
</div>
|
||||
</section>
|
||||
<div class="formactions">
|
||||
<button type="submit" name="action" value="preview" class="btn" formnovalidate>Preview</button>
|
||||
<button type="submit" name="action" value="publish" class="btn pri" id="save">Publish version 1</button>
|
||||
<a class="btn ghost" href="/agreements">Cancel</a>
|
||||
</div>
|
||||
<p class="hint">A published text can never be changed, only followed by a new version.</p>
|
||||
</form>
|
||||
{% if d.body %}
|
||||
<section class="card" id="preview">
|
||||
<header><h2>As the client reads it</h2></header>
|
||||
{{ ag.text(preview) }}
|
||||
</section>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -0,0 +1,27 @@
|
||||
{% extends "base.html" %}
|
||||
{% block main %}
|
||||
<div class="pagehead">
|
||||
<h1>Agreements</h1>
|
||||
<div class="actions"><a class="btn pri" href="/agreements/new" id="new-agreement">+ New agreement</a></div>
|
||||
</div>
|
||||
<p class="lead2">What clients sign through their link: every active agreement is asked for, in its current version. A published text never changes; a new version is signed again at the client's next link.</p>
|
||||
{% if rows %}
|
||||
<div class="tblwrap">
|
||||
<table class="tbl" id="agreement-list">
|
||||
<thead><tr><th>Agreement</th><th>Current version</th><th>Signed</th><th><span class="vh">State</span></th></tr></thead>
|
||||
<tbody>
|
||||
{% for r in rows %}
|
||||
<tr>
|
||||
<td><a class="strong" href="/agreements/{{ r.id }}">{{ r.title }}</a></td>
|
||||
<td>{{ r.version }}, {{ r.published }}</td>
|
||||
<td>{{ r.signed }}</td>
|
||||
<td>{% if r.active %}<span class="chip ok">asked for</span>{% else %}<span class="chip plain">switched off</span>{% endif %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="card"><p class="empty-inline">No agreement yet. Once one is added, every client link asks the client to read and sign it.</p></div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -24,6 +24,7 @@
|
||||
<a href="/"{% if nav == "deadlines" %} class="on" aria-current="page"{% endif %}>Deadlines</a>
|
||||
<a href="/people"{% if nav == "people" %} class="on" aria-current="page"{% endif %}>People</a>
|
||||
<a href="/companies"{% if nav == "companies" %} class="on" aria-current="page"{% endif %}>Companies</a>
|
||||
<a href="/agreements"{% if nav == "agreements" %} class="on" aria-current="page"{% endif %}>Agreements</a>
|
||||
<a href="/activity"{% if nav == "activity" %} class="on" aria-current="page"{% endif %}>Activity</a>
|
||||
</nav>
|
||||
<div class="who">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<ol class="parts">
|
||||
{% for p in parts %}
|
||||
<li>
|
||||
<a class="part{% if p.done %} done{% endif %}" href="{{ base }}/{{ p.slug }}" id="part-{{ p.slug }}">
|
||||
<a class="part{% if p.done %} done{% endif %}" href="{{ base }}/{{ p.slug }}" id="part-{{ p.slug|replace("/", "-") }}">
|
||||
<span class="pmark" aria-hidden="true">{% if p.done %}✓{% else %}{{ loop.index }}{% endif %}</span>
|
||||
<span class="pbody"><b>{{ p.title }}</b><span class="muted small">{{ p.what }}</span></span>
|
||||
<span class="chip {% if p.done %}ok{% else %}warn{% endif %}">{{ p.status }}</span>
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
{% extends "client_base.html" %}
|
||||
{% import "_agreement_text.html" as ag %}
|
||||
{% block main %}
|
||||
<div class="crumbs"><a href="{{ base }}">Your details</a></div>
|
||||
<h1 class="chead">{{ title }}</h1>
|
||||
<p class="muted small">Version {{ version }}, {{ published }}</p>
|
||||
{% if again %}<div class="notice warn">The text has changed since you last signed it. Read this version and sign it again.</div>{% endif %}
|
||||
<section class="card agcard">
|
||||
{{ ag.text(blocks) }}
|
||||
</section>
|
||||
{% if signed %}
|
||||
<div class="notice ok" role="status">You signed this version on {{ signed }}. B4L keeps the signed copy.</div>
|
||||
<p><a class="btn" href="{{ base }}">Back</a></p>
|
||||
{% else %}
|
||||
<form method="post" action="{{ base }}/agree/{{ agreement_id }}" class="form card" id="sign-form" data-sign-form>
|
||||
<input type="hidden" name="csrf" value="{{ csrf }}">
|
||||
<input type="hidden" name="version" value="{{ version_id }}">
|
||||
<h2>Sign</h2>
|
||||
<div class="field{% if errors.accept %} has-err{% endif %}">
|
||||
<label class="check"><input type="checkbox" name="accept" value="yes" id="f-accept" required{% if f.accept %} checked{% endif %}{% if errors.accept %} aria-invalid="true" aria-describedby="e-accept"{% endif %}> I have read this agreement and accept it.</label>
|
||||
{% if errors.accept %}<p class="err" id="e-accept">{{ errors.accept }}</p>{% endif %}
|
||||
</div>
|
||||
<div class="field{% if errors.name %} has-err{% endif %}">
|
||||
<label for="f-name">Your full name, as your signature <span class="req" aria-hidden="true">*</span></label>
|
||||
<input id="f-name" name="name" type="text" value="{{ f.name }}" required autocomplete="name"{% if errors.name %} aria-invalid="true" aria-describedby="e-name"{% endif %}>
|
||||
{% if errors.name %}<p class="err" id="e-name">{{ errors.name }}</p>{% endif %}
|
||||
</div>
|
||||
<div class="field sigfield{% if errors.drawing %} has-err{% endif %}" data-sign-wrap hidden>
|
||||
<label for="f-pad">Sign with your finger or the mouse <span class="req" aria-hidden="true">*</span></label>
|
||||
<canvas class="sigpad" id="f-pad" data-sign-pad aria-label="Signature pad"></canvas>
|
||||
<input type="hidden" name="drawing" value="" data-sign-out>
|
||||
<div class="sigbar"><button type="button" class="btn sm ghost" data-sign-clear>Clear</button><span class="err" data-sign-msg hidden>Sign in the box first.</span></div>
|
||||
{% if errors.drawing %}<p class="err" id="e-drawing">{{ errors.drawing }}</p>{% endif %}
|
||||
</div>
|
||||
<div class="formactions">
|
||||
<button type="submit" class="btn pri" id="sign-btn">Sign</button>
|
||||
<a class="btn ghost" href="{{ base }}">Back</a>
|
||||
</div>
|
||||
<p class="hint">Signing records your name, the time, this link, your internet address and your browser with the exact text. B4L keeps the signed copy as a PDF.</p>
|
||||
</form>
|
||||
<script src="/static/signature.js?v={{ v }}" defer></script>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
@@ -87,6 +87,22 @@
|
||||
{% endfor %}
|
||||
</section>
|
||||
|
||||
{% if agreements or signed_agreements %}
|
||||
<section class="card" id="agreements">
|
||||
<header><h2>Agreements</h2></header>
|
||||
{% for g in agreements %}
|
||||
<div class="row agrow"><a href="/agreements/{{ g.id }}">{{ g.title }}</a><span class="chip {{ g.level }}">{{ g.state }}</span><span class="muted small">{{ g.note }}</span></div>
|
||||
{% endfor %}
|
||||
{% if signed_agreements %}
|
||||
<ul class="log">
|
||||
{% for s in signed_agreements %}
|
||||
<li><span class="when">{{ s.at }}</span><span>{% if s.href %}<a href="{{ s.href }}" target="_blank" rel="noopener">{{ s.title }}, version {{ s.version }}</a>{% else %}{{ s.title }}, version {{ s.version }}{% endif %} signed as <b>{{ s.name }}</b>{% if s.through %} <span class="muted">({{ s.through }})</span>{% endif %}{% if s.old %} <span class="tag plain">earlier version</span>{% endif %}</span></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
<section class="card" id="recent">
|
||||
<header><h2>Recent activity</h2><a class="btn sm ghost" href="/activity?person={{ p.id }}">All of it</a></header>
|
||||
<ul class="log">
|
||||
|
||||
Reference in new issue
Block a user