diff --git a/services/api-server/src/api_server/html5.py b/services/api-server/src/api_server/html5.py index 3187d16..a0d7226 100644 --- a/services/api-server/src/api_server/html5.py +++ b/services/api-server/src/api_server/html5.py @@ -473,6 +473,7 @@ def render_html5_object_context( {escape(str(name))} {escape(str(getattr(obj, "kind", "object")))} + {_object_action_links(project_id, str(name), getattr(obj, "lineage_id", ""), modules)}
{_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'Source' + if module_lineage + else "" + ) + symbol_link = ( + f'Symbol' + if lineage + else "" + ) + return f""" + + """ + + def _tabular_section_item(section: object) -> str: tabular_section = getattr(section, "tabular_section", None) columns = getattr(section, "columns", []) or [] diff --git a/services/api-server/tests/test_api.py b/services/api-server/tests/test_api.py index 61144f7..ce0da6a 100644 --- a/services/api-server/tests/test_api.py +++ b/services/api-server/tests/test_api.py @@ -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