From c67e8e93235af6cb7832dab1ce61d9dd79bff261 Mon Sep 17 00:00:00 2001 From: "Ouin, Edouard" Date: Tue, 19 May 2026 11:26:04 +0100 Subject: [PATCH 01/51] feat add other aggregations to page building block --- .../fe-fpm-writer/src/building-block/index.ts | 152 +++++++++++++++ .../building-block/prompts/questions/page.ts | 11 ++ .../fe-fpm-writer/src/building-block/types.ts | 7 + packages/fe-fpm-writer/src/index.ts | 8 +- .../src/prompts/translations/i18n.ts | 5 + .../building-block/page/Controller.js | 17 ++ .../building-block/page/Controller.ts | 14 ++ .../templates/building-block/page/View.xml | 3 +- .../templates/building-block/page/actions.xml | 5 + .../building-block/page/breadcrumbs.xml | 8 + .../templates/building-block/page/footer.xml | 4 + .../building-block/page/headerContent.xml | 6 + .../templates/building-block/page/items.xml | 1 + .../building-block/page/navigationActions.xml | 4 + .../building-block/page/titleContent.xml | 4 + .../test/unit/building-block.test.ts | 175 +++++++++++++++++- .../__snapshots__/prompts.test.ts.snap | 38 ++++ 17 files changed, 459 insertions(+), 3 deletions(-) create mode 100644 packages/fe-fpm-writer/templates/building-block/page/Controller.js create mode 100644 packages/fe-fpm-writer/templates/building-block/page/Controller.ts create mode 100644 packages/fe-fpm-writer/templates/building-block/page/actions.xml create mode 100644 packages/fe-fpm-writer/templates/building-block/page/breadcrumbs.xml create mode 100644 packages/fe-fpm-writer/templates/building-block/page/footer.xml create mode 100644 packages/fe-fpm-writer/templates/building-block/page/headerContent.xml create mode 100644 packages/fe-fpm-writer/templates/building-block/page/items.xml create mode 100644 packages/fe-fpm-writer/templates/building-block/page/navigationActions.xml create mode 100644 packages/fe-fpm-writer/templates/building-block/page/titleContent.xml diff --git a/packages/fe-fpm-writer/src/building-block/index.ts b/packages/fe-fpm-writer/src/building-block/index.ts index 9e7769c3bdf..6b4475386a8 100644 --- a/packages/fe-fpm-writer/src/building-block/index.ts +++ b/packages/fe-fpm-writer/src/building-block/index.ts @@ -14,6 +14,7 @@ import { type BuildingBlock, type BuildingBlockConfig, type BuildingBlockMetaPath, + type Page, bindingContextAbsolute, type TemplateConfig } from './types'; @@ -23,10 +24,12 @@ import { getTemplatePath } from '../templates'; import { CodeSnippetLanguage, type FilePathProps, type CodeSnippet } from '../prompts/types'; import { CONFIG, + copyTpl, createIdGenerator, detectTabSpacing, extendJSON, getRelativeTemplateComponentPath, + type IdGeneratorFunction, type TemplateContext } from '../common/file'; import { getManifest, getManifestPath } from '../common/utils'; @@ -94,6 +97,13 @@ export async function generateBuildingBlock( templateConfig ); + if ( + buildingBlockData.buildingBlockType === BuildingBlockType.Page && + (buildingBlockData as Page).templateType === 'full' + ) { + appendPageAggregations(fs, xmlDocument, templateDocument, fnGenerateId); + } + if ( buildingBlockData.buildingBlockType === BuildingBlockType.RichTextEditor || buildingBlockData.buildingBlockType === BuildingBlockType.RichTextEditorButtonGroups @@ -116,6 +126,13 @@ export async function generateBuildingBlock( config.replace ); + if ( + buildingBlockData.buildingBlockType === BuildingBlockType.Page && + (buildingBlockData as Page).templateType === 'full' + ) { + applyPageControllerTemplate(fs, basePath, viewOrFragmentPath); + } + if (allowAutoAddDependencyLib && manifest && !validateDependenciesLibs(manifest, ['sap.fe.macros'])) { // "sap.fe.macros" is missing - enhance manifest.json for missing "sap.fe.macros" const manifestPath = await getManifestPath(basePath, fs); @@ -132,6 +149,141 @@ export async function generateBuildingBlock( return fs; } +export const PAGE_AGGREGATIONS = [ + 'breadcrumbs', + 'navigationActions', + 'titleContent', + 'actions', + 'headerContent', + 'items', + 'footer' +] as const; + +export type PageAggregationName = (typeof PAGE_AGGREGATIONS)[number]; + +/** + * Appends the 7 Page building block aggregation fragments as child elements of the templateDocument root. + * + * @param {Editor} fs - the memfs editor instance + * @param {Document} xmlDocument - the view XML document (used to resolve namespace prefixes) + * @param {Document} templateDocument - the template document whose root element receives the children + * @param {IdGeneratorFunction} generateId - function to generate unique IDs + */ +function appendPageAggregations( + fs: Editor, + xmlDocument: Document, + templateDocument: Document, + generateId: IdGeneratorFunction +): void { + const macrosNS = getOrAddNamespace(xmlDocument, 'sap.fe.macros', 'macros'); + const mNS = getOrAddNamespace(xmlDocument, 'sap.m', 'm'); + // getOrAddNamespace returns '' when the namespace is the document's default (xmlns="..."). + // For macros:Page aggregations, macros always has an explicit prefix. + // For sap.m, honour the default namespace by keeping mPrefix empty so elements render + // as bare names (e.g.