Add server-rendered 1C form editor
CI / python (push) Has been cancelled
CI / rust (push) Has been cancelled

This commit is contained in:
2026-05-17 19:00:02 +03:00
parent 35dd134ebc
commit 02aa084634
6 changed files with 368 additions and 3 deletions
@@ -0,0 +1,41 @@
from __future__ import annotations
from sir import NodeKind, SirSnapshot
def select_form_semantics(forms: list[object], form_id: str | None) -> object | None:
if form_id:
selected = next(
(
item
for item in forms
if getattr(getattr(item, "form", None), "lineage_id", None) == form_id
or getattr(getattr(item, "form", None), "qualified_name", None) == form_id
or getattr(getattr(item, "form", None), "name", None) == form_id
),
None,
)
if selected is not None:
return selected
return forms[0] if forms else None
def form_module_for_form(snapshot: SirSnapshot, form: object | None):
if form is None:
return None
form_lineage = str(getattr(form, "lineage_id", "") or "")
form_qualified = str(getattr(form, "qualified_name", "") or "")
form_name = str(getattr(form, "name", "") or "")
for node in snapshot.nodes:
if node.kind != NodeKind.MODULE:
continue
attributes = node.attributes or {}
if attributes.get("form_lineage_id") == form_lineage:
return node
if attributes.get("form_qualified_name") == form_qualified:
return node
if attributes.get("module_role") == "FORM_MODULE" and attributes.get("form_name") == form_name:
owner_name = str(attributes.get("owner_qualified_name") or "")
if form_qualified.startswith(owner_name):
return node
return None
@@ -0,0 +1,265 @@
from __future__ import annotations
from html import escape
from typing import Iterable
from urllib.parse import quote
from api_server.html5 import _metric, _page, _project_link, _topbar
from api_server.html5_editor import render_html5_source
from sir import SirSnapshot
def render_html5_form_editor(
*,
project_id: str,
projects: Iterable[object],
snapshot: SirSnapshot | None,
forms: Iterable[object],
selected_form_id: str | None = None,
form_module: object | None = None,
error: str | None = None,
) -> str:
project_nav = "\n".join(_project_link(project, project_id) for project in projects)
if error or snapshot is None:
content = f"""
<main class="workspace" data-html5-page="form-editor" data-project-id="{escape(project_id)}">
{_topbar(project_id, project_nav)}
<section class="empty-state" data-html5-error>
<h1>Редактор форм недоступен</h1>
<p>{escape(error or "Snapshot не найден")}</p>
<a class="button" href="/html5/projects/{quote(project_id)}/editor">Открыть IDE</a>
</section>
</main>
"""
return _page(f"SFERA Forms - {project_id}", content)
form_items = list(forms)
selected = _selected_form(form_items, selected_form_id)
selected_form = getattr(selected, "form", None)
selected_lineage = str(getattr(selected_form, "lineage_id", "") or "")
commands = getattr(selected, "commands", []) if selected is not None else []
elements = getattr(selected, "elements", []) if selected is not None else []
handlers = getattr(selected, "command_handlers", {}) if selected is not None else {}
module_lineage = str(getattr(form_module, "lineage_id", "") or "")
form_name = getattr(selected_form, "qualified_name", None) or getattr(selected_form, "name", "Форма")
content = f"""
<main
class="workspace"
data-html5-page="form-editor"
data-project-id="{escape(project_id)}"
data-html5-form-editor
>
{_topbar(project_id, project_nav)}
<section class="layout form-editor-layout">
<aside class="panel tree" data-html5-form-tree>
<div class="panel-title">Формы объекта</div>
<nav>{''.join(_form_tree_item(project_id, item, selected_lineage) for item in form_items) or '<p class="muted padded">Формы не найдены</p>'}</nav>
</aside>
<section class="editor form-editor" data-html5-form-workspace>
<div class="editor-head">
<div>
<p class="eyebrow">HTML5 form editor</p>
<h1>{escape(str(form_name))}</h1>
</div>
<nav class="form-editor-actions">
<a class="button" href="/html5/projects/{quote(project_id)}/editor">IDE</a>
{_module_button(project_id, module_lineage)}
</nav>
</div>
{_form_designer_surface(project_id, selected, form_module)}
</section>
<aside class="panel inspector" data-html5-form-inspector>
<div class="panel-title">Состав формы</div>
<dl class="metrics">
{_metric("Forms", len(form_items))}
{_metric("Commands", len(commands))}
{_metric("Elements", len(elements))}
{_metric("Handlers", len(handlers))}
</dl>
{_form_object_summary(selected, form_module)}
<div class="panel-title">Команды</div>
{_command_list(project_id, commands, handlers)}
<div class="panel-title">Элементы</div>
{_element_list(elements)}
<div class="panel-title">Модуль формы</div>
{render_html5_source(form_module)}
</aside>
</section>
</main>
"""
return _page(f"SFERA Forms - {project_id}", content)
def _selected_form(forms: list[object], selected_form_id: str | None) -> object | None:
if selected_form_id:
selected = next(
(
item
for item in forms
if str(getattr(getattr(item, "form", None), "lineage_id", "")) == selected_form_id
or str(getattr(getattr(item, "form", None), "qualified_name", "")) == selected_form_id
),
None,
)
if selected is not None:
return selected
return forms[0] if forms else None
def _form_tree_item(project_id: str, item: object, selected_lineage: str) -> str:
form = getattr(item, "form", None)
lineage = str(getattr(form, "lineage_id", "") or "")
name = getattr(form, "qualified_name", None) or getattr(form, "name", "Форма")
commands = getattr(item, "commands", []) or []
elements = getattr(item, "elements", []) or []
selected_attr = ' aria-current="page" data-html5-form-selected="true"' if lineage == selected_lineage else ""
return f"""
<a
class="tree-item"
href="/html5/projects/{quote(project_id)}/forms/editor?form={quote(lineage, safe='')}"
hx-get="/html5/projects/{quote(project_id)}/forms/editor?form={quote(lineage, safe='')}"
hx-target="body"
hx-swap="outerHTML"
data-html5-form-tree-item
{selected_attr}
>
<span>Форма</span>
<strong>{escape(str(name))}</strong>
<small>{len(commands)} команд · {len(elements)} элементов</small>
</a>
"""
def _module_button(project_id: str, module_lineage: str) -> str:
if not module_lineage:
return ""
quoted_project = quote(project_id)
quoted_lineage = quote(module_lineage, safe="")
return f"""
<a
class="button"
href="/html5/projects/{quoted_project}/source/{quoted_lineage}"
hx-get="/html5/projects/{quoted_project}/source/{quoted_lineage}"
hx-target="[data-html5-source]"
hx-swap="outerHTML"
data-html5-form-module-action
>Модуль формы</a>
"""
def _form_designer_surface(project_id: str, form_semantics: object | None, form_module: object | None) -> str:
if form_semantics is None:
return '<section class="form-designer" data-html5-form-designer><p class="muted padded">Выберите форму объекта.</p></section>'
form = getattr(form_semantics, "form", None)
commands = getattr(form_semantics, "commands", []) or []
elements = getattr(form_semantics, "elements", []) or []
handlers = getattr(form_semantics, "command_handlers", {}) or {}
form_name = getattr(form, "qualified_name", None) or getattr(form, "name", "Форма")
module_attrs = getattr(form_module, "attributes", {}) or {}
owner = module_attrs.get("owner_qualified_name") or _owner_name_from_form(str(form_name))
return f"""
<section class="form-designer" data-html5-form-designer data-html5-form="{escape(str(form_name))}">
<header class="form-designer-head">
<div>
<strong>{escape(str(form_name))}</strong>
<small>{escape(str(owner))} · объектная форма 1С</small>
</div>
<span data-html5-object-cache="warm">cache-warm</span>
</header>
<div class="form-canvas" data-html5-form-canvas>
<div class="form-window">
<div class="form-window-title">{escape(str(getattr(form, "name", "Форма")))}</div>
<div class="form-command-bar">
{''.join(_canvas_command(command, handlers) for command in commands) or '<span class="muted">Команды не описаны</span>'}
</div>
<div class="form-fields">
{''.join(_canvas_element(element) for element in elements) or '<p class="muted">Элементы формы не описаны в выгрузке.</p>'}
</div>
</div>
</div>
<footer class="form-designer-foot">
<a class="button" href="/html5/projects/{quote(project_id)}/objects/context/{quote(str(owner), safe='')}">Контекст объекта</a>
</footer>
</section>
"""
def _canvas_command(command: object, handlers: dict[str, object]) -> str:
lineage = str(getattr(command, "lineage_id", "") or "")
handler = handlers.get(lineage)
handler_name = getattr(handler, "name", None) or getattr(handler, "qualified_name", None) or "handler?"
return f"""
<button type="button" data-html5-form-command="{escape(lineage)}" title="{escape(str(handler_name))}">
{escape(str(getattr(command, "name", "Команда")))}
</button>
"""
def _canvas_element(element: object) -> str:
name = str(getattr(element, "name", None) or getattr(element, "qualified_name", "Элемент"))
kind = str(getattr(element, "kind", "FORM_ELEMENT"))
return f"""
<label class="form-field" data-html5-form-element="{escape(name)}">
<span>{escape(name)}</span>
<input value="{escape(kind)}" readonly />
</label>
"""
def _form_object_summary(form_semantics: object | None, form_module: object | None) -> str:
if form_semantics is None:
return '<p class="object-summary">Форма не выбрана</p>'
form = getattr(form_semantics, "form", None)
module_attrs = getattr(form_module, "attributes", {}) or {}
owner = module_attrs.get("owner_qualified_name") or _owner_name_from_form(str(getattr(form, "qualified_name", "")))
object_part = module_attrs.get("object_part") or "form.module"
return f"""
<p class="object-summary" data-html5-form-summary>
Форма является частью объекта 1С: {escape(str(owner))} · {escape(str(object_part))}.
Редактор работает с формой целиком: элементы, команды, обработчики и модуль формы.
</p>
"""
def _command_list(project_id: str, commands: Iterable[object], handlers: dict[str, object]) -> str:
items = []
for command in commands:
lineage = str(getattr(command, "lineage_id", "") or "")
handler = handlers.get(lineage)
handler_lineage = str(getattr(handler, "lineage_id", "") or "")
handler_link = (
f'<a href="/html5/projects/{quote(project_id)}/source/{quote(handler_lineage, safe="")}" '
f'hx-get="/html5/projects/{quote(project_id)}/source/{quote(handler_lineage, safe="")}" '
'hx-target="[data-html5-source]" hx-swap="outerHTML">handler</a>'
if handler_lineage
else "<span>handler?</span>"
)
items.append(
f"""
<article class="object-context-item" data-html5-form-command-item>
<strong>{escape(str(getattr(command, "name", "Команда")))}</strong>
<small>{handler_link}</small>
</article>
"""
)
return "".join(items) or '<p class="muted padded">Команды не найдены</p>'
def _element_list(elements: Iterable[object]) -> str:
items = [
f"""
<article class="object-context-item" data-html5-form-element-item>
<strong>{escape(str(getattr(element, "name", "Элемент")))}</strong>
<small>{escape(str(getattr(element, "qualified_name", "")))}</small>
</article>
"""
for element in elements
]
return "".join(items) or '<p class="muted padded">Элементы не найдены</p>'
def _owner_name_from_form(form_name: str) -> str:
parts = form_name.split(".")
if len(parts) >= 2:
return ".".join(parts[:2])
return form_name
@@ -330,7 +330,7 @@ def render_html5_object_context(
or '<p class="muted padded">Реквизиты не найдены</p>' or '<p class="muted padded">Реквизиты не найдены</p>'
) )
compact_body += ''.join(_tabular_section_item(item) for item in sections[:8]) compact_body += ''.join(_tabular_section_item(item) for item in sections[:8])
compact_body += ''.join(_ui_form_item(item) for item in ui_forms[:8]) compact_body += ''.join(_ui_form_item(project_id, item) for item in ui_forms[:8])
elif normalized_mode == "impact": elif normalized_mode == "impact":
compact_body = ''.join(_integration_endpoint_item(item) for item in integration_items[:8]) compact_body = ''.join(_integration_endpoint_item(item) for item in integration_items[:8])
compact_body += ''.join(_named_node_item("command", item) for item in commands[:8]) compact_body += ''.join(_named_node_item("command", item) for item in commands[:8])
@@ -351,7 +351,7 @@ def render_html5_object_context(
or '<p class="muted padded">Реквизиты не найдены</p>' or '<p class="muted padded">Реквизиты не найдены</p>'
) )
compact_body += ''.join(_tabular_section_item(item) for item in sections[:4]) compact_body += ''.join(_tabular_section_item(item) for item in sections[:4])
compact_body += ''.join(_ui_form_item(item) for item in ui_forms[:4]) compact_body += ''.join(_ui_form_item(project_id, item) for item in ui_forms[:4])
compact_body += ''.join(_role_access_item(item) for item in grants[:6]) compact_body += ''.join(_role_access_item(item) for item in grants[:6])
compact_body += ''.join(_integration_endpoint_item(item) for item in integration_items[:4]) compact_body += ''.join(_integration_endpoint_item(item) for item in integration_items[:4])
compact_body += ''.join(_named_node_item("command", item) for item in commands[:6]) compact_body += ''.join(_named_node_item("command", item) for item in commands[:6])
@@ -659,12 +659,13 @@ def _role_access_item(grant: object) -> str:
""" """
def _ui_form_item(form_semantics: object) -> str: def _ui_form_item(project_id: str, form_semantics: object) -> str:
form = getattr(form_semantics, "form", None) form = getattr(form_semantics, "form", None)
commands = getattr(form_semantics, "commands", []) or [] commands = getattr(form_semantics, "commands", []) or []
elements = getattr(form_semantics, "elements", []) or [] elements = getattr(form_semantics, "elements", []) or []
handlers = getattr(form_semantics, "command_handlers", {}) or {} handlers = getattr(form_semantics, "command_handlers", {}) or {}
form_name = getattr(form, "qualified_name", None) or getattr(form, "name", "form") form_name = getattr(form, "qualified_name", None) or getattr(form, "name", "form")
form_lineage = str(getattr(form, "lineage_id", "") or "")
command_names = [ command_names = [
str(getattr(command, "name", getattr(command, "qualified_name", ""))) str(getattr(command, "name", getattr(command, "qualified_name", "")))
for command in commands[:3] for command in commands[:3]
@@ -684,6 +685,15 @@ def _ui_form_item(form_semantics: object) -> str:
<article class="object-context-item" data-html5-object-context-item="ui-form"> <article class="object-context-item" data-html5-object-context-item="ui-form">
<strong>{escape(str(form_name))}</strong> <strong>{escape(str(form_name))}</strong>
<small>{escape(" · ".join(details) or "UI metadata")}</small> <small>{escape(" · ".join(details) or "UI metadata")}</small>
<span class="inline-actions">
<a
href="/html5/projects/{quote(project_id)}/forms/editor?form={quote(form_lineage, safe='')}"
hx-get="/html5/projects/{quote(project_id)}/forms/editor?form={quote(form_lineage, safe='')}"
hx-target="body"
hx-swap="outerHTML"
data-html5-form-editor-link
>Редактор формы</a>
</span>
</article> </article>
""" """
@@ -42,6 +42,10 @@ from api_server.html5_forms import (
html5_metadata_payload as _html5_metadata_payload, html5_metadata_payload as _html5_metadata_payload,
html5_metadata_request_payload as _html5_metadata_request_payload, html5_metadata_request_payload as _html5_metadata_request_payload,
) )
from api_server.form_editor_service import (
form_module_for_form as _form_module_for_form,
select_form_semantics as _select_form_semantics,
)
from api_server.html5_projects import render_html5_index, render_html5_project_rows from api_server.html5_projects import render_html5_index, render_html5_project_rows
from api_server.html5_responses import ( from api_server.html5_responses import (
Html5StaticFiles, Html5StaticFiles,
@@ -76,6 +80,7 @@ from api_server.html5_editor import (
render_html5_symbol_detail, render_html5_symbol_detail,
render_html5_symbols, render_html5_symbols,
) )
from api_server.html5_form_editor import render_html5_form_editor
from api_server.html5_operations import ( from api_server.html5_operations import (
filter_html5_operation_jobs, filter_html5_operation_jobs,
latest_html5_import_job, latest_html5_import_job,
@@ -1730,6 +1735,32 @@ async def html5_project_editor(project_id: str, q: str = "") -> Response:
return _html5_response(html) return _html5_response(html)
@app.get("/html5/projects/{project_id}/forms/editor")
async def html5_project_form_editor(project_id: str, form: str | None = None) -> Response:
try:
snapshot = _project_snapshot_or_404(project_id)
forms = [_form_semantics_response(item) for item in form_semantics(snapshot)]
selected = _select_form_semantics(forms, form)
form_module = _form_module_for_form(snapshot, selected.form if selected is not None else None)
html = render_html5_form_editor(
project_id=project_id,
projects=_project_summaries(),
snapshot=snapshot,
forms=forms,
selected_form_id=form,
form_module=form_module,
)
except HTTPException as error:
html = render_html5_form_editor(
project_id=project_id,
projects=_project_summaries(),
snapshot=None,
forms=[],
error=str(error.detail),
)
return _html5_response(html)
@app.get("/html5/projects/{project_id}/events") @app.get("/html5/projects/{project_id}/events")
async def html5_project_events(project_id: str, once: bool = False) -> StreamingResponse: async def html5_project_events(project_id: str, once: bool = False) -> StreamingResponse:
async def stream_status(): async def stream_status():
@@ -7,5 +7,6 @@
.editor{min-width:0;overflow:hidden;border-top:0;border-bottom:0}.editor-head{height:72px;border-bottom:1px solid var(--line);padding:0 14px}.editor-head h1{margin:0;font-size:18px}.search{display:flex;gap:6px}.search input{height:32px;width:260px;border:1px solid var(--line);padding:0 10px}.source-panel{height:calc(100% - 72px);display:grid;grid-template-rows:auto auto auto minmax(0,1fr);overflow:hidden}.source-head{display:flex;justify-content:space-between;gap:12px;align-items:center;min-height:54px;padding:10px 14px;border-bottom:1px solid var(--line);background:#fff}.source-head strong,.source-head small{display:block}.source-head small{color:var(--muted)}.source-head dl{display:flex;gap:12px;margin:0}.source-head div div{padding:0}.source-head dt{font-size:11px;color:var(--muted)}.source-head dd{margin:0;font-weight:800}.source-summary,.object-cache{margin:0;padding:8px 14px;border-bottom:1px solid var(--line);background:#fffdf8;color:var(--muted);font-size:12px;font-weight:800;line-height:1.45}.object-cache{background:#f8fbff}.code{height:100%;margin:0;overflow:auto;padding:16px;background:#fbfaf7;font:13px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap} .editor{min-width:0;overflow:hidden;border-top:0;border-bottom:0}.editor-head{height:72px;border-bottom:1px solid var(--line);padding:0 14px}.editor-head h1{margin:0;font-size:18px}.search{display:flex;gap:6px}.search input{height:32px;width:260px;border:1px solid var(--line);padding:0 10px}.source-panel{height:calc(100% - 72px);display:grid;grid-template-rows:auto auto auto minmax(0,1fr);overflow:hidden}.source-head{display:flex;justify-content:space-between;gap:12px;align-items:center;min-height:54px;padding:10px 14px;border-bottom:1px solid var(--line);background:#fff}.source-head strong,.source-head small{display:block}.source-head small{color:var(--muted)}.source-head dl{display:flex;gap:12px;margin:0}.source-head div div{padding:0}.source-head dt{font-size:11px;color:var(--muted)}.source-head dd{margin:0;font-weight:800}.source-summary,.object-cache{margin:0;padding:8px 14px;border-bottom:1px solid var(--line);background:#fffdf8;color:var(--muted);font-size:12px;font-weight:800;line-height:1.45}.object-cache{background:#f8fbff}.code{height:100%;margin:0;overflow:auto;padding:16px;background:#fbfaf7;font:13px/1.55 ui-monospace,SFMono-Regular,Consolas,monospace;white-space:pre-wrap}
.metrics{display:grid;grid-template-columns:1fr 1fr;margin:0}.metrics div{padding:12px;border-bottom:1px solid var(--line)}.metrics dt{color:var(--muted);font-size:12px}.metrics dd{margin:2px 0 0;font-size:22px;font-weight:800}.compact{list-style:none;margin:0;padding:0}.compact li{display:flex;justify-content:space-between;padding:8px 12px;border-bottom:1px solid var(--line)}.object-actions{display:flex;gap:6px;flex-wrap:wrap;padding:10px 12px;border-bottom:1px solid var(--line);background:#fbfcfe}.object-actions .button{height:28px;padding:0 9px;font-size:12px}.object-actions .button[data-html5-object-action-active="true"],.object-actions .button[aria-current="page"]{background:var(--brand);border-color:var(--brand);color:#fff}.object-breadcrumb{display:flex;gap:6px;flex-wrap:wrap;padding:9px 12px;border-bottom:1px solid var(--line);background:#fff;font-size:12px;font-weight:800;color:var(--muted)}.object-breadcrumb span:not(:last-child)::after{content:"/";margin-left:6px;color:#98a2b3}.object-breadcrumb span:last-child{color:var(--ink)}.object-summary,.symbol-summary,.review-summary,.project-summary,.object-report-summary,.authoring-summary{margin:0;padding:10px 12px;border-bottom:1px solid var(--line);background:#f8fbff;color:var(--muted);font-size:12px;font-weight:800;line-height:1.45}.symbol{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line);cursor:pointer}.symbol:hover{background:#f8fbff}.symbol span,.symbol small{color:var(--muted)}.symbol-focus,.symbol-reference,.object-focus,.object-context-item{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.symbol-focus small,.symbol-reference span,.symbol-reference small,.object-focus span,.object-context-item small{color:var(--muted)}.inline-actions{display:flex;gap:8px;flex-wrap:wrap;font-size:12px;font-weight:800}.inline-actions a{color:var(--brand);text-decoration:none}.report-grid{display:grid;grid-template-columns:1fr 1fr;margin:0}.report-grid div{padding:10px 12px;border-bottom:1px solid var(--line)}.report-grid dt{color:var(--muted);font-size:12px}.report-grid dd{margin:2px 0 0;font-size:20px;font-weight:900}.review-item,.authoring-change{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.authoring-change[hx-get]{cursor:pointer}.authoring-change[hx-get]:hover{background:#f8fbff}.review-item span,.review-item small,.authoring-change span,.authoring-change small{color:var(--muted)}.diff-item{display:grid;grid-template-columns:72px minmax(0,1fr);gap:8px;padding:8px 12px;border-bottom:1px solid var(--line)}.diff-item span{color:var(--muted);font-weight:800}.diff-item code{white-space:pre-wrap;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px}.status{position:fixed;bottom:0;left:0;right:0;display:flex;gap:18px;overflow:auto;height:34px;align-items:center;border-top:1px solid var(--line);background:#fff;padding:0 12px;color:var(--muted);font-size:12px}.empty-state{max-width:720px;margin:80px auto;background:#fff;border:1px solid var(--line);padding:28px} .metrics{display:grid;grid-template-columns:1fr 1fr;margin:0}.metrics div{padding:12px;border-bottom:1px solid var(--line)}.metrics dt{color:var(--muted);font-size:12px}.metrics dd{margin:2px 0 0;font-size:22px;font-weight:800}.compact{list-style:none;margin:0;padding:0}.compact li{display:flex;justify-content:space-between;padding:8px 12px;border-bottom:1px solid var(--line)}.object-actions{display:flex;gap:6px;flex-wrap:wrap;padding:10px 12px;border-bottom:1px solid var(--line);background:#fbfcfe}.object-actions .button{height:28px;padding:0 9px;font-size:12px}.object-actions .button[data-html5-object-action-active="true"],.object-actions .button[aria-current="page"]{background:var(--brand);border-color:var(--brand);color:#fff}.object-breadcrumb{display:flex;gap:6px;flex-wrap:wrap;padding:9px 12px;border-bottom:1px solid var(--line);background:#fff;font-size:12px;font-weight:800;color:var(--muted)}.object-breadcrumb span:not(:last-child)::after{content:"/";margin-left:6px;color:#98a2b3}.object-breadcrumb span:last-child{color:var(--ink)}.object-summary,.symbol-summary,.review-summary,.project-summary,.object-report-summary,.authoring-summary{margin:0;padding:10px 12px;border-bottom:1px solid var(--line);background:#f8fbff;color:var(--muted);font-size:12px;font-weight:800;line-height:1.45}.symbol{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line);cursor:pointer}.symbol:hover{background:#f8fbff}.symbol span,.symbol small{color:var(--muted)}.symbol-focus,.symbol-reference,.object-focus,.object-context-item{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.symbol-focus small,.symbol-reference span,.symbol-reference small,.object-focus span,.object-context-item small{color:var(--muted)}.inline-actions{display:flex;gap:8px;flex-wrap:wrap;font-size:12px;font-weight:800}.inline-actions a{color:var(--brand);text-decoration:none}.report-grid{display:grid;grid-template-columns:1fr 1fr;margin:0}.report-grid div{padding:10px 12px;border-bottom:1px solid var(--line)}.report-grid dt{color:var(--muted);font-size:12px}.report-grid dd{margin:2px 0 0;font-size:20px;font-weight:900}.review-item,.authoring-change{display:grid;gap:3px;padding:10px 12px;border-bottom:1px solid var(--line)}.authoring-change[hx-get]{cursor:pointer}.authoring-change[hx-get]:hover{background:#f8fbff}.review-item span,.review-item small,.authoring-change span,.authoring-change small{color:var(--muted)}.diff-item{display:grid;grid-template-columns:72px minmax(0,1fr);gap:8px;padding:8px 12px;border-bottom:1px solid var(--line)}.diff-item span{color:var(--muted);font-weight:800}.diff-item code{white-space:pre-wrap;font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px}.status{position:fixed;bottom:0;left:0;right:0;display:flex;gap:18px;overflow:auto;height:34px;align-items:center;border-top:1px solid var(--line);background:#fff;padding:0 12px;color:var(--muted);font-size:12px}.empty-state{max-width:720px;margin:80px auto;background:#fff;border:1px solid var(--line);padding:28px}
.setup-layout{display:grid;grid-template-columns:340px minmax(0,1fr);gap:16px;max-width:1180px;margin:18px auto;padding:0 16px}.setup-workspace{background:#f3f6fb}.setup-card{padding:16px;border-bottom:1px solid var(--line)}.setup-card h1{margin:0;font-size:24px}.setup-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}.setup-main{min-height:620px}.settings-form{display:grid;grid-template-columns:2fr 1fr 1fr auto;gap:8px;align-items:end;padding:12px 16px;border-bottom:1px solid var(--line);background:#fff}.settings-form label{display:grid;gap:4px;font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase}.settings-form input{height:32px;border:1px solid var(--line);padding:0 8px}.saved{float:right;color:var(--ok);font-weight:900}.setup-actions-panel,.ops-filter{display:flex;gap:8px;flex-wrap:wrap;align-items:end;padding:12px 16px;border-bottom:1px solid var(--line);background:#fbfcfe}.ops-filter input{height:32px;min-width:180px;border:1px solid var(--line);padding:0 8px}.inline-form{display:flex;gap:8px;align-items:end}.inline-form label{display:grid;gap:4px;font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase}.inline-form select{height:32px;min-width:240px;border:1px solid var(--line);background:#fff;padding:0 8px}.rollback-form,.authoring-preview-form{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:12px;border-bottom:1px solid var(--line);background:#fbfcfe}.rollback-form input,.authoring-preview-form input,.authoring-preview-form textarea{min-width:0;border:1px solid var(--line);padding:0 8px}.rollback-form input,.authoring-preview-form input{height:32px}.authoring-preview-form textarea{grid-column:1/-1;min-height:88px;padding:8px;resize:vertical;font:12px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace}.rollback-form button,.authoring-preview-form button{grid-column:1/-1}.setup-summary{display:grid;gap:0}.compact-lead{margin:0;padding:0 16px 16px}.setup-metrics,.ops-summary{display:grid;grid-template-columns:repeat(4,1fr);margin:0;border-top:1px solid var(--line)}.ops-summary{grid-template-columns:repeat(5,1fr);margin:12px 0}.setup-metrics div,.ops-summary div{padding:16px;border-right:1px solid var(--line);border-bottom:1px solid var(--line);background:#fff}.setup-metrics div:last-child,.ops-summary div:last-child{border-right:0}.setup-metrics dt,.ops-summary dt{font-size:12px;color:var(--muted)}.setup-metrics dd,.ops-summary dd{margin:4px 0 0;font-size:28px;font-weight:900}.status-pill{border:1px solid var(--line);padding:6px 10px;background:#eef6f1;color:var(--ok);font-weight:800}.flush{border-top:1px solid var(--line)}.padded{padding:12px 16px;margin:0}.setup-detail,.history-item,.source-card,.check-item{display:grid;gap:3px;padding:12px 16px;border-bottom:1px solid var(--line)}.setup-detail span,.setup-detail small,.history-item span,.history-item small,.source-card span,.source-card small,.check-item span,.check-item small,.check-head span,.check-head small{color:var(--muted)}.source-list,.history-list,.check-list{display:grid}.check-head{display:flex;gap:10px;align-items:center;padding:12px 16px;border-bottom:1px solid var(--line);background:#fff}.job-log{margin:0;padding:0;list-style:none}.job-log li{padding:8px 16px;border-bottom:1px solid var(--line);color:var(--muted);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px} .setup-layout{display:grid;grid-template-columns:340px minmax(0,1fr);gap:16px;max-width:1180px;margin:18px auto;padding:0 16px}.setup-workspace{background:#f3f6fb}.setup-card{padding:16px;border-bottom:1px solid var(--line)}.setup-card h1{margin:0;font-size:24px}.setup-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:14px}.setup-main{min-height:620px}.settings-form{display:grid;grid-template-columns:2fr 1fr 1fr auto;gap:8px;align-items:end;padding:12px 16px;border-bottom:1px solid var(--line);background:#fff}.settings-form label{display:grid;gap:4px;font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase}.settings-form input{height:32px;border:1px solid var(--line);padding:0 8px}.saved{float:right;color:var(--ok);font-weight:900}.setup-actions-panel,.ops-filter{display:flex;gap:8px;flex-wrap:wrap;align-items:end;padding:12px 16px;border-bottom:1px solid var(--line);background:#fbfcfe}.ops-filter input{height:32px;min-width:180px;border:1px solid var(--line);padding:0 8px}.inline-form{display:flex;gap:8px;align-items:end}.inline-form label{display:grid;gap:4px;font-size:12px;font-weight:800;color:var(--muted);text-transform:uppercase}.inline-form select{height:32px;min-width:240px;border:1px solid var(--line);background:#fff;padding:0 8px}.rollback-form,.authoring-preview-form{display:grid;grid-template-columns:1fr 1fr;gap:8px;padding:12px;border-bottom:1px solid var(--line);background:#fbfcfe}.rollback-form input,.authoring-preview-form input,.authoring-preview-form textarea{min-width:0;border:1px solid var(--line);padding:0 8px}.rollback-form input,.authoring-preview-form input{height:32px}.authoring-preview-form textarea{grid-column:1/-1;min-height:88px;padding:8px;resize:vertical;font:12px/1.45 ui-monospace,SFMono-Regular,Consolas,monospace}.rollback-form button,.authoring-preview-form button{grid-column:1/-1}.setup-summary{display:grid;gap:0}.compact-lead{margin:0;padding:0 16px 16px}.setup-metrics,.ops-summary{display:grid;grid-template-columns:repeat(4,1fr);margin:0;border-top:1px solid var(--line)}.ops-summary{grid-template-columns:repeat(5,1fr);margin:12px 0}.setup-metrics div,.ops-summary div{padding:16px;border-right:1px solid var(--line);border-bottom:1px solid var(--line);background:#fff}.setup-metrics div:last-child,.ops-summary div:last-child{border-right:0}.setup-metrics dt,.ops-summary dt{font-size:12px;color:var(--muted)}.setup-metrics dd,.ops-summary dd{margin:4px 0 0;font-size:28px;font-weight:900}.status-pill{border:1px solid var(--line);padding:6px 10px;background:#eef6f1;color:var(--ok);font-weight:800}.flush{border-top:1px solid var(--line)}.padded{padding:12px 16px;margin:0}.setup-detail,.history-item,.source-card,.check-item{display:grid;gap:3px;padding:12px 16px;border-bottom:1px solid var(--line)}.setup-detail span,.setup-detail small,.history-item span,.history-item small,.source-card span,.source-card small,.check-item span,.check-item small,.check-head span,.check-head small{color:var(--muted)}.source-list,.history-list,.check-list{display:grid}.check-head{display:flex;gap:10px;align-items:center;padding:12px 16px;border-bottom:1px solid var(--line);background:#fff}.job-log{margin:0;padding:0;list-style:none}.job-log li{padding:8px 16px;border-bottom:1px solid var(--line);color:var(--muted);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:12px}
.form-editor-layout{grid-template-columns:280px minmax(0,1.2fr) minmax(320px,.8fr)}.form-editor-actions{display:flex;gap:8px;flex-wrap:wrap}.tree-item[data-html5-form-selected="true"]{background:#f8fbff;border-left-color:var(--brand)}.form-designer{height:calc(100% - 72px);display:grid;grid-template-rows:auto minmax(0,1fr) auto;overflow:hidden;background:#f7f9fc}.form-designer-head,.form-designer-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 14px;border-bottom:1px solid var(--line);background:#fff}.form-designer-head strong,.form-designer-head small{display:block}.form-designer-head small{color:var(--muted)}.form-designer-head span{border:1px solid var(--line);background:#eef6f1;color:var(--ok);padding:5px 8px;font-size:12px;font-weight:900}.form-designer-foot{border-top:1px solid var(--line);border-bottom:0}.form-canvas{min-height:0;overflow:auto;padding:18px}.form-window{max-width:720px;min-height:420px;margin:0 auto;border:1px solid var(--line);background:#fff;box-shadow:0 8px 24px rgba(15,23,42,.08)}.form-window-title{height:38px;display:flex;align-items:center;border-bottom:1px solid var(--line);padding:0 12px;font-weight:900;background:#fbfcfe}.form-command-bar{display:flex;gap:6px;flex-wrap:wrap;padding:10px 12px;border-bottom:1px solid var(--line)}.form-command-bar button{height:28px;font-size:12px}.form-fields{display:grid;gap:10px;padding:14px}.form-field{display:grid;grid-template-columns:160px minmax(0,1fr);gap:8px;align-items:center}.form-field span{font-size:12px;font-weight:800;color:var(--muted)}.form-field input{height:30px;border:1px solid var(--line);padding:0 8px;background:#fbfaf7}
@media(max-width:980px){.layout{grid-template-columns:1fr;height:auto}.tree,.inspector{max-height:320px}.editor{min-height:520px}.hero{display:block}.shell{padding:16px}} @media(max-width:980px){.layout{grid-template-columns:1fr;height:auto}.tree,.inspector{max-height:320px}.editor{min-height:520px}.hero{display:block}.shell{padding:16px}}
@media(max-width:980px){.setup-layout{grid-template-columns:1fr}.setup-metrics{grid-template-columns:1fr 1fr}.settings-form{grid-template-columns:1fr}} @media(max-width:980px){.setup-layout{grid-template-columns:1fr}.setup-metrics{grid-template-columns:1fr 1fr}.settings-form{grid-template-columns:1fr}}
+17
View File
@@ -570,6 +570,7 @@ def test_html5_object_context_fragment(tmp_path: Path):
assert indexed.status_code == 200 assert indexed.status_code == 200
snapshot = client.get(f"/projects/{project_id}/snapshot/export").json() snapshot = client.get(f"/projects/{project_id}/snapshot/export").json()
handler = next(node for node in snapshot["nodes"] if node["name"] == "ПровестиКоманда") handler = next(node for node in snapshot["nodes"] if node["name"] == "ПровестиКоманда")
form_node = next(node for node in snapshot["nodes"] if node["name"] == "ФормаДокумента")
attribute = next(node for node in snapshot["nodes"] if node["name"] == "Контрагент") attribute = next(node for node in snapshot["nodes"] if node["name"] == "Контрагент")
signal = client.post( signal = client.post(
f"/projects/{project_id}/runtime/signals", f"/projects/{project_id}/runtime/signals",
@@ -648,6 +649,7 @@ def test_html5_object_context_fragment(tmp_path: Path):
assert "Контрагент" in context.text assert "Контрагент" in context.text
assert "Товары" in context.text assert "Товары" in context.text
assert "ФормаДокумента" in context.text assert "ФормаДокумента" in context.text
assert "data-html5-form-editor-link" in context.text
assert "Провести" in context.text assert "Провести" in context.text
assert "ПровестиКоманда" in context.text assert "ПровестиКоманда" in context.text
assert "ПроверитьКонтрагента" in context.text assert "ПроверитьКонтрагента" in context.text
@@ -676,6 +678,21 @@ def test_html5_object_context_fragment(tmp_path: Path):
assert "data-html5-project-report" in context.text assert "data-html5-project-report" in context.text
assert "Отчет объекта" in context.text assert "Отчет объекта" in context.text
assert "server focused summary" in context.text assert "server focused summary" in context.text
form_editor = client.get(
f"/html5/projects/{project_id}/forms/editor",
params={"form": form_node["lineage_id"]},
)
assert form_editor.status_code == 200
assert "data-html5-page=\"form-editor\"" in form_editor.text
assert "data-html5-form-designer" in form_editor.text
assert "data-html5-form-canvas" in form_editor.text
assert "Документ.ЗаказПокупателя.ФормаДокумента" in form_editor.text
assert "Провести" in form_editor.text
assert "ПровестиКоманда" in form_editor.text
assert "Модуль формы" in form_editor.text
assert 'data-html5-object-cache="warm"' in form_editor.text
assert "ПриОткрытии" in form_editor.text
assert "data-html5-object-report-summary" in context.text assert "data-html5-object-report-summary" in context.text
assert "data links" in context.text assert "data links" in context.text
assert "data-html5-review" in context.text assert "data-html5-review" in context.text