A lawyer sends a contract version to one of its parties with a link. On it the other side marks the text up in an editor that keeps every change visible, as tracked changes do: deleting our text crosses it out in red, typing is marked as added in green, and the highlighter marks a passage in yellow with a comment. Restore and Undo take marks back. They send it back once a round; each later version comes on the same link. - Migration 0014: review_links (token kept as a SHA-256, one open link a party) and review_rounds (the reply written once: their pieces, text, SHA-256, name, message; a trigger refuses any other change and every delete). Journal entries "sent for review", "review returned" (with the fingerprint of their text) and "review link closed"; audit entity "review". - The reply is a list of pieces (same, ins, del, mark). The server checks that the pieces without the added ones are exactly the version sent, so nothing changes unseen (reviews::check). - Our review page: their message, the changes numbered with the words around them and a box each, the highlights with comments, a git-style diff (line numbers, - and + lines, the changed words marked, three lines of context per hunk) and their markup. "Take the ticked changes" opens the contract page with the version form filled with our text plus those changes. - static/review-editor.js: edits work on the pieces and redraw, so our text cannot vanish; keyboard compositions and edits the browser will not cancel are compared with the text and taken as edits. - Property tests (any markup is accepted and taken back exactly; markup that changes our text unseen is refused), the fuzz text target runs reviews::check, integration tests, and the demo has the label's review of the recording agreement. - PLAN: phase 13.
198 lines
14 KiB
HTML
198 lines
14 KiB
HTML
{% extends "base.html" %}
|
|
{% import "_fields.html" as fm %}
|
|
{% import "_agreement_text.html" as ag %}
|
|
{% import "_journal.html" as jn %}
|
|
{% import "_conflicts.html" as cf %}
|
|
{% block main %}
|
|
<div class="phead">
|
|
<div class="crumbs"><a href="/contracts">Contracts</a> <span class="sep">/</span> <a href="/clients/{{ head.client_id }}">{{ client_name }}</a></div>
|
|
<div class="pagehead">
|
|
<div>
|
|
<div class="ccode mono">{{ head.code }}</div>
|
|
<h1>{{ head.title }}</h1>
|
|
</div>
|
|
<div class="actions"><a class="btn sm" href="/contracts/{{ id }}/edit" id="edit-contract">Edit the facts</a></div>
|
|
</div>
|
|
<p class="meta">{% if artist %}<span class="tag gold">artist</span> {% endif %}{{ kind_label }}<span class="sep">·</span>for <a href="/clients/{{ head.client_id }}">{{ client_name }}</a>{% if shown.status %} <span class="chip {{ shown.status.level }}">{{ shown.status.label }}</span>{% endif %}</p>
|
|
</div>
|
|
<div class="cols">
|
|
<section class="card" id="details">
|
|
<header><h2>Facts</h2></header>
|
|
<dl class="kv">
|
|
{% for it in shown.items %}
|
|
<dt>{{ it.label }}</dt><dd class="{% if it.pre %}pre{% endif %}{% if it.mono %} mono{% endif %}">{% if it.href %}<a href="{{ it.href }}">{{ it.value }}</a>{% else %}{{ it.value }}{% endif %}</dd>
|
|
{% endfor %}
|
|
<dt>Opened</dt><dd>{{ opened }}{% if head.created_by %} by {{ head.created_by }}{% endif %}</dd>
|
|
</dl>
|
|
</section>
|
|
<section class="card" id="versions">
|
|
<header><h2>Versions</h2><span class="muted small">never changed once added</span></header>
|
|
{% for v in versions %}
|
|
<div class="item{% if reading and v.version != reading %} old{% endif %}" id="version-{{ v.version }}">
|
|
<div class="row"><b>Version {{ v.version }}</b>{% if loop.first %}<span class="tag">newest</span>{% endif %}<span class="muted small">{{ v.at }} · {{ v.by }}</span></div>
|
|
<div>{{ v.note }}</div>
|
|
<div class="vlinks small">
|
|
{% if v.has_text %}<a href="/contracts/{{ id }}?v={{ v.version }}#reading">Read the text</a> <span class="muted">({{ v.chars }} characters)</span>{% endif %}
|
|
{% if v.file %}<a href="{{ v.file }}" target="_blank" rel="noopener">{{ v.file_name }}</a> <a href="{{ v.file }}?download=1">download</a>{% endif %}
|
|
</div>
|
|
{% if v.body_sha %}<div class="muted small mono" title="SHA-256 of the text: {{ v.body_sha }}">text {{ v.body_sha[:16] }}…</div>{% endif %}
|
|
{% if v.file_sha %}<div class="muted small mono" title="SHA-256 of the file: {{ v.file_sha }}">file {{ v.file_sha[:16] }}…</div>{% endif %}
|
|
</div>
|
|
{% else %}
|
|
<p class="empty-inline">No version yet: add the first draft below, as a text, a file or both.</p>
|
|
{% endfor %}
|
|
</section>
|
|
</div>
|
|
<section class="card" id="parties">
|
|
<header><h2>Parties</h2><span class="muted small">each one added is checked for conflicts</span></header>
|
|
<ul class="parties">
|
|
<li><div class="prow"><span><a class="strong" href="/clients/{{ head.client_id }}">{{ client_name }}</a> <span class="tag gold">our client</span></span></div></li>
|
|
{% for p in parties %}
|
|
<li id="party-{{ p.id }}"{% if p.removed %} class="old"{% endif %}>
|
|
<div class="prow">
|
|
<span><b>{{ p.name }}</b>{% if p.name_th %} <span lang="th">{{ p.name_th }}</span>{% endif %}{% if p.role %} <span class="tag">{{ p.role }}</span>{% endif %}{% if p.removed %} <span class="chip plain">removed</span>{% endif %}</span>
|
|
{% if not p.removed %}<form method="post" action="/contracts/{{ id }}/parties/{{ p.id }}/remove" class="inline-form" data-confirm="Take {{ p.name }} off this contract? It stays on record, marked removed."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm ghost">Remove</button></form>{% endif %}
|
|
</div>
|
|
<div class="sub">{% if p.id_no %}<span class="mono">{{ p.id_no }}</span> · {% endif %}added {{ p.added }} by {{ p.by }}{% if p.removed %} · removed {{ p.removed }} by {{ p.removed_by }}{% endif %}</div>
|
|
</li>
|
|
{% endfor %}
|
|
</ul>
|
|
{% if not live_parties %}<p class="empty-inline">No other party yet: add the other side, and the check looks for it among everyone on record.</p>{% endif %}
|
|
<details class="addparty"{% if check.hits or party_errors %} open{% endif %}>
|
|
<summary class="btn sm" id="add-party-open">Add a party</summary>
|
|
<form method="post" action="/contracts/{{ id }}/parties" class="form" id="party-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
{% if check.hits %}{{ cf.block(check) }}{% endif %}
|
|
<div class="grid">
|
|
{{ fm.text("party_name", "Name", party.name, err=party_errors.party_name, req=true, cls="wide", hint="As registered, or as in the ID card or passport.") }}
|
|
{{ fm.text("party_name_th", "Name in Thai", party.name_th, err=party_errors.party_name_th, cls="wide") }}
|
|
{{ fm.text("party_id_no", "ID, passport or registration number", party.id_no, err=party_errors.party_id_no, hint="The check compares numbers too.") }}
|
|
{{ fm.text("party_role", "Role", party.role, err=party_errors.party_role, list="roles", ph="Label, venue, landlord") }}
|
|
</div>
|
|
<div class="formactions"><button type="submit" class="btn pri" id="add-party">{% if check.ask %}Add the party{% else %}Check and add{% endif %}</button></div>
|
|
</form>
|
|
</details>
|
|
<datalist id="roles">{% for r in roles %}<option value="{{ r }}"></option>{% endfor %}</datalist>
|
|
</section>
|
|
<section class="card" id="reviews">
|
|
<header><h2>Review by the other side</h2><span class="muted small">a link where a party marks up a version and sends it back</span></header>
|
|
{% for l in reviews %}
|
|
<div class="item{% if not l.open %} old{% endif %}" id="review-link-{{ l.id }}">
|
|
<div class="row"><b>{{ l.party }}</b><span class="muted small">{{ l.state }}</span>
|
|
{% if l.open %}<form method="post" action="/contracts/{{ id }}/review-links/{{ l.id }}/close" class="inline-form" data-confirm="Close {{ l.party }}'s review link? It stops working; sending again makes a new one."><input type="hidden" name="csrf" value="{{ csrf }}"><button type="submit" class="btn sm ghost">Close the link</button></form>{% endif %}
|
|
</div>
|
|
<ul class="rvrounds">
|
|
{% for r in l.rounds %}
|
|
<li id="round-{{ r.id }}">Version {{ r.version }} sent {{ r.sent }} by {{ r.by }}:
|
|
{% if r.replied %}<a href="/contracts/{{ id }}/reviews/{{ r.id }}">sent back {{ r.replied }}</a>, <span class="chip {% if r.changes %}warn{% else %}ok{% endif %}">{{ r.changes }} {% if r.changes == 1 %}change{% else %}changes{% endif %}</span>{% if r.highlights %} <span class="chip plain">{{ r.highlights }} {% if r.highlights == 1 %}highlight{% else %}highlights{% endif %}</span>{% endif %}
|
|
{% elif loop.first %}<span class="muted">waiting for them</span>{% else %}<span class="muted">not sent back; a newer version followed</span>{% endif %}</li>
|
|
{% endfor %}
|
|
</ul>
|
|
</div>
|
|
{% endfor %}
|
|
{% if live_parties and text_versions %}
|
|
<details class="addparty"{% if not reviews %} open{% endif %}>
|
|
<summary class="btn sm" id="send-review-open">Send a version for review</summary>
|
|
<form method="post" action="/contracts/{{ id }}/reviews" class="form" id="send-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<div class="grid">
|
|
{{ fm.select("review_party", "To", "", review_parties, req=true, blank="Choose the party") }}
|
|
{{ fm.select("review_version", "Version", text_versions[0][0], text_versions, req=true, blank="Choose") }}
|
|
{{ fm.area("review_message", "Message to them", "", rows=3, fcls="wide", hint="Optional: what to look at, by when.") }}
|
|
</div>
|
|
<div class="formactions"><button type="submit" class="btn pri" id="send-review">Send</button></div>
|
|
</form>
|
|
</details>
|
|
{% elif not live_parties %}<p class="empty-inline">Add the other party above to send them a version to review.</p>
|
|
{% else %}<p class="empty-inline">Add a version with a text to send it for review: the editor works on the text.</p>{% endif %}
|
|
</section>
|
|
{% if reading %}
|
|
<section class="card" id="reading">
|
|
<header><h2>{% if compare %}Version {{ reading }} against version {{ before }}{% else %}Version {{ reading }}{% endif %}{% if reading_note %}: {{ reading_note }}{% endif %}</h2>
|
|
{% if before %}{% if compare %}<a class="small" href="/contracts/{{ id }}?v={{ reading }}#reading">Show the text</a>{% else %}<a class="small" href="/contracts/{{ id }}?v={{ reading }}&compare=1#reading" id="compare">Compare with version {{ before }}</a>{% endif %}{% endif %}
|
|
</header>
|
|
{% if compare %}
|
|
{% if diff %}
|
|
<p class="hint">Lines taken out are struck through in red, lines added are marked in green.</p>
|
|
<div class="diff">{% for l in diff %}<div class="dl {{ l.op }}">{% if l.op == "removed" %}<del>{{ l.text or " " }}</del>{% elif l.op == "added" %}<ins>{{ l.text or " " }}</ins>{% else %}{{ l.text or " " }}{% endif %}</div>{% endfor %}</div>
|
|
{% else %}<p class="empty-inline">The texts are too long to compare here.</p>{% endif %}
|
|
{% else %}
|
|
{{ ag.text(blocks) }}
|
|
{% if reading_sha %}<p class="muted small mono hashline">SHA-256 {{ reading_sha }}</p>{% endif %}
|
|
{% endif %}
|
|
</section>
|
|
{% endif %}
|
|
<form method="post" action="/contracts/{{ id }}/versions" enctype="multipart/form-data" class="form upload" id="version-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<section class="card">
|
|
<header><h2>Add version {{ next_version }}</h2></header>
|
|
<p class="hint lead">A new draft, the other side's changes, the final text, the scan of the signed paper: each is a version. Keep the text here, attach the file (PDF or a scan), or both. A version never changes once added; its fingerprints go into the journal.</p>
|
|
<div class="grid">
|
|
{{ fm.text("note", "What this version is", draft_note, err=errors.note, req=true, cls="wide", ph="Such as: first draft, the label's changes, signed by both sides") }}
|
|
{{ fm.area("body", "Text", draft_body, err=errors.body, rows=14, fcls="wide", hint="Paragraphs separated by an empty line, # before a heading, - before a list item. It starts as the last version's text; leave it as it is to add only a file.") }}
|
|
<div class="field wide{% if errors.file %} has-err{% endif %}">
|
|
<label for="f-file">File</label>
|
|
{% if uploads %}<input id="f-file" name="file" type="file" accept="application/pdf,image/jpeg,image/png,image/webp">
|
|
<p class="hint">PDF, JPEG, PNG or WebP, up to {{ file_mb }} MB. Stored encrypted, like every document.</p>{% else %}<p class="hint">This server keeps no files: add the text only.</p>{% endif %}
|
|
{% if errors.file %}<p class="err" id="e-file">{{ errors.file }}</p>{% endif %}
|
|
</div>
|
|
</div>
|
|
<div class="formactions"><button type="submit" class="btn pri" id="add-version">Add version {{ next_version }}</button></div>
|
|
</section>
|
|
</form>
|
|
<h2 class="sechead" id="papers">Paper copies</h2>
|
|
<p class="meta">Each paper gets an id to write on it, or a label to print. Its record says where it lies; every move goes into the journal.</p>
|
|
{% if papers %}
|
|
<div class="card flush">
|
|
<div class="tblwrap">
|
|
<table class="tbl" id="paper-list">
|
|
<thead><tr><th>Id</th><th>Paper</th><th>Where it is</th><th></th></tr></thead>
|
|
<tbody>
|
|
{% for p in papers %}
|
|
<tr id="paper-{{ p.id }}"{% if p.gone %} class="old"{% endif %}>
|
|
<td><span class="pcode mono">{{ p.code }}</span></td>
|
|
<td>{{ p.what }}{% if p.version %}<div class="sub">version {{ p.version }}</div>{% endif %}</td>
|
|
<td><span class="chip {% if p.state == "filed" %}ok{% elif p.state == "out" %}warn{% else %}plain{% endif %}">{{ p.state_label }}</span> {{ p.location }}{% if p.holder %}<div class="sub">with {{ p.holder }}</div>{% endif %}<div class="sub">since {{ p.moved }}</div></td>
|
|
<td class="pacts">
|
|
<a class="btn sm ghost" href="/papers/{{ p.id }}/label" target="_blank" rel="noopener">Label</a>
|
|
<details class="move"><summary class="btn sm ghost">Move</summary>
|
|
<form method="post" action="/papers/{{ p.id }}/move" class="form mini">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<label>Where it is now<input name="location" value="{{ p.location }}" list="locations" required></label>
|
|
<label>State<select name="state">{% for s in states %}<option value="{{ s[0] }}"{% if s[0] == p.state %} selected{% endif %}>{{ s[1] }}</option>{% endfor %}</select></label>
|
|
<label>With whom<input name="holder" value="{{ p.holder }}" placeholder="While it is out, or whom it went to"></label>
|
|
<label>Note<input name="note" placeholder="Such as: for the signing at the label"></label>
|
|
<button type="submit" class="btn sm pri">Save the move</button>
|
|
</form>
|
|
</details>
|
|
</td>
|
|
</tr>
|
|
{% endfor %}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
<form method="post" action="/contracts/{{ id }}/papers" class="form" id="paper-form">
|
|
<input type="hidden" name="csrf" value="{{ csrf }}">
|
|
<section class="card">
|
|
<header><h2>Register a paper copy</h2></header>
|
|
<div class="grid">
|
|
{{ fm.text("what", "What it is", "", req=true, list="whats", ph="Signed original") }}
|
|
<div class="field">
|
|
<label for="f-version">Version</label>
|
|
<select id="f-version" name="version"><option value="">Not known</option>{% for v in versions %}<option value="{{ v.version }}"{% if loop.first %} selected{% endif %}>Version {{ v.version }}: {{ v.note }}</option>{% endfor %}</select>
|
|
</div>
|
|
{{ fm.text("location", "Where it is filed", "", req=true, list="locations", cls="wide", ph="Office, cabinet A, drawer 2, folder of the client") }}
|
|
</div>
|
|
<div class="formactions"><button type="submit" class="btn" id="add-paper">Register and give it an id</button></div>
|
|
</section>
|
|
</form>
|
|
<datalist id="whats">{% for w in whats %}<option value="{{ w }}"></option>{% endfor %}</datalist>
|
|
<datalist id="locations">{% for l in locations %}<option value="{{ l }}"></option>{% endfor %}</datalist>
|
|
<section class="card" id="contract-journal">
|
|
<header><h2>Journal of this contract</h2><a class="small" href="/journal">The whole journal, checked</a></header>
|
|
{% if entries %}{{ jn.list(entries) }}{% else %}<p class="empty-inline">Nothing yet.</p>{% endif %}
|
|
</section>
|
|
{% endblock %}
|