Add HTML5 object action links
This commit is contained in:
@@ -473,6 +473,7 @@ def render_html5_object_context(
|
||||
<strong>{escape(str(name))}</strong>
|
||||
<span>{escape(str(getattr(obj, "kind", "object")))}</span>
|
||||
</article>
|
||||
{_object_action_links(project_id, str(name), getattr(obj, "lineage_id", ""), modules)}
|
||||
<dl class="report-grid">
|
||||
{_metric("Attrs", len(attributes))}
|
||||
{_metric("Tables", len(sections))}
|
||||
@@ -1512,6 +1513,34 @@ def _named_node_item(label: str, node: object) -> str:
|
||||
"""
|
||||
|
||||
|
||||
def _object_action_links(project_id: str, object_name: str, lineage_id: object, modules: Iterable[object]) -> str:
|
||||
quoted_project = quote(project_id)
|
||||
quoted_object = quote(object_name, safe="")
|
||||
lineage = str(lineage_id or "")
|
||||
first_module = next(iter(modules), None)
|
||||
module_lineage = str(getattr(first_module, "lineage_id", "") or "")
|
||||
source_link = (
|
||||
f'<a class="button" href="/html5/projects/{quoted_project}/source/{quote(module_lineage, safe="")}">Source</a>'
|
||||
if module_lineage
|
||||
else ""
|
||||
)
|
||||
symbol_link = (
|
||||
f'<a class="button" href="/html5/projects/{quoted_project}/symbols/{quote(lineage, safe="")}/detail">Symbol</a>'
|
||||
if lineage
|
||||
else ""
|
||||
)
|
||||
return f"""
|
||||
<nav class="object-actions" data-html5-object-actions>
|
||||
<a class="button" href="/projects/{quoted_project}/objects/schema/{quoted_object}">Schema</a>
|
||||
<a class="button" href="/projects/{quoted_project}/objects/impact/{quoted_object}">Impact</a>
|
||||
<a class="button" href="/projects/{quoted_project}/objects/privacy/{quoted_object}">Privacy</a>
|
||||
<a class="button" href="/html5/projects/{quoted_project}/flowchart?focus={quoted_object}">Flowchart</a>
|
||||
{source_link}
|
||||
{symbol_link}
|
||||
</nav>
|
||||
"""
|
||||
|
||||
|
||||
def _tabular_section_item(section: object) -> str:
|
||||
tabular_section = getattr(section, "tabular_section", None)
|
||||
columns = getattr(section, "columns", []) or []
|
||||
|
||||
@@ -315,6 +315,9 @@ def test_html5_object_context_fragment(tmp_path: Path):
|
||||
assert "text/html" in context.headers["content-type"]
|
||||
assert "data-html5-object-context" in context.text
|
||||
assert "Документ.ЗаказПокупателя" in context.text
|
||||
assert "data-html5-object-actions" in context.text
|
||||
assert f"/projects/{project_id}/objects/schema/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82.%D0%97%D0%B0%D0%BA%D0%B0%D0%B7%D0%9F%D0%BE%D0%BA%D1%83%D0%BF%D0%B0%D1%82%D0%B5%D0%BB%D1%8F" in context.text
|
||||
assert f"/projects/{project_id}/objects/impact/%D0%94%D0%BE%D0%BA%D1%83%D0%BC%D0%B5%D0%BD%D1%82.%D0%97%D0%B0%D0%BA%D0%B0%D0%B7%D0%9F%D0%BE%D0%BA%D1%83%D0%BF%D0%B0%D1%82%D0%B5%D0%BB%D1%8F" in context.text
|
||||
assert "Контрагент" in context.text
|
||||
assert "Товары" in context.text
|
||||
assert "ФормаДокумента" in context.text
|
||||
|
||||
Reference in New Issue
Block a user