Release govoplan-templates v0.1.22: bound rendering and improve dialog layout
This commit is contained in:
+2
-2
@@ -4,13 +4,13 @@ build-backend = "setuptools.build_meta"
|
|||||||
|
|
||||||
[project]
|
[project]
|
||||||
name = "govoplan-templates"
|
name = "govoplan-templates"
|
||||||
version = "0.1.21"
|
version = "0.1.22"
|
||||||
description = "GovOPlaN typed template library and deterministic printable rendering."
|
description = "GovOPlaN typed template library and deterministic printable rendering."
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.12"
|
requires-python = ">=3.12"
|
||||||
authors = [{ name = "GovOPlaN" }]
|
authors = [{ name = "GovOPlaN" }]
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"govoplan-core>=0.1.18",
|
"govoplan-core>=0.1.45",
|
||||||
]
|
]
|
||||||
|
|
||||||
[tool.setuptools.packages.find]
|
[tool.setuptools.packages.find]
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
"""GovOPlaN Templates module."""
|
"""GovOPlaN Templates module."""
|
||||||
|
|
||||||
__version__ = "0.1.21"
|
__version__ = "0.1.22"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ from govoplan_templates.backend.dsar_provider import (
|
|||||||
|
|
||||||
MODULE_ID = "templates"
|
MODULE_ID = "templates"
|
||||||
MODULE_NAME = "Templates"
|
MODULE_NAME = "Templates"
|
||||||
MODULE_VERSION = "0.1.21"
|
MODULE_VERSION = "0.1.22"
|
||||||
|
|
||||||
READ_SCOPE = "templates:template:read"
|
READ_SCOPE = "templates:template:read"
|
||||||
WRITE_SCOPE = "templates:template:write"
|
WRITE_SCOPE = "templates:template:write"
|
||||||
@@ -102,6 +102,21 @@ ROLE_TEMPLATES = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
DOCUMENTATION = (
|
DOCUMENTATION = (
|
||||||
|
DocumentationTopic(
|
||||||
|
id="templates.workspace-layout",
|
||||||
|
title="Templates workspace actions",
|
||||||
|
summary="Find collection-wide commands in their consistent workspace position.",
|
||||||
|
body="Reload and Add template use the persistent full-width workspace header at the upper right; Reload sits immediately before creation. Selecting a record, changing filters, or opening an editor does not move these collection-wide commands into the left pane. Template editing, saving, publishing, and rendering remain scoped to the selected template. Existing permissions, disabled-state rules, and unsaved-change guards still apply. Administrators configure authority through the existing permission system; no new permission or automatic operation is introduced.",
|
||||||
|
layer="static",
|
||||||
|
documentation_types=("user", "admin"),
|
||||||
|
audience=("user", "module_admin", "operator"),
|
||||||
|
order=5,
|
||||||
|
translations={"de": {
|
||||||
|
"title": "Vorlagen: Aktionen im Arbeitsbereich",
|
||||||
|
"summary": "Sammlungsweite Aktionen an ihrer einheitlichen Position im Arbeitsbereich finden.",
|
||||||
|
"body": "Neu laden und Vorlage hinzufügen stehen oben rechts in der dauerhaft sichtbaren, arbeitsbereichsweiten Leiste; Neu laden steht unmittelbar vor dem Anlegen. Auswahl, Filterwechsel und Bearbeitung verschieben diese sammlungsweiten Aktionen nicht in den linken Bereich. Bearbeiten, Speichern, Veröffentlichen und Rendern bleiben der ausgewählten Vorlage zugeordnet. Bestehende Berechtigungen, Deaktivierungsregeln und der Schutz ungespeicherter Änderungen gelten weiterhin. Administratoren konfigurieren Rechte im bestehenden Berechtigungssystem; es entstehen weder neue Rechte noch automatische Vorgänge.",
|
||||||
|
}},
|
||||||
|
),
|
||||||
DocumentationTopic(
|
DocumentationTopic(
|
||||||
id="templates.library",
|
id="templates.library",
|
||||||
title="Template library",
|
title="Template library",
|
||||||
@@ -109,7 +124,8 @@ DOCUMENTATION = (
|
|||||||
body=(
|
body=(
|
||||||
"Templates are reusable, scoped definitions. Every edit creates an immutable revision. "
|
"Templates are reusable, scoped definitions. Every edit creates an immutable revision. "
|
||||||
"Publish the revision that consumers may use for final output. A compatibility check explains "
|
"Publish the revision that consumers may use for final output. A compatibility check explains "
|
||||||
"missing fields, unsupported usages, and unavailable output formats before rendering."
|
"missing fields, unsupported usages, and unavailable output formats before rendering. "
|
||||||
|
"The Add template dialog uses the shared responsive form layout: name, type, and footer actions remain inside the dialog on narrow screens without horizontal form scrolling."
|
||||||
),
|
),
|
||||||
layer="available",
|
layer="available",
|
||||||
documentation_types=("admin", "user"),
|
documentation_types=("admin", "user"),
|
||||||
@@ -127,7 +143,8 @@ DOCUMENTATION = (
|
|||||||
"body": (
|
"body": (
|
||||||
"Vorlagen sind wiederverwendbare, bereichsgebundene Definitionen. Jede Bearbeitung erzeugt eine unveränderliche Revision. "
|
"Vorlagen sind wiederverwendbare, bereichsgebundene Definitionen. Jede Bearbeitung erzeugt eine unveränderliche Revision. "
|
||||||
"Veröffentlichen Sie die Revision, die Verbraucher für endgültige Ausgaben verwenden dürfen. Vor dem Rendern erläutert eine "
|
"Veröffentlichen Sie die Revision, die Verbraucher für endgültige Ausgaben verwenden dürfen. Vor dem Rendern erläutert eine "
|
||||||
"Kompatibilitätsprüfung fehlende Felder, nicht unterstützte Verwendungen und nicht verfügbare Ausgabeformate."
|
"Kompatibilitätsprüfung fehlende Felder, nicht unterstützte Verwendungen und nicht verfügbare Ausgabeformate. "
|
||||||
|
"Der Dialog zum Hinzufügen einer Vorlage verwendet das gemeinsame responsive Formularlayout: Name, Typ und Fußzeilenaktionen bleiben auch auf schmalen Bildschirmen ohne horizontales Formularscrollen im Dialog."
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -187,7 +204,9 @@ DOCUMENTATION = (
|
|||||||
"Preview output may use a draft revision. Final output requires a published revision and an "
|
"Preview output may use a draft revision. Final output requires a published revision and an "
|
||||||
"idempotency key. Results pin the template hash, input hash, renderer version, item/page counts, "
|
"idempotency key. Results pin the template hash, input hash, renderer version, item/page counts, "
|
||||||
"diagnostics, and output digest. Files stores artifacts when available and authorized; otherwise "
|
"diagnostics, and output digest. Files stores artifacts when available and authorized; otherwise "
|
||||||
"Templates provides a bounded download. Browser printing is the supported baseline output path."
|
"Templates provides a bounded download. The existing 5 MiB output ceiling is enforced while substituting tokens and composing items, "
|
||||||
|
"including UTF-8 bytes, escaping, separators, and the final HTML wrapper. Oversized expansion stops before the whole bundle is allocated "
|
||||||
|
"or any output is persisted; reduce the selected items or template content and retry. Browser printing is the supported baseline output path."
|
||||||
),
|
),
|
||||||
layer="available",
|
layer="available",
|
||||||
documentation_types=("admin", "user"),
|
documentation_types=("admin", "user"),
|
||||||
@@ -201,7 +220,10 @@ DOCUMENTATION = (
|
|||||||
"Eine Vorschau darf eine Entwurfsrevision verwenden. Endgültige Ausgabe verlangt eine veröffentlichte Revision und einen "
|
"Eine Vorschau darf eine Entwurfsrevision verwenden. Endgültige Ausgabe verlangt eine veröffentlichte Revision und einen "
|
||||||
"Idempotenzschlüssel. Ergebnisse legen Vorlagenhash, Eingabehash, Renderer-Version, Element-/Seitenanzahl, Diagnosen und "
|
"Idempotenzschlüssel. Ergebnisse legen Vorlagenhash, Eingabehash, Renderer-Version, Element-/Seitenanzahl, Diagnosen und "
|
||||||
"Ausgabe-Digest fest. Files speichert Artefakte, wenn die Fähigkeit verfügbar und berechtigt ist; andernfalls stellt Templates "
|
"Ausgabe-Digest fest. Files speichert Artefakte, wenn die Fähigkeit verfügbar und berechtigt ist; andernfalls stellt Templates "
|
||||||
"einen begrenzten Download bereit. Drucken im Browser ist der unterstützte grundlegende Ausgabepfad."
|
"einen begrenzten Download bereit. Die bestehende Ausgabegrenze von 5 MiB wird bereits beim Ersetzen von Platzhaltern und Zusammenstellen "
|
||||||
|
"der Elemente durchgesetzt, einschließlich UTF-8-Bytes, Maskierung, Trennzeichen und abschließender HTML-Hülle. Übermäßige Erweiterung "
|
||||||
|
"stoppt vor dem vollständigen Speicheraufbau oder Speichern einer Ausgabe; reduzieren Sie die ausgewählten Elemente oder den Vorlageninhalt "
|
||||||
|
"und versuchen Sie es erneut. Drucken im Browser ist der unterstützte grundlegende Ausgabepfad."
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -362,22 +362,49 @@ def _render_payload(
|
|||||||
) -> tuple[bytes, str, int]:
|
) -> tuple[bytes, str, int]:
|
||||||
if request.output_format == "text":
|
if request.output_format == "text":
|
||||||
body = revision.content_text or _html_to_text(revision.content_html or "")
|
body = revision.content_text or _html_to_text(revision.content_html or "")
|
||||||
rendered = [
|
|
||||||
_substitute(body, _render_context(request.parameters, item, index), html=False)
|
|
||||||
for index, item in enumerate(items)
|
|
||||||
]
|
|
||||||
separator = "\n\n---\n\n" if revision.template_type != "list_layout" else "\n"
|
separator = "\n\n---\n\n" if revision.template_type != "list_layout" else "\n"
|
||||||
|
rendered = _render_items(body, request.parameters, items, html=False, separator=separator)
|
||||||
payload = separator.join(rendered).encode("utf-8")
|
payload = separator.join(rendered).encode("utf-8")
|
||||||
return payload, "text/plain; charset=utf-8", _page_count(revision, len(items))
|
return payload, "text/plain; charset=utf-8", _page_count(revision, len(items))
|
||||||
|
|
||||||
body = revision.content_html or f"<pre>{escape(revision.content_text or '')}</pre>"
|
body = revision.content_html or f"<pre>{escape(revision.content_text or '')}</pre>"
|
||||||
rendered = [
|
rendered = _render_items(body, request.parameters, items, html=True)
|
||||||
_substitute(body, _render_context(request.parameters, item, index), html=True)
|
|
||||||
for index, item in enumerate(items)
|
|
||||||
]
|
|
||||||
page_count = _page_count(revision, len(items))
|
page_count = _page_count(revision, len(items))
|
||||||
document = _html_document(definition, revision, rendered)
|
document = _html_document(definition, revision, rendered)
|
||||||
return document.encode("utf-8"), "text/html; charset=utf-8", page_count
|
payload = document.encode("utf-8")
|
||||||
|
if len(payload) > MAX_OUTPUT_BYTES:
|
||||||
|
_output_limit_exceeded()
|
||||||
|
return payload, "text/html; charset=utf-8", page_count
|
||||||
|
|
||||||
|
|
||||||
|
def _output_limit_exceeded() -> None:
|
||||||
|
raise TemplateRenderError(
|
||||||
|
f"Rendered output exceeds the {MAX_OUTPUT_BYTES} byte bounded-download limit."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def _render_items(
|
||||||
|
body: str,
|
||||||
|
parameters: Mapping[str, object],
|
||||||
|
items: Sequence[Mapping[str, object]],
|
||||||
|
*,
|
||||||
|
html: bool,
|
||||||
|
separator: str = "",
|
||||||
|
) -> list[str]:
|
||||||
|
# Reject as soon as the same existing output budget is exhausted; never
|
||||||
|
# build thousands of oversized documents and only then measure the join.
|
||||||
|
remaining = MAX_OUTPUT_BYTES
|
||||||
|
separator_bytes = len(separator.encode("utf-8"))
|
||||||
|
rendered: list[str] = []
|
||||||
|
for index, item in enumerate(items):
|
||||||
|
if index:
|
||||||
|
remaining -= separator_bytes
|
||||||
|
if remaining < 0:
|
||||||
|
_output_limit_exceeded()
|
||||||
|
value = _substitute(body, _render_context(parameters, item, index), html=html, max_bytes=remaining)
|
||||||
|
remaining -= len(value.encode("utf-8"))
|
||||||
|
rendered.append(value)
|
||||||
|
return rendered
|
||||||
|
|
||||||
|
|
||||||
def _html_document(
|
def _html_document(
|
||||||
@@ -552,15 +579,32 @@ def _render_context(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def _substitute(template: str, context: Mapping[str, object], *, html: bool) -> str:
|
def _substitute(template: str, context: Mapping[str, object], *, html: bool, max_bytes: int | None = None) -> str:
|
||||||
def replacement(match: re.Match[str]) -> str:
|
remaining = MAX_OUTPUT_BYTES if max_bytes is None else max_bytes
|
||||||
value, present = _resolve_path(context, match.group(1))
|
pieces: list[str] = []
|
||||||
if not present or value is None:
|
|
||||||
return ""
|
|
||||||
rendered = _display_value(value)
|
|
||||||
return escape(rendered, quote=True) if html else rendered
|
|
||||||
|
|
||||||
return _TOKEN_PATTERN.sub(replacement, template)
|
def append(value: str) -> None:
|
||||||
|
nonlocal remaining
|
||||||
|
# Character count is a cheap lower bound before allocating UTF-8 bytes.
|
||||||
|
if len(value) > remaining:
|
||||||
|
_output_limit_exceeded()
|
||||||
|
remaining -= len(value.encode("utf-8"))
|
||||||
|
if remaining < 0:
|
||||||
|
_output_limit_exceeded()
|
||||||
|
pieces.append(value)
|
||||||
|
|
||||||
|
previous = 0
|
||||||
|
for match in _TOKEN_PATTERN.finditer(template):
|
||||||
|
append(template[previous:match.start()])
|
||||||
|
value, present = _resolve_path(context, match.group(1))
|
||||||
|
if present and value is not None:
|
||||||
|
rendered = _display_value(value)
|
||||||
|
if len(rendered) > remaining:
|
||||||
|
_output_limit_exceeded()
|
||||||
|
append(escape(rendered, quote=True) if html else rendered)
|
||||||
|
previous = match.end()
|
||||||
|
append(template[previous:])
|
||||||
|
return "".join(pieces)
|
||||||
|
|
||||||
|
|
||||||
def _resolve_path(context: Mapping[str, object], path: str) -> tuple[object | None, bool]:
|
def _resolve_path(context: Mapping[str, object], path: str) -> tuple[object | None, bool]:
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
from types import SimpleNamespace
|
||||||
|
from unittest.mock import patch
|
||||||
|
|
||||||
|
from govoplan_core.core.templates import TemplateRenderError
|
||||||
|
from govoplan_templates.backend import rendering
|
||||||
|
|
||||||
|
|
||||||
|
class TemplateRenderLimitTests(unittest.TestCase):
|
||||||
|
def test_many_items_stop_before_rendering_the_entire_oversized_bundle(self):
|
||||||
|
with patch.object(rendering, "MAX_OUTPUT_BYTES", 128), patch.object(rendering, "_substitute", wraps=rendering._substitute) as substitute:
|
||||||
|
with self.assertRaisesRegex(TemplateRenderError, "bounded-download limit"):
|
||||||
|
rendering._render_items("x" * 64, {}, [{}] * 5000, html=False)
|
||||||
|
self.assertEqual(3, substitute.call_count)
|
||||||
|
|
||||||
|
def test_repeated_token_expansion_stops_before_allocating_the_whole_row(self):
|
||||||
|
with patch.object(rendering, "MAX_OUTPUT_BYTES", 128), patch.object(rendering, "_display_value", wraps=rendering._display_value) as display:
|
||||||
|
with self.assertRaisesRegex(TemplateRenderError, "bounded-download limit"):
|
||||||
|
rendering._substitute("{{value}}" * 5000, {"value": "x" * 64}, html=False)
|
||||||
|
self.assertEqual(3, display.call_count)
|
||||||
|
|
||||||
|
def test_utf8_byte_limit_is_not_a_character_limit(self):
|
||||||
|
with patch.object(rendering, "MAX_OUTPUT_BYTES", 4):
|
||||||
|
self.assertEqual("üü", rendering._substitute("{{value}}", {"value": "üü"}, html=False))
|
||||||
|
with self.assertRaises(TemplateRenderError):
|
||||||
|
rendering._substitute("{{value}}", {"value": "üüü"}, html=False)
|
||||||
|
|
||||||
|
def test_html_escaping_counts_expanded_bytes_and_preserves_valid_output(self):
|
||||||
|
with patch.object(rendering, "MAX_OUTPUT_BYTES", 9):
|
||||||
|
self.assertEqual("<&", rendering._substitute("{{value}}", {"value": "<&"}, html=True))
|
||||||
|
with self.assertRaises(TemplateRenderError):
|
||||||
|
rendering._substitute("{{value}}!", {"value": "<&"}, html=True)
|
||||||
|
|
||||||
|
def test_text_separator_is_part_of_the_same_budget(self):
|
||||||
|
with patch.object(rendering, "MAX_OUTPUT_BYTES", 5):
|
||||||
|
self.assertEqual(["ab", "cd"], rendering._render_items("{{value}}", {}, [{"value": "ab"}, {"value": "cd"}], html=False, separator="\n"))
|
||||||
|
with self.assertRaises(TemplateRenderError):
|
||||||
|
rendering._render_items("{{value}}", {}, [{"value": "ab"}, {"value": "cd"}], html=False, separator="\n\n")
|
||||||
|
|
||||||
|
def test_html_wrapper_is_also_subject_to_output_limit(self):
|
||||||
|
definition = SimpleNamespace(name="Example")
|
||||||
|
revision = SimpleNamespace(content_html="<p>Ada</p>", content_text=None, template_type="list_layout", layout={}, output_profiles=[])
|
||||||
|
request = SimpleNamespace(output_format="html", parameters={})
|
||||||
|
with patch.object(rendering, "MAX_OUTPUT_BYTES", 32):
|
||||||
|
with self.assertRaises(TemplateRenderError):
|
||||||
|
rendering._render_payload(definition, revision, request=request, items=[{}])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
+3
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@govoplan/templates-webui",
|
"name": "@govoplan/templates-webui",
|
||||||
"version": "0.1.21",
|
"version": "0.1.22",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "src/index.ts",
|
"main": "src/index.ts",
|
||||||
@@ -14,10 +14,11 @@
|
|||||||
"./styles/templates.css": "./src/styles/templates.css"
|
"./styles/templates.css": "./src/styles/templates.css"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
"test:dialog-layout": "node scripts/test-dialog-layout.mjs",
|
||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"@govoplan/core-webui": "^0.1.18",
|
"@govoplan/core-webui": "^0.1.45",
|
||||||
"lucide-react": "^1.23.0",
|
"lucide-react": "^1.23.0",
|
||||||
"react": ">=19.2.7 <20",
|
"react": ">=19.2.7 <20",
|
||||||
"react-dom": ">=19.2.7 <20",
|
"react-dom": ">=19.2.7 <20",
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import assert from "node:assert/strict";
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
|
||||||
|
const page = readFileSync(new URL("../src/features/templates/TemplatesPage.tsx", import.meta.url), "utf8");
|
||||||
|
const styles = readFileSync(new URL("../src/styles/templates.css", import.meta.url), "utf8");
|
||||||
|
assert.match(page, /<Dialog open=\{createOpen\}[^]*?<FormGrid columns=\{2\} collapseAt="standard">/);
|
||||||
|
assert.doesNotMatch(page, /templates-dialog-form/);
|
||||||
|
assert.doesNotMatch(styles, /templates-dialog-form/);
|
||||||
|
console.log("Templates dialog uses the shared shrinking form layout.");
|
||||||
@@ -9,13 +9,14 @@ import {
|
|||||||
X
|
X
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||||
import { DialogSection, ActionToolbar,
|
import { FormGrid, ActionToolbar,
|
||||||
ApiError,
|
ApiError,
|
||||||
ActionBlockerHint,
|
ActionBlockerHint,
|
||||||
Button,
|
Button,
|
||||||
ConfirmDialog,
|
ConfirmDialog,
|
||||||
ContentSection,
|
ContentSection,
|
||||||
Dialog,
|
Dialog,
|
||||||
|
DialogSection,
|
||||||
DocumentationHelpLink,
|
DocumentationHelpLink,
|
||||||
DismissibleAlert,
|
DismissibleAlert,
|
||||||
FilterBar,
|
FilterBar,
|
||||||
@@ -302,6 +303,14 @@ export default function TemplatesPage({ settings, auth }: Props) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<WorkspaceFrame as="main" height="viewport" surface="plain" className="templates-page" label="Template workspace">
|
<WorkspaceFrame as="main" height="viewport" surface="plain" className="templates-page" label="Template workspace">
|
||||||
|
<WorkspaceActionBar
|
||||||
|
scope="workspace"
|
||||||
|
variant="collection"
|
||||||
|
refreshable
|
||||||
|
reloadAction={{ onReload: () => void reload(selectedId), loading: loading || busy }}
|
||||||
|
contextActions={<strong>Template library</strong>}
|
||||||
|
createAction={<IconButton label="Add template" icon={<Plus size={17} />} variant="primary" disabled={!canWrite} disabledReason={!canWrite ? TEMPLATES_I18N.writeReason : undefined} onClick={() => requestDiscard(() => setCreateOpen(true))} />}
|
||||||
|
/>
|
||||||
<WorkspaceLayout
|
<WorkspaceLayout
|
||||||
variant="split"
|
variant="split"
|
||||||
primarySize="compact"
|
primarySize="compact"
|
||||||
@@ -312,14 +321,6 @@ export default function TemplatesPage({ settings, auth }: Props) {
|
|||||||
contentLabel="Template workspace"
|
contentLabel="Template workspace"
|
||||||
contentClassName="templates-workspace"
|
contentClassName="templates-workspace"
|
||||||
primary={<>
|
primary={<>
|
||||||
<WorkspaceActionBar
|
|
||||||
scope="collection-pane"
|
|
||||||
variant="collection"
|
|
||||||
refreshable
|
|
||||||
reloadAction={{ onReload: () => void reload(selectedId), loading: loading || busy }}
|
|
||||||
contextActions={<strong>Template library</strong>}
|
|
||||||
createAction={<IconButton label="Add template" icon={<Plus size={17} />} variant="primary" disabled={!canWrite} disabledReason={!canWrite ? TEMPLATES_I18N.writeReason : undefined} onClick={() => requestDiscard(() => setCreateOpen(true))} />}
|
|
||||||
/>
|
|
||||||
<FilterBar surface="panel"><input value={search} onChange={(event) => setSearch(event.target.value)} placeholder="Search templates" /></FilterBar>
|
<FilterBar surface="panel"><input value={search} onChange={(event) => setSearch(event.target.value)} placeholder="Search templates" /></FilterBar>
|
||||||
<SelectionList variant="navigation" label="Templates">
|
<SelectionList variant="navigation" label="Templates">
|
||||||
{visibleItems.map((item) => (
|
{visibleItems.map((item) => (
|
||||||
@@ -418,9 +419,11 @@ export default function TemplatesPage({ settings, auth }: Props) {
|
|||||||
</WorkspaceLayout>
|
</WorkspaceLayout>
|
||||||
|
|
||||||
<Dialog open={createOpen} title="Add template" onClose={closeCreate} closeDisabled={busy} footer={<><Button onClick={closeCreate} disabled={busy} disabledReason={busy ? TEMPLATES_I18N.busy : undefined}>Cancel</Button><Button variant="primary" disabled={!createName.trim() || busy} disabledReason={busy ? TEMPLATES_I18N.busy : !createName.trim() ? TEMPLATES_I18N.incomplete : undefined} onClick={() => void create()}>Create</Button></>}>
|
<Dialog open={createOpen} title="Add template" onClose={closeCreate} closeDisabled={busy} footer={<><Button onClick={closeCreate} disabled={busy} disabledReason={busy ? TEMPLATES_I18N.busy : undefined}>Cancel</Button><Button variant="primary" disabled={!createName.trim() || busy} disabledReason={busy ? TEMPLATES_I18N.busy : !createName.trim() ? TEMPLATES_I18N.incomplete : undefined} onClick={() => void create()}>Create</Button></>}>
|
||||||
<DialogSection className="templates-dialog-form">
|
<DialogSection>
|
||||||
|
<FormGrid columns={2} collapseAt="standard">
|
||||||
<FormField label="Name" documentation={TEMPLATE_FIELDS_DOCUMENTATION}><input autoFocus value={createName} onChange={(event) => setCreateName(event.target.value)} /></FormField>
|
<FormField label="Name" documentation={TEMPLATE_FIELDS_DOCUMENTATION}><input autoFocus value={createName} onChange={(event) => setCreateName(event.target.value)} /></FormField>
|
||||||
<FormField label="Type" documentation={TEMPLATE_FIELDS_DOCUMENTATION}><select value={createType} onChange={(event) => setCreateType(event.target.value as TemplateType)}>{TEMPLATE_TYPES.map((item) => <option key={item.value} value={item.value}>{item.label}</option>)}</select></FormField>
|
<FormField label="Type" documentation={TEMPLATE_FIELDS_DOCUMENTATION}><select value={createType} onChange={(event) => setCreateType(event.target.value as TemplateType)}>{TEMPLATE_TYPES.map((item) => <option key={item.value} value={item.value}>{item.label}</option>)}</select></FormField>
|
||||||
|
</FormGrid>
|
||||||
</DialogSection>
|
</DialogSection>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
<ConfirmDialog open={publishOpen} title="i18n:govoplan-templates.publish_title" message="i18n:govoplan-templates.publish_message" confirmLabel="Publish" busy={busy} onCancel={() => setPublishOpen(false)} onConfirm={() => void publish()} />
|
<ConfirmDialog open={publishOpen} title="i18n:govoplan-templates.publish_title" message="i18n:govoplan-templates.publish_message" confirmLabel="Publish" busy={busy} onCancel={() => setPublishOpen(false)} onConfirm={() => void publish()} />
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
.templates-content { height: 100%; min-width: 0; min-height: 0; overflow: auto; padding: 14px; }
|
.templates-content { height: 100%; min-width: 0; min-height: 0; overflow: auto; padding: 14px; }
|
||||||
.templates-definition-fields { display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(130px, .7fr)); gap: 12px; margin-bottom: 14px; }
|
.templates-definition-fields { display: grid; grid-template-columns: minmax(220px, 1.4fr) repeat(3, minmax(130px, .7fr)); gap: 12px; margin-bottom: 14px; }
|
||||||
.templates-definition-fields .form-field:nth-child(5) { grid-column: span 2; }
|
.templates-definition-fields .form-field:nth-child(5) { grid-column: span 2; }
|
||||||
.templates-definition-fields input, .templates-definition-fields select, .templates-dialog-form input, .templates-dialog-form select, .templates-layout-fields input, .templates-layout-fields select, .templates-preview-controls select { width: 100%; }
|
.templates-definition-fields input, .templates-definition-fields select, .templates-layout-fields input, .templates-layout-fields select, .templates-preview-controls select { width: 100%; }
|
||||||
|
|
||||||
.templates-section-heading small { color: var(--muted); font-weight: 400; }
|
.templates-section-heading small { color: var(--muted); font-weight: 400; }
|
||||||
.templates-section-heading .btn { display: inline-flex; align-items: center; gap: 6px; }
|
.templates-section-heading .btn { display: inline-flex; align-items: center; gap: 6px; }
|
||||||
@@ -39,7 +39,6 @@
|
|||||||
.templates-history-list small { margin-top: 3px; color: var(--muted); font-size: 11px; }
|
.templates-history-list small { margin-top: 3px; color: var(--muted); font-size: 11px; }
|
||||||
.templates-history-list .btn { display: inline-flex; align-items: center; gap: 6px; }
|
.templates-history-list .btn { display: inline-flex; align-items: center; gap: 6px; }
|
||||||
.templates-history-badges { display: flex; align-items: center; gap: 6px; }
|
.templates-history-badges { display: flex; align-items: center; gap: 6px; }
|
||||||
.templates-dialog-form { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(180px, .7fr); gap: 12px; min-width: min(560px, 80vw); }
|
|
||||||
|
|
||||||
@media (max-width: 1100px) {
|
@media (max-width: 1100px) {
|
||||||
.templates-definition-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
.templates-definition-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||||
@@ -54,5 +53,5 @@
|
|||||||
.templates-workspace-toolbar { align-items: flex-start; flex-wrap: wrap; }
|
.templates-workspace-toolbar { align-items: flex-start; flex-wrap: wrap; }
|
||||||
.templates-toolbar-actions { flex-wrap: wrap; }
|
.templates-toolbar-actions { flex-wrap: wrap; }
|
||||||
.templates-content { height: auto; overflow: visible; }
|
.templates-content { height: auto; overflow: visible; }
|
||||||
.templates-definition-fields, .templates-dialog-form, .templates-render-result dl { grid-template-columns: 1fr; }
|
.templates-definition-fields, .templates-render-result dl { grid-template-columns: 1fr; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user