Add product presentation extension contracts
This commit is contained in:
@@ -11,7 +11,16 @@ from govoplan_core.core.module_entitlements import (
|
||||
module_entitlement_payload,
|
||||
tenant_module_entitlement_state,
|
||||
)
|
||||
from govoplan_core.core.modules import FrontendModule, FrontendRoute, ModuleManifest, NavItem, PublicFrontendRoute
|
||||
from govoplan_core.core.modules import (
|
||||
FrontendModule,
|
||||
FrontendRoute,
|
||||
ModuleManifest,
|
||||
NavItem,
|
||||
ProductAreaContribution,
|
||||
PublicFrontendRoute,
|
||||
QuickAccessTool,
|
||||
SUPPORTED_PRESENTATION_CONTRACT_VERSION,
|
||||
)
|
||||
from govoplan_core.core.platform_interfaces import (
|
||||
manifest_interface_catalog,
|
||||
platform_interface_catalog,
|
||||
@@ -132,6 +141,36 @@ def _view_surface_payload(surface: ViewSurface) -> dict[str, object]:
|
||||
}
|
||||
|
||||
|
||||
def _product_area_payload(area: ProductAreaContribution) -> dict[str, object]:
|
||||
return {
|
||||
"id": area.id,
|
||||
"module_id": area.module_id,
|
||||
"label": area.label,
|
||||
"description": area.description,
|
||||
"icon": area.icon,
|
||||
"surface_ids": list(area.surface_ids),
|
||||
"order": area.order,
|
||||
}
|
||||
|
||||
|
||||
def _quick_access_tool_payload(tool: QuickAccessTool) -> dict[str, object]:
|
||||
return {
|
||||
"id": tool.id,
|
||||
"module_id": tool.module_id,
|
||||
"category_id": tool.category_id,
|
||||
"label": tool.label,
|
||||
"description": tool.description,
|
||||
"surface_id": tool.surface_id,
|
||||
"icon": tool.icon,
|
||||
"full_page_path": tool.full_page_path,
|
||||
"required_all": list(tool.required_all),
|
||||
"required_any": list(tool.required_any),
|
||||
"order": tool.order,
|
||||
"default_enabled": tool.default_enabled,
|
||||
"modes": list(tool.modes),
|
||||
}
|
||||
|
||||
|
||||
def _frontend_view_surfaces(manifest: ModuleManifest) -> list[dict[str, object]]:
|
||||
return [
|
||||
_view_surface_payload(surface)
|
||||
@@ -217,6 +256,13 @@ def _frontend_payload(manifest: ModuleManifest) -> dict[str, object] | None:
|
||||
"settings_routes": [_frontend_route_payload(route, manifest.id) for route in frontend.settings_routes],
|
||||
"view_surface_contract_version": VIEW_SURFACE_CONTRACT_VERSION,
|
||||
"view_surfaces": _frontend_view_surfaces(manifest),
|
||||
"presentation_contract_version": SUPPORTED_PRESENTATION_CONTRACT_VERSION,
|
||||
"product_areas": [
|
||||
_product_area_payload(area) for area in frontend.product_areas
|
||||
],
|
||||
"quick_access_tools": [
|
||||
_quick_access_tool_payload(tool) for tool in frontend.quick_access_tools
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user