Merge remote-tracking branch 'origin/feat/send-to-approval' into naprawa-53
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
"""Galena's "Send for approval" lands here (Atrium#53): the new-run screen takes the document from
|
||||
the link, locked, and still lets the server re-pin it. DB-free, reads the console source."""
|
||||
from __future__ import annotations
|
||||
|
||||
import pathlib
|
||||
import re
|
||||
|
||||
import pytest
|
||||
|
||||
CONSOLE = pathlib.Path(__file__).resolve().parents[2] / "frontend" / "app.js"
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def view() -> str:
|
||||
source = CONSOLE.read_text(encoding="utf-8")
|
||||
return source.split("async function viewNewRun(C, q) {", 1)[1].split("\n}\n", 1)[0]
|
||||
|
||||
|
||||
def test_the_link_fills_both_fields_escaped(view):
|
||||
assert 'value="${esc(q.path || \'\')}"' in view
|
||||
assert 'value="${esc(q.document_id || \'\')}"' in view
|
||||
|
||||
|
||||
def test_a_sent_document_is_locked_only_when_it_came_with_the_link(view):
|
||||
assert re.search(r"const sent = doc && !!q\.document_id && !!q\.path;", view)
|
||||
assert "const ro = sent ? ' readonly' : '';" in view
|
||||
|
||||
|
||||
def test_the_start_still_sends_id_and_path_for_the_server_to_pin():
|
||||
source = CONSOLE.read_text(encoding="utf-8")
|
||||
start = source.split("function startRun(e) {", 1)[1].split("\n}\n", 1)[0]
|
||||
assert "document_id: $('nsDocId').value.trim(), path: $('nsDocPath').value.trim()" in start
|
||||
|
||||
|
||||
def test_the_new_sentence_is_translated():
|
||||
source = CONSOLE.read_text(encoding="utf-8")
|
||||
assert "'Dokument wybrany w Galenie. Obieg zatwierdzi jego obecną wersję główną.': " in source
|
||||
+10
-3
@@ -343,6 +343,7 @@ const I18N = {
|
||||
'Wgraj plik': 'Upload a file',
|
||||
'Identyfikator dokumentu': 'Document ID',
|
||||
'Ścieżka dokumentu': 'Document path',
|
||||
'Dokument wybrany w Galenie. Obieg zatwierdzi jego obecną wersję główną.': 'Document chosen in Galena. The run approves its current main version.',
|
||||
'Rozpocznij obieg': 'Start the run',
|
||||
'Wybierz plik.': 'Choose a file.',
|
||||
'Moderator nie zdefiniował jeszcze typów wniosków.': 'A moderator has not defined any request types yet.',
|
||||
@@ -853,18 +854,24 @@ const stepFoot = (label) => `<div class="form-foot"><a class="btn" href="#/new">
|
||||
<button class="btn primary" type="submit">${label}</button></div>`;
|
||||
|
||||
/* Nowa sprawa, a document: an upload, or a Galena document by id and path, re-pinned by the server
|
||||
at start. A Galena role is a stage only a document can have, so the editor offers it only then. */
|
||||
at start. A Galena role is a stage only a document can have, so the editor offers it only then.
|
||||
Galena's "Send for approval" (Atrium#53: Galena has no menu entry) opens this screen as
|
||||
`#/runs/new?kind=document&document_id=…&path=…`: the document arrives chosen and locked, and the
|
||||
server still re-pins it with the person's token, so the link grants nothing by itself. */
|
||||
async function viewNewRun(C, q) {
|
||||
const [opts] = await Promise.all([api('GET', '/options'), loadStart()]);
|
||||
const doc = q.kind === 'document' && !!opts.galena_enabled;
|
||||
const name = doc ? 'Dokument z Galeny' : 'Plik z komputera';
|
||||
const sent = doc && !!q.document_id && !!q.path;
|
||||
setCrumb([{ label: 'Nowa sprawa', href: '#/new' }, { label: name }]);
|
||||
state.start.allowRole = doc;
|
||||
const ro = sent ? ' readonly' : '';
|
||||
C.innerHTML = stepHead(esc(name))
|
||||
+ `<form data-errors onsubmit="startRun(event)"><div class="split">
|
||||
<div class="card form"><h3>Przedmiot obiegu</h3>${doc
|
||||
? `<label class="field">Identyfikator dokumentu<input id="nsDocId" class="mono" /></label>
|
||||
<label class="field">Ścieżka dokumentu<input id="nsDocPath" class="mono" /></label>`
|
||||
? `${sent ? '<div class="faint tiny" style="margin-bottom:8px">Dokument wybrany w Galenie. Obieg zatwierdzi jego obecną wersję główną.</div>' : ''}
|
||||
<label class="field">Ścieżka dokumentu<input id="nsDocPath" class="mono" value="${esc(q.path || '')}"${ro} /></label>
|
||||
<label class="field">Identyfikator dokumentu<input id="nsDocId" class="mono" value="${esc(q.document_id || '')}"${ro} /></label>`
|
||||
: '<label class="field">Plik<input type="file" id="nsFile" /></label>'}</div>
|
||||
${layoutPicker(null)}</div>${stepFoot('Rozpocznij obieg')}</form>`;
|
||||
layoutChanged();
|
||||
|
||||
Reference in New Issue
Block a user