@siliconst/metaui 1.4.4 → 1.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost-dbg.js +40 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.d.ts +6 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.ts +44 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate-dbg.js +122 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.d.ts +49 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ODataDelegate.ts +118 -0
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator-dbg.js +24 -8
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.d.ts +1 -0
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/DefaultLayoutGenerator.ts +26 -9
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js +45 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts +10 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.ts +45 -2
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout-dbg.js +10 -6
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.ts +5 -5
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js +10 -6
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.ts +5 -5
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js +22 -29
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.ts +18 -29
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout-dbg.js +8 -4
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/WizardLayout.ts +3 -3
- package/src/nz/co/siliconst/ui5/metaui/library-preload.js +8 -7
- package/src/nz/co/siliconst/ui5/metaui/library-preload.js.map +1 -1
|
@@ -177,10 +177,9 @@ export class SchemaNormalizer {
|
|
|
177
177
|
const val = obj[key];
|
|
178
178
|
if (val === null || val === undefined) continue;
|
|
179
179
|
|
|
180
|
-
if (typeof val === "object" && !Array.isArray(val)) continue;
|
|
181
|
-
|
|
182
180
|
let type: FieldType = "string";
|
|
183
181
|
let items: IPropertyMetadata | undefined;
|
|
182
|
+
let nestedProps: Record<string, IPropertyMetadata> | undefined;
|
|
184
183
|
|
|
185
184
|
if (typeof val === "number") type = "number";
|
|
186
185
|
else if (typeof val === "boolean") type = "boolean";
|
|
@@ -190,11 +189,15 @@ export class SchemaNormalizer {
|
|
|
190
189
|
type: "object",
|
|
191
190
|
properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}
|
|
192
191
|
};
|
|
192
|
+
} else if (typeof val === "object") {
|
|
193
|
+
type = "object";
|
|
194
|
+
nestedProps = this.inferPropertiesFromObject(val);
|
|
193
195
|
}
|
|
194
196
|
|
|
195
197
|
properties[key] = {
|
|
196
198
|
type,
|
|
197
199
|
items,
|
|
200
|
+
properties: nestedProps,
|
|
198
201
|
ui: {
|
|
199
202
|
label: this.generateLabel(key),
|
|
200
203
|
isKey: false,
|
|
@@ -205,4 +208,44 @@ export class SchemaNormalizer {
|
|
|
205
208
|
|
|
206
209
|
return properties;
|
|
207
210
|
}
|
|
211
|
+
|
|
212
|
+
/**
|
|
213
|
+
* Resolves a JSON Schema scope (e.g. '#/properties/header/properties/id')
|
|
214
|
+
* against the ISchema, returning the PropertyMetadata and the UI5 binding path.
|
|
215
|
+
*/
|
|
216
|
+
public static resolveScope(schema: ISchema, scope: string): { meta: IPropertyMetadata | undefined, bindingPath: string, propKey: string } {
|
|
217
|
+
if (!scope || !scope.startsWith("#/properties/")) {
|
|
218
|
+
return { meta: undefined, bindingPath: scope || "", propKey: scope || "" };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const pathSegments = scope.replace("#/properties/", "").split("/properties/");
|
|
222
|
+
let current: any = schema.properties;
|
|
223
|
+
let meta: IPropertyMetadata | undefined;
|
|
224
|
+
|
|
225
|
+
Logger.debug("[MetaUI SchemaNormalizer]", `Resolving scope '${scope}' with segments: ${JSON.stringify(pathSegments)}`, "SchemaNormalizer");
|
|
226
|
+
Logger.debug("[MetaUI SchemaNormalizer]", `Root schema keys: ${Object.keys(schema.properties || {})}`, "SchemaNormalizer");
|
|
227
|
+
|
|
228
|
+
for (let i = 0; i < pathSegments.length; i++) {
|
|
229
|
+
const segment = pathSegments[i];
|
|
230
|
+
if (!current) {
|
|
231
|
+
Logger.debug("[MetaUI SchemaNormalizer]", `current is undefined at segment '${segment}'`, "SchemaNormalizer");
|
|
232
|
+
meta = undefined;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
meta = current[segment];
|
|
236
|
+
Logger.debug("[MetaUI SchemaNormalizer]", `Segment '${segment}' resolved to meta: ${!!meta}. Available keys in current: ${Object.keys(current)}`, "SchemaNormalizer");
|
|
237
|
+
if (i < pathSegments.length - 1) {
|
|
238
|
+
current = meta?.properties;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const bindingPath = pathSegments.join("/");
|
|
243
|
+
const propKey = scope.replace("#/properties/", ""); // The original raw string for logging
|
|
244
|
+
|
|
245
|
+
return {
|
|
246
|
+
meta,
|
|
247
|
+
bindingPath,
|
|
248
|
+
propKey
|
|
249
|
+
};
|
|
250
|
+
}
|
|
208
251
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
sap.ui.define(["sap/m/VBox", "sap/m/Label", "../utils/Logger"], function (VBox, Label, ___utils_Logger) {
|
|
1
|
+
sap.ui.define(["sap/m/VBox", "sap/m/Label", "../core/SchemaNormalizer", "../utils/Logger"], function (VBox, Label, ___core_SchemaNormalizer, ___utils_Logger) {
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
+
const SchemaNormalizer = ___core_SchemaNormalizer["SchemaNormalizer"];
|
|
4
5
|
const Logger = ___utils_Logger["Logger"];
|
|
5
6
|
/**
|
|
6
7
|
* Layout Manager responsible for generating a dense, lightweight layout (no SimpleForm padding).
|
|
@@ -49,8 +50,11 @@ sap.ui.define(["sap/m/VBox", "sap/m/Label", "../utils/Logger"], function (VBox,
|
|
|
49
50
|
Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, "", "CompactLayout");
|
|
50
51
|
return;
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
-
|
|
53
|
+
const {
|
|
54
|
+
meta,
|
|
55
|
+
bindingPath,
|
|
56
|
+
propKey
|
|
57
|
+
} = SchemaNormalizer.resolveScope(schema, element.scope);
|
|
54
58
|
if (!meta) {
|
|
55
59
|
Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, "", "CompactLayout");
|
|
56
60
|
return;
|
|
@@ -61,13 +65,13 @@ sap.ui.define(["sap/m/VBox", "sap/m/Label", "../utils/Logger"], function (VBox,
|
|
|
61
65
|
if (isSubLayout) {
|
|
62
66
|
Logger.debug("[MetaUI CompactLayout]", `Routing property '${propKey}' to Table Sub-Layout.`, "CompactLayout");
|
|
63
67
|
tableElements.push({
|
|
64
|
-
scope:
|
|
68
|
+
scope: bindingPath,
|
|
65
69
|
meta,
|
|
66
70
|
label: element.label
|
|
67
71
|
});
|
|
68
72
|
} else {
|
|
69
|
-
Logger.debug("[MetaUI CompactLayout]", `Rendering scalar field '${
|
|
70
|
-
this._renderScalarField(container, element,
|
|
73
|
+
Logger.debug("[MetaUI CompactLayout]", `Rendering scalar field '${bindingPath}'.`, "CompactLayout");
|
|
74
|
+
this._renderScalarField(container, element, bindingPath, meta, modelName, engine);
|
|
71
75
|
}
|
|
72
76
|
} else {
|
|
73
77
|
Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, "", "CompactLayout");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactLayout-dbg.js","names":["Logger","___utils_Logger","CompactLayout","render","schema","modelName","engine","onSubmit","container","VBox","renderType","addStyleClass","uiLayout","Array","isArray","warn","tableElements","renderElement","element","type","label","title","sap","m","Title","text","level","addItem","elements","forEach","scope","startsWith","error","propKey","replace","meta","properties","isCollectionOfRecords","items","hasExplicitWidget","ui","widget","isSubLayout","debug","push","_renderScalarField","field","subSchema","control","generateLayout","msg","message","showErrorPopup","labelText","Label","required","effectiveMeta","generateField","fieldBox","__exports","__esModule"],"sources":["CompactLayout.ts"],"sourcesContent":["/**\n * @file CompactLayout.ts\n * @description Generates a lightweight, dense VBox layout for use inside tight spaces like table cells.\n */\n\nimport VBox from \"sap/m/VBox\";\nimport Label from \"sap/m/Label\";\nimport Title from \"sap/ui/core/Title\";\nimport { IPropertyMetadata, ISchema, ILayoutElement } from \"../interfaces/ISchema\";\nimport { ILayoutManager } from \"../interfaces/ILayoutManager\";\nimport { Engine } from \"../core/Engine\";\nimport { Logger } from \"../utils/Logger\";\nimport Control from \"sap/ui/core/Control\";\n\n/**\n * Layout Manager responsible for generating a dense, lightweight layout (no SimpleForm padding).\n * Ideal for rendering objects dynamically inside table cells or side-panels.\n * \n * @namespace nz.co.siliconst.ui5.metaui.layouts\n * @public\n */\nexport class CompactLayout implements ILayoutManager {\n /**\n * Renders the JSON Schema properties into a dense VBox layout.\n * \n * @param schema The active JSON schema subset.\n * @param modelName The bound UI5 model name.\n * @param engine The central orchestrator for delegating plugin generation.\n * @param onSubmit Optional submit hook.\n * @returns {Control} The VBox wrapper containing the generated compact form.\n */\n public render(schema: ISchema, modelName: string, engine: Engine, onSubmit?: () => void): Control {\n const container = new VBox({ renderType: \"Bare\" });\n container.addStyleClass(\"sapUiTinyMargin\");\n\n if (!schema.uiLayout || !Array.isArray(schema.uiLayout)) {\n Logger.warn(\"[MetaUI] Missing 'uiLayout' array in schema. CompactLayout will not render any fields.\");\n return container;\n }\n\n const tableElements: { scope: string, meta: IPropertyMetadata, label?: string }[] = [];\n\n // Recursively render layout elements\n const renderElement = (element: ILayoutElement) => {\n if (element.type === \"Group\") {\n if (element.label) {\n const title = new sap.m.Title({ text: element.label, level: \"H5\" });\n title.addStyleClass(\"sapUiTinyMarginTop sapUiTinyMarginBottom\");\n container.addItem(title);\n }\n \n if (element.elements && Array.isArray(element.elements)) {\n element.elements.forEach(renderElement);\n }\n } else if (element.type === \"Control\") {\n if (!element.scope || !element.scope.startsWith(\"#/properties/\")) {\n Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, \"\", \"CompactLayout\");\n return;\n }\n \n const propKey = element.scope.replace(\"#/properties/\", \"\");\n const meta = schema.properties?.[propKey];\n \n if (!meta) {\n Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, \"\", \"CompactLayout\");\n return;\n }\n\n const isCollectionOfRecords = meta.items?.type === \"object\" || meta.items?.properties;\n const hasExplicitWidget = !!meta.ui?.widget;\n const isSubLayout = meta.type === \"array\" && isCollectionOfRecords && !hasExplicitWidget;\n\n if (isSubLayout) {\n Logger.debug(\"[MetaUI CompactLayout]\", `Routing property '${propKey}' to Table Sub-Layout.`, \"CompactLayout\");\n tableElements.push({ scope: propKey, meta, label: element.label });\n } else {\n Logger.debug(\"[MetaUI CompactLayout]\", `Rendering scalar field '${propKey}'.`, \"CompactLayout\");\n this._renderScalarField(container, element, propKey, meta, modelName, engine);\n }\n } else {\n Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, \"\", \"CompactLayout\");\n }\n };\n\n // Render everything defined in the layout\n schema.uiLayout.forEach(renderElement);\n\n // Render array/table sub-layouts full width below the fields\n tableElements.forEach(field => {\n try {\n const subSchema = {\n type: \"array\",\n title: field.label || field.meta.ui?.label || field.scope,\n items: field.meta.items || { type: \"object\", properties: {} },\n uiLayout: field.meta.items?.uiLayout\n };\n \n const control = engine.generateLayout(subSchema as ISchema, modelName, `/${field.scope}`);\n if (control) {\n control.addStyleClass(\"sapUiTinyMarginTop\");\n container.addItem(control);\n }\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render array field ${field.scope}`, msg, \"CompactLayout\");\n Logger.showErrorPopup(`Failed to render array field '${field.scope}'.\\n\\nDetails: ${msg}`);\n }\n });\n\n return container;\n }\n\n private _renderScalarField(container: VBox, element: ILayoutElement, propKey: string, meta: IPropertyMetadata, modelName: string, engine: Engine): void {\n try {\n const labelText = element.label || meta.ui?.label || propKey;\n const label = new Label({\n text: labelText,\n required: meta.required\n });\n label.addStyleClass(\"sapUiTinyMarginTop\");\n\n const effectiveMeta = { ...meta };\n if (element.widget) {\n effectiveMeta.ui = { ...meta.ui, widget: element.widget };\n }\n\n const control = engine.generateField(effectiveMeta, `/${propKey}`, modelName);\n control.addStyleClass(\"sapUiTinyMarginBottom\");\n\n // Wrap label and field tightly\n const fieldBox = new VBox({ renderType: \"Bare\", items: [label, control] });\n container.addItem(fieldBox);\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render field ${propKey}`, msg, \"CompactLayout\");\n Logger.showErrorPopup(`Failed to render field '${propKey}'.\\n\\nDetails: ${msg}`);\n }\n }\n}\n"],"mappings":";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AAA,OAAAyD,SAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"CompactLayout-dbg.js","names":["SchemaNormalizer","___core_SchemaNormalizer","Logger","___utils_Logger","CompactLayout","render","schema","modelName","engine","onSubmit","container","VBox","renderType","addStyleClass","uiLayout","Array","isArray","warn","tableElements","renderElement","element","type","label","title","sap","m","Title","text","level","addItem","elements","forEach","scope","startsWith","error","meta","bindingPath","propKey","resolveScope","isCollectionOfRecords","items","properties","hasExplicitWidget","ui","widget","isSubLayout","debug","push","_renderScalarField","field","subSchema","control","generateLayout","msg","message","showErrorPopup","labelText","Label","required","effectiveMeta","generateField","fieldBox","__exports","__esModule"],"sources":["CompactLayout.ts"],"sourcesContent":["/**\n * @file CompactLayout.ts\n * @description Generates a lightweight, dense VBox layout for use inside tight spaces like table cells.\n */\n\nimport VBox from \"sap/m/VBox\";\nimport Label from \"sap/m/Label\";\nimport Title from \"sap/ui/core/Title\";\nimport { IPropertyMetadata, ISchema, ILayoutElement } from \"../interfaces/ISchema\";\nimport { ILayoutManager } from \"../interfaces/ILayoutManager\";\nimport { Engine } from \"../core/Engine\";\nimport { SchemaNormalizer } from \"../core/SchemaNormalizer\";\nimport { Logger } from \"../utils/Logger\";\nimport Control from \"sap/ui/core/Control\";\n\n/**\n * Layout Manager responsible for generating a dense, lightweight layout (no SimpleForm padding).\n * Ideal for rendering objects dynamically inside table cells or side-panels.\n * \n * @namespace nz.co.siliconst.ui5.metaui.layouts\n * @public\n */\nexport class CompactLayout implements ILayoutManager {\n /**\n * Renders the JSON Schema properties into a dense VBox layout.\n * \n * @param schema The active JSON schema subset.\n * @param modelName The bound UI5 model name.\n * @param engine The central orchestrator for delegating plugin generation.\n * @param onSubmit Optional submit hook.\n * @returns {Control} The VBox wrapper containing the generated compact form.\n */\n public render(schema: ISchema, modelName: string, engine: Engine, onSubmit?: () => void): Control {\n const container = new VBox({ renderType: \"Bare\" });\n container.addStyleClass(\"sapUiTinyMargin\");\n\n if (!schema.uiLayout || !Array.isArray(schema.uiLayout)) {\n Logger.warn(\"[MetaUI] Missing 'uiLayout' array in schema. CompactLayout will not render any fields.\");\n return container;\n }\n\n const tableElements: { scope: string, meta: IPropertyMetadata, label?: string }[] = [];\n\n // Recursively render layout elements\n const renderElement = (element: ILayoutElement) => {\n if (element.type === \"Group\") {\n if (element.label) {\n const title = new sap.m.Title({ text: element.label, level: \"H5\" });\n title.addStyleClass(\"sapUiTinyMarginTop sapUiTinyMarginBottom\");\n container.addItem(title);\n }\n \n if (element.elements && Array.isArray(element.elements)) {\n element.elements.forEach(renderElement);\n }\n } else if (element.type === \"Control\") {\n if (!element.scope || !element.scope.startsWith(\"#/properties/\")) {\n Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, \"\", \"CompactLayout\");\n return;\n }\n \n const { meta, bindingPath, propKey } = SchemaNormalizer.resolveScope(schema, element.scope);\n \n if (!meta) {\n Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, \"\", \"CompactLayout\");\n return;\n }\n\n const isCollectionOfRecords = meta.items?.type === \"object\" || meta.items?.properties;\n const hasExplicitWidget = !!meta.ui?.widget;\n const isSubLayout = meta.type === \"array\" && isCollectionOfRecords && !hasExplicitWidget;\n\n if (isSubLayout) {\n Logger.debug(\"[MetaUI CompactLayout]\", `Routing property '${propKey}' to Table Sub-Layout.`, \"CompactLayout\");\n tableElements.push({ scope: bindingPath, meta, label: element.label });\n } else {\n Logger.debug(\"[MetaUI CompactLayout]\", `Rendering scalar field '${bindingPath}'.`, \"CompactLayout\");\n this._renderScalarField(container, element, bindingPath, meta, modelName, engine);\n }\n } else {\n Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, \"\", \"CompactLayout\");\n }\n };\n\n // Render everything defined in the layout\n schema.uiLayout.forEach(renderElement);\n\n // Render array/table sub-layouts full width below the fields\n tableElements.forEach(field => {\n try {\n const subSchema = {\n type: \"array\",\n title: field.label || field.meta.ui?.label || field.scope,\n items: field.meta.items || { type: \"object\", properties: {} },\n uiLayout: field.meta.items?.uiLayout\n };\n \n const control = engine.generateLayout(subSchema as ISchema, modelName, `/${field.scope}`);\n if (control) {\n control.addStyleClass(\"sapUiTinyMarginTop\");\n container.addItem(control);\n }\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render array field ${field.scope}`, msg, \"CompactLayout\");\n Logger.showErrorPopup(`Failed to render array field '${field.scope}'.\\n\\nDetails: ${msg}`);\n }\n });\n\n return container;\n }\n\n private _renderScalarField(container: VBox, element: ILayoutElement, propKey: string, meta: IPropertyMetadata, modelName: string, engine: Engine): void {\n try {\n const labelText = element.label || meta.ui?.label || propKey;\n const label = new Label({\n text: labelText,\n required: meta.required\n });\n label.addStyleClass(\"sapUiTinyMarginTop\");\n\n const effectiveMeta = { ...meta };\n if (element.widget) {\n effectiveMeta.ui = { ...meta.ui, widget: element.widget };\n }\n\n const control = engine.generateField(effectiveMeta, `/${propKey}`, modelName);\n control.addStyleClass(\"sapUiTinyMarginBottom\");\n\n // Wrap label and field tightly\n const fieldBox = new VBox({ renderType: \"Bare\", items: [label, control] });\n container.addItem(fieldBox);\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render field ${propKey}`, msg, \"CompactLayout\");\n Logger.showErrorPopup(`Failed to render field '${propKey}'.\\n\\nDetails: ${msg}`);\n }\n }\n}\n"],"mappings":";;;QAWSA,gBAAgB,GAAAC,wBAAA;EAAA,MAChBC,MAAM,GAAAC,eAAA;EAGf;AACA;AACA;AACA;AACA;AACA;AACA;EACO,MAAMC,aAAa,CAA2B;IACjD;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACWC,MAAMA,CAACC,MAAe,EAAEC,SAAiB,EAAEC,MAAc,EAAEC,QAAqB,EAAW;MAC9F,MAAMC,SAAS,GAAG,IAAIC,IAAI,CAAC;QAAEC,UAAU,EAAE;MAAO,CAAC,CAAC;MAClDF,SAAS,CAACG,aAAa,CAAC,iBAAi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AK,CAAC;QACjC,IAAIf,OAAO,CAACwB,MAAM,EAAE;UAChBe,aAAa,CAAChB,EAAE,GAAG;YAAE,GAAGR,IAAI,CAACQ,EAAE;YAAEC,MAAM,EAAExB,OAAO,CAACwB;UAAO,CAAC;QAC7D;QAEA,MAAMO,OAAO,GAAG3C,MAAM,CAACoD,aAAa,CAACD,aAAa,EAAE,IAAItB,OAAO,EAAE,EAAE9B,SAAS,CAAC;QAC7E4C,OAAO,CAACtC,aAAa,CAAC,uBAAuB,CAAC;;QAE9C;QACA,MAAMgD,QAAQ,GAAG,IAAIlD,IAAI,CAAC;UAAEC,UAAU,EAAE,MAAM;UAAE4B,KAAK,EAAE,CAAClB,KAAK,EAAE6B,OAAO;QAAE,CAAC,CAAC;QAC1EzC,SAAS,CAACmB,OAAO,CAACgC,QAAQ,CAAC;MAC/B,CAAC,CAAC,OAAO3B,KAAK,EAAE;QACZ,MAAMmB,GAAG,GAAInB,KAAK,CAAWoB,OAAO;QACpCpD,MAAM,CAACgC,KAAK,CAAC,mCAAmCG,OAAO,EAAE,EAAEgB,GAAG,EAAE,eAAe,CAAC;QAChFnD,MAAM,CAACqD,cAAc,CAAC,2BAA2BlB,OAAO,kBAAkBgB,GAAG,EAAE,CAAC;MACpF;IACJ;EACJ;EAAC,IAAAS,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAA1D,aAAA,GAAAA,aAAA;EAAA,OAAA0D,SAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactLayout.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,kDAAkD,CAAC;IASlE,OAAO,EAAqB,OAAO,EAAkB,MAAM,+CAA+C,CAAC;IAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;IACtF,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"CompactLayout.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/layouts/CompactLayout.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,kDAAkD,CAAC;IASlE,OAAO,EAAqB,OAAO,EAAkB,MAAM,+CAA+C,CAAC;IAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;IACtF,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;IAGhE,OAAO,OAAO,MAAM,qBAAqB,CAAC;IAE1C;;;;;;OAMG;IACH,MAAa,aAAc,YAAW,cAAc;QAChD;;;;;;;;WAQG;QACI,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;QAgFjG,OAAO,CAAC,kBAAkB;KA0B7B;CAEA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
sap.ui.define(["sap/m/VBox","sap/m/Label","../utils/Logger"],function(e,t,a){"use strict";const
|
|
1
|
+
sap.ui.define(["sap/m/VBox","sap/m/Label","../core/SchemaNormalizer","../utils/Logger"],function(e,t,a,r){"use strict";const o=a["SchemaNormalizer"];const i=r["Logger"];class s{render(t,a,r,s){const n=new e({renderType:"Bare"});n.addStyleClass("sapUiTinyMargin");if(!t.uiLayout||!Array.isArray(t.uiLayout)){i.warn("[MetaUI] Missing 'uiLayout' array in schema. CompactLayout will not render any fields.");return n}const l=[];const p=e=>{if(e.type==="Group"){if(e.label){const t=new sap.m.Title({text:e.label,level:"H5"});t.addStyleClass("sapUiTinyMarginTop sapUiTinyMarginBottom");n.addItem(t)}if(e.elements&&Array.isArray(e.elements)){e.elements.forEach(p)}}else if(e.type==="Control"){if(!e.scope||!e.scope.startsWith("#/properties/")){i.error(`[MetaUI] Invalid scope '${e.scope}' in uiLayout Control.`,"","CompactLayout");return}const{meta:s,bindingPath:p,propKey:c}=o.resolveScope(t,e.scope);if(!s){i.error(`[MetaUI] Property '${c}' not found in schema definitions.`,"","CompactLayout");return}const y=s.items?.type==="object"||s.items?.properties;const u=!!s.ui?.widget;const d=s.type==="array"&&y&&!u;if(d){i.debug("[MetaUI CompactLayout]",`Routing property '${c}' to Table Sub-Layout.`,"CompactLayout");l.push({scope:p,meta:s,label:e.label})}else{i.debug("[MetaUI CompactLayout]",`Rendering scalar field '${p}'.`,"CompactLayout");this._renderScalarField(n,e,p,s,a,r)}}else{i.warn(`[MetaUI] Unsupported layout element type '${e.type}'.`,"","CompactLayout")}};t.uiLayout.forEach(p);l.forEach(e=>{try{const t={type:"array",title:e.label||e.meta.ui?.label||e.scope,items:e.meta.items||{type:"object",properties:{}},uiLayout:e.meta.items?.uiLayout};const o=r.generateLayout(t,a,`/${e.scope}`);if(o){o.addStyleClass("sapUiTinyMarginTop");n.addItem(o)}}catch(t){const a=t.message;i.error(`[MetaUI] Failed to render array field ${e.scope}`,a,"CompactLayout");i.showErrorPopup(`Failed to render array field '${e.scope}'.\n\nDetails: ${a}`)}});return n}_renderScalarField(a,r,o,s,n,l){try{const i=r.label||s.ui?.label||o;const p=new t({text:i,required:s.required});p.addStyleClass("sapUiTinyMarginTop");const c={...s};if(r.widget){c.ui={...s.ui,widget:r.widget}}const y=l.generateField(c,`/${o}`,n);y.addStyleClass("sapUiTinyMarginBottom");const u=new e({renderType:"Bare",items:[p,y]});a.addItem(u)}catch(e){const t=e.message;i.error(`[MetaUI] Failed to render field ${o}`,t,"CompactLayout");i.showErrorPopup(`Failed to render field '${o}'.\n\nDetails: ${t}`)}}}var n={__esModule:true};n.CompactLayout=s;return n});
|
|
2
2
|
//# sourceMappingURL=CompactLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompactLayout.js","names":["Logger","___utils_Logger","CompactLayout","render","schema","modelName","engine","onSubmit","container","VBox","renderType","addStyleClass","uiLayout","Array","isArray","warn","tableElements","renderElement","element","type","label","title","sap","m","Title","text","level","addItem","elements","forEach","scope","startsWith","error","
|
|
1
|
+
{"version":3,"file":"CompactLayout.js","names":["SchemaNormalizer","___core_SchemaNormalizer","Logger","___utils_Logger","CompactLayout","render","schema","modelName","engine","onSubmit","container","VBox","renderType","addStyleClass","uiLayout","Array","isArray","warn","tableElements","renderElement","element","type","label","title","sap","m","Title","text","level","addItem","elements","forEach","scope","startsWith","error","meta","bindingPath","propKey","resolveScope","isCollectionOfRecords","items","properties","hasExplicitWidget","ui","widget","isSubLayout","debug","push","this","_renderScalarField","field","subSchema","control","generateLayout","msg","message","showErrorPopup","labelText","Label","required","effectiveMeta","generateField","fieldBox","__exports","__esModule"],"sources":["CompactLayout.ts"],"sourcesContent":["/**\n * @file CompactLayout.ts\n * @description Generates a lightweight, dense VBox layout for use inside tight spaces like table cells.\n */\n\nimport VBox from \"sap/m/VBox\";\nimport Label from \"sap/m/Label\";\nimport Title from \"sap/ui/core/Title\";\nimport { IPropertyMetadata, ISchema, ILayoutElement } from \"../interfaces/ISchema\";\nimport { ILayoutManager } from \"../interfaces/ILayoutManager\";\nimport { Engine } from \"../core/Engine\";\nimport { SchemaNormalizer } from \"../core/SchemaNormalizer\";\nimport { Logger } from \"../utils/Logger\";\nimport Control from \"sap/ui/core/Control\";\n\n/**\n * Layout Manager responsible for generating a dense, lightweight layout (no SimpleForm padding).\n * Ideal for rendering objects dynamically inside table cells or side-panels.\n * \n * @namespace nz.co.siliconst.ui5.metaui.layouts\n * @public\n */\nexport class CompactLayout implements ILayoutManager {\n /**\n * Renders the JSON Schema properties into a dense VBox layout.\n * \n * @param schema The active JSON schema subset.\n * @param modelName The bound UI5 model name.\n * @param engine The central orchestrator for delegating plugin generation.\n * @param onSubmit Optional submit hook.\n * @returns {Control} The VBox wrapper containing the generated compact form.\n */\n public render(schema: ISchema, modelName: string, engine: Engine, onSubmit?: () => void): Control {\n const container = new VBox({ renderType: \"Bare\" });\n container.addStyleClass(\"sapUiTinyMargin\");\n\n if (!schema.uiLayout || !Array.isArray(schema.uiLayout)) {\n Logger.warn(\"[MetaUI] Missing 'uiLayout' array in schema. CompactLayout will not render any fields.\");\n return container;\n }\n\n const tableElements: { scope: string, meta: IPropertyMetadata, label?: string }[] = [];\n\n // Recursively render layout elements\n const renderElement = (element: ILayoutElement) => {\n if (element.type === \"Group\") {\n if (element.label) {\n const title = new sap.m.Title({ text: element.label, level: \"H5\" });\n title.addStyleClass(\"sapUiTinyMarginTop sapUiTinyMarginBottom\");\n container.addItem(title);\n }\n \n if (element.elements && Array.isArray(element.elements)) {\n element.elements.forEach(renderElement);\n }\n } else if (element.type === \"Control\") {\n if (!element.scope || !element.scope.startsWith(\"#/properties/\")) {\n Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, \"\", \"CompactLayout\");\n return;\n }\n \n const { meta, bindingPath, propKey } = SchemaNormalizer.resolveScope(schema, element.scope);\n \n if (!meta) {\n Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, \"\", \"CompactLayout\");\n return;\n }\n\n const isCollectionOfRecords = meta.items?.type === \"object\" || meta.items?.properties;\n const hasExplicitWidget = !!meta.ui?.widget;\n const isSubLayout = meta.type === \"array\" && isCollectionOfRecords && !hasExplicitWidget;\n\n if (isSubLayout) {\n Logger.debug(\"[MetaUI CompactLayout]\", `Routing property '${propKey}' to Table Sub-Layout.`, \"CompactLayout\");\n tableElements.push({ scope: bindingPath, meta, label: element.label });\n } else {\n Logger.debug(\"[MetaUI CompactLayout]\", `Rendering scalar field '${bindingPath}'.`, \"CompactLayout\");\n this._renderScalarField(container, element, bindingPath, meta, modelName, engine);\n }\n } else {\n Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, \"\", \"CompactLayout\");\n }\n };\n\n // Render everything defined in the layout\n schema.uiLayout.forEach(renderElement);\n\n // Render array/table sub-layouts full width below the fields\n tableElements.forEach(field => {\n try {\n const subSchema = {\n type: \"array\",\n title: field.label || field.meta.ui?.label || field.scope,\n items: field.meta.items || { type: \"object\", properties: {} },\n uiLayout: field.meta.items?.uiLayout\n };\n \n const control = engine.generateLayout(subSchema as ISchema, modelName, `/${field.scope}`);\n if (control) {\n control.addStyleClass(\"sapUiTinyMarginTop\");\n container.addItem(control);\n }\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render array field ${field.scope}`, msg, \"CompactLayout\");\n Logger.showErrorPopup(`Failed to render array field '${field.scope}'.\\n\\nDetails: ${msg}`);\n }\n });\n\n return container;\n }\n\n private _renderScalarField(container: VBox, element: ILayoutElement, propKey: string, meta: IPropertyMetadata, modelName: string, engine: Engine): void {\n try {\n const labelText = element.label || meta.ui?.label || propKey;\n const label = new Label({\n text: labelText,\n required: meta.required\n });\n label.addStyleClass(\"sapUiTinyMarginTop\");\n\n const effectiveMeta = { ...meta };\n if (element.widget) {\n effectiveMeta.ui = { ...meta.ui, widget: element.widget };\n }\n\n const control = engine.generateField(effectiveMeta, `/${propKey}`, modelName);\n control.addStyleClass(\"sapUiTinyMarginBottom\");\n\n // Wrap label and field tightly\n const fieldBox = new VBox({ renderType: \"Bare\", items: [label, control] });\n container.addItem(fieldBox);\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render field ${propKey}`, msg, \"CompactLayout\");\n Logger.showErrorPopup(`Failed to render field '${propKey}'.\\n\\nDetails: ${msg}`);\n }\n }\n}\n"],"mappings":"6HAWSA,EAAgBC,EAAA,0BAChBC,EAAMC,EAAA,UAUR,MAAMC,EAUFC,OAAOC,EAAiBC,EAAmBC,EAAgBC,GAC9D,MAAMC,EAAY,IAAIC,EAAK,CAAEC,WAAY,SACzCF,EAAUG,cAAc,mBAExB,IAAKP,EAAOQ,WAAaC,MAAMC,QAAQV,EAAOQ,UAAW,CACrDZ,EAAOe,KAAK,0FACZ,OAAOP,CACX,CAEA,MAAMQ,EAA8E,GAGpF,MAAMC,EAAiBC,IACnB,GAAIA,EAAQC,OAAS,QAAS,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":[]}
|
|
@@ -9,6 +9,7 @@ import Title from "sap/ui/core/Title";
|
|
|
9
9
|
import { IPropertyMetadata, ISchema, ILayoutElement } from "../interfaces/ISchema";
|
|
10
10
|
import { ILayoutManager } from "../interfaces/ILayoutManager";
|
|
11
11
|
import { Engine } from "../core/Engine";
|
|
12
|
+
import { SchemaNormalizer } from "../core/SchemaNormalizer";
|
|
12
13
|
import { Logger } from "../utils/Logger";
|
|
13
14
|
import Control from "sap/ui/core/Control";
|
|
14
15
|
|
|
@@ -58,8 +59,7 @@ export class CompactLayout implements ILayoutManager {
|
|
|
58
59
|
return;
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
const propKey =
|
|
62
|
-
const meta = schema.properties?.[propKey];
|
|
62
|
+
const { meta, bindingPath, propKey } = SchemaNormalizer.resolveScope(schema, element.scope);
|
|
63
63
|
|
|
64
64
|
if (!meta) {
|
|
65
65
|
Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, "", "CompactLayout");
|
|
@@ -72,10 +72,10 @@ export class CompactLayout implements ILayoutManager {
|
|
|
72
72
|
|
|
73
73
|
if (isSubLayout) {
|
|
74
74
|
Logger.debug("[MetaUI CompactLayout]", `Routing property '${propKey}' to Table Sub-Layout.`, "CompactLayout");
|
|
75
|
-
tableElements.push({ scope:
|
|
75
|
+
tableElements.push({ scope: bindingPath, meta, label: element.label });
|
|
76
76
|
} else {
|
|
77
|
-
Logger.debug("[MetaUI CompactLayout]", `Rendering scalar field '${
|
|
78
|
-
this._renderScalarField(container, element,
|
|
77
|
+
Logger.debug("[MetaUI CompactLayout]", `Rendering scalar field '${bindingPath}'.`, "CompactLayout");
|
|
78
|
+
this._renderScalarField(container, element, bindingPath, meta, modelName, engine);
|
|
79
79
|
}
|
|
80
80
|
} else {
|
|
81
81
|
Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, "", "CompactLayout");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
sap.ui.define(["sap/ui/layout/form/SimpleForm", "sap/m/Label", "sap/ui/core/Title", "sap/m/VBox", "../utils/Logger"], function (SimpleForm, Label, Title, VBox, ___utils_Logger) {
|
|
1
|
+
sap.ui.define(["sap/ui/layout/form/SimpleForm", "sap/m/Label", "sap/ui/core/Title", "sap/m/VBox", "../core/SchemaNormalizer", "../utils/Logger"], function (SimpleForm, Label, Title, VBox, ___core_SchemaNormalizer, ___utils_Logger) {
|
|
2
2
|
"use strict";
|
|
3
3
|
|
|
4
|
+
const SchemaNormalizer = ___core_SchemaNormalizer["SchemaNormalizer"];
|
|
4
5
|
const Logger = ___utils_Logger["Logger"];
|
|
5
6
|
/**
|
|
6
7
|
* Layout Manager responsible for generating a fully responsive SAP Fiori SimpleForm.
|
|
@@ -65,8 +66,11 @@ sap.ui.define(["sap/ui/layout/form/SimpleForm", "sap/m/Label", "sap/ui/core/Titl
|
|
|
65
66
|
Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, "", "FormLayout");
|
|
66
67
|
return;
|
|
67
68
|
}
|
|
68
|
-
const
|
|
69
|
-
|
|
69
|
+
const {
|
|
70
|
+
meta,
|
|
71
|
+
bindingPath,
|
|
72
|
+
propKey
|
|
73
|
+
} = SchemaNormalizer.resolveScope(schema, element.scope);
|
|
70
74
|
if (!meta) {
|
|
71
75
|
Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, "", "FormLayout");
|
|
72
76
|
return;
|
|
@@ -81,14 +85,14 @@ sap.ui.define(["sap/ui/layout/form/SimpleForm", "sap/m/Label", "sap/ui/core/Titl
|
|
|
81
85
|
if (isSubLayout) {
|
|
82
86
|
Logger.debug("[MetaUI FormLayout]", `Routing property '${propKey}' to Table Sub-Layout.`, "FormLayout");
|
|
83
87
|
tableElements.push({
|
|
84
|
-
scope:
|
|
88
|
+
scope: bindingPath,
|
|
85
89
|
meta,
|
|
86
90
|
label: element.label
|
|
87
91
|
});
|
|
88
92
|
} else {
|
|
89
93
|
hasFormFields = true;
|
|
90
|
-
Logger.debug("[MetaUI FormLayout]", `Rendering scalar field '${
|
|
91
|
-
this._renderScalarField(form, element,
|
|
94
|
+
Logger.debug("[MetaUI FormLayout]", `Rendering scalar field '${bindingPath}'.`, "FormLayout");
|
|
95
|
+
this._renderScalarField(form, element, bindingPath, meta, modelName, engine);
|
|
92
96
|
}
|
|
93
97
|
} else {
|
|
94
98
|
Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, "", "FormLayout");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLayout-dbg.js","names":["Logger","___utils_Logger","FormLayout","render","schema","modelName","engine","onSubmit","container","VBox","renderType","form","SimpleForm","editable","title","layout","labelSpanXL","labelSpanL","labelSpanM","labelSpanS","adjustLabelSpan","emptySpanXL","emptySpanL","emptySpanM","emptySpanS","columnsXL","columnsL","columnsM","singleContainerFullSize","uiLayout","Array","isArray","warn","addItem","tableElements","hasFormFields","renderElement","element","type","label","addContent","Title","text","elements","forEach","scope","startsWith","error","propKey","replace","meta","properties","isCollectionOfRecords","items","hasExplicitWidget","ui","widget","isSubLayout","debug","push","_renderScalarField","field","subSchema","control","generateLayout","addStyleClass","msg","message","showErrorPopup","labelText","Label","required","effectiveMeta","generateField","fullWidth","sap","require","GridData","setLayoutData","span","__exports","__esModule"],"sources":["FormLayout.ts"],"sourcesContent":["/**\n * @file FormLayout.ts\n * @description Generates a fully responsive SAP Fiori Form layout (SimpleForm).\n */\n\nimport SimpleForm from \"sap/ui/layout/form/SimpleForm\";\nimport Label from \"sap/m/Label\";\nimport Title from \"sap/ui/core/Title\";\nimport VBox from \"sap/m/VBox\";\nimport { IPropertyMetadata, ISchema, ILayoutElement } from \"../interfaces/ISchema\";\nimport { ILayoutManager } from \"../interfaces/ILayoutManager\";\nimport { Engine } from \"../core/Engine\";\nimport { Logger } from \"../utils/Logger\";\nimport Control from \"sap/ui/core/Control\";\n\n/**\n * Layout Manager responsible for generating a fully responsive SAP Fiori SimpleForm.\n * It traverses the `uiLayout` tree defined in the schema to build the form groups and fields,\n * completely separating visual orchestration from data modeling.\n * @namespace nz.co.siliconst.ui5.metaui.layouts\n * @public\n */\nexport class FormLayout implements ILayoutManager {\n /**\n * Renders the JSON Schema properties into a UI5 SimpleForm using the uiLayout definitions.\n * \n * @param schema The active JSON schema subset.\n * @param modelName The bound UI5 model name.\n * @param engine The central orchestrator for delegating plugin generation.\n * @param onSubmit Optional submit hook.\n * @returns {Control} The VBox wrapper containing the generated form.\n */\n public render(schema: ISchema, modelName: string, engine: Engine, onSubmit?: () => void): Control {\n const container = new VBox({ renderType: \"Bare\" });\n const form = new SimpleForm({\n editable: true,\n title: schema.title,\n layout: \"ResponsiveGridLayout\",\n labelSpanXL: 4, labelSpanL: 4, labelSpanM: 4, labelSpanS: 12,\n adjustLabelSpan: false,\n emptySpanXL: 0, emptySpanL: 0, emptySpanM: 0, emptySpanS: 0,\n columnsXL: 1, columnsL: 1, columnsM: 1,\n singleContainerFullSize: false\n });\n\n if (!schema.uiLayout || !Array.isArray(schema.uiLayout)) {\n Logger.warn(\"[MetaUI] Missing 'uiLayout' array in schema. Form will not render any fields.\");\n container.addItem(form);\n return container;\n }\n\n const tableElements: { scope: string, meta: IPropertyMetadata, label?: string }[] = [];\n let hasFormFields = false;\n\n // Recursively render layout elements\n const renderElement = (element: ILayoutElement) => {\n if (element.type === \"Group\") {\n if (element.label) {\n form.addContent(new Title({ text: element.label }));\n }\n \n if (element.elements && Array.isArray(element.elements)) {\n element.elements.forEach(renderElement);\n }\n } else if (element.type === \"Control\") {\n if (!element.scope || !element.scope.startsWith(\"#/properties/\")) {\n Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, \"\", \"FormLayout\");\n return;\n }\n \n const propKey = element.scope.replace(\"#/properties/\", \"\");\n const meta = schema.properties?.[propKey];\n \n if (!meta) {\n Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, \"\", \"FormLayout\");\n return;\n }\n\n // Architectural Boundary: Separate Field Controls (Plugins) from Sub-Layouts (LayoutManagers)\n // A property is delegated to a Sub-Layout Manager (Table) ONLY if it represents a collection of complex objects.\n // Collections of primitives, or explicitly assigned widgets (like multiSelect), remain in the Form as Field Plugins.\n const isCollectionOfRecords = meta.items?.type === \"object\" || meta.items?.properties;\n const hasExplicitWidget = !!meta.ui?.widget;\n const isSubLayout = meta.type === \"array\" && isCollectionOfRecords && !hasExplicitWidget;\n\n if (isSubLayout) {\n Logger.debug(\"[MetaUI FormLayout]\", `Routing property '${propKey}' to Table Sub-Layout.`, \"FormLayout\");\n tableElements.push({ scope: propKey, meta, label: element.label });\n } else {\n hasFormFields = true;\n Logger.debug(\"[MetaUI FormLayout]\", `Rendering scalar field '${propKey}'.`, \"FormLayout\");\n this._renderScalarField(form, element, propKey, meta, modelName, engine);\n }\n } else {\n Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, \"\", \"FormLayout\");\n }\n };\n\n // Render everything defined in the layout\n schema.uiLayout.forEach(renderElement);\n\n if (hasFormFields) {\n container.addItem(form);\n }\n\n // Render array/table sub-layouts full width below the form\n tableElements.forEach(field => {\n try {\n const subSchema = {\n type: \"array\",\n title: field.label || field.meta.ui?.label || field.scope,\n items: field.meta.items || { type: \"object\", properties: {} },\n uiLayout: field.meta.items?.uiLayout // Pass down sub-layout if available\n };\n \n const control = engine.generateLayout(subSchema as ISchema, modelName, `/${field.scope}`);\n if (control) {\n control.addStyleClass(\"sapUiSmallMarginTop\");\n container.addItem(control);\n }\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render array field ${field.scope}`, msg, \"FormLayout\");\n Logger.showErrorPopup(`Failed to render array field '${field.scope}'.\\n\\nDetails: ${msg}`);\n }\n });\n\n return container;\n }\n\n private _renderScalarField(form: SimpleForm, element: ILayoutElement, propKey: string, meta: IPropertyMetadata, modelName: string, engine: Engine): void {\n try {\n const labelText = element.label || meta.ui?.label || propKey;\n const label = new Label({\n text: labelText,\n required: meta.required\n });\n\n // Override widget if specified in the layout element\n const effectiveMeta = { ...meta };\n if (element.widget) {\n effectiveMeta.ui = { ...meta.ui, widget: element.widget };\n }\n\n const control = engine.generateField(effectiveMeta, `/${propKey}`, modelName);\n\n if (effectiveMeta.ui?.fullWidth) {\n sap.ui.require([\"sap/ui/layout/GridData\"], (GridData: any) => {\n control.setLayoutData(new GridData({ span: \"XL12 L12 M12 S12\" }));\n });\n }\n\n form.addContent(label);\n form.addContent(control);\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render field ${propKey}`, msg, \"FormLayout\");\n Logger.showErrorPopup(`Failed to render field '${propKey}'.\\n\\nDetails: ${msg}`);\n }\n }\n}\n"],"mappings":";;;QAYSA,MAAM,GAAAC,eAAA;EAGf;AACA;AACA;AACA;AACA;AACA;AACA;EACO,MAAMC,UAAU,CAA2B;IAC9C;AACJ;AACA;AACA;AACA;AACA;AACA;AACA;AACA;IACWC,MAAMA,CAACC,MAAe,EAAEC,SAAiB,EAAEC,MAAc,EAAEC,QAAqB,EAAW;MAC9F,MAAMC,SAAS,GAAG,IAAIC,IAAI,CAAC;QAAEC,UAAU,EAAE;MAAO,CAAC,CAAC;MAClD,MAAMC,IAAI,GAAG,IAAIC,UAAU,CAAC;QACxBC,QAAQ,EAAE,IAAI;QACdC,KAAK,EAAEV,MAAM,CAACU,KAAK;QACnBC,MAAM,EAAE,sBAAsB;QAC9BC,WAAW,EAAE,CAAC;QAAEC,UAAU,EAAE,CAAC;QAAEC,UAAU,EAAE,CAAC;QAAEC,UAAU,EAAE,EAAE;QAC5DC,eAAe,EAAE,KAAK;QACtBC,WAAW,EAAE,CAAC;QAAEC,UAAU,EAAE,CAAC;QAAEC,UAAU,EAAE,CAAC;QAAEC,UAAU,EAAE,CAAC;QAC3DC,SAAS,EAAE,CAAC;QAAEC,QAAQ,EAAE,CAAC;QAAEC,QAAQ,EAAE,CAAC;QACtCC,uBAAuB,EAAE;MAC7B,CAAC,CAAC;MAEF,IAAI,CAACxB,MA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;QACA,MAAMC,aAAa,GAAG;UAAE,GAAGtB;QAAK,CAAC;QACjC,IAAIb,OAAO,CAACmB,MAAM,EAAE;UAChBgB,aAAa,CAACjB,EAAE,GAAG;YAAE,GAAGL,IAAI,CAACK,EAAE;YAAEC,MAAM,EAAEnB,OAAO,CAACmB;UAAO,CAAC;QAC7D;QAEA,MAAMO,OAAO,GAAGzD,MAAM,CAACmE,aAAa,CAACD,aAAa,EAAE,IAAIxB,OAAO,EAAE,EAAE3C,SAAS,CAAC;QAE7E,IAAImE,aAAa,CAACjB,EAAE,EAAEmB,SAAS,EAAE;UAC7BC,GAAG,CAACpB,EAAE,CAACqB,OAAO,CAAC,CAAC,wBAAwB,CAAC,EAAGC,QAAa,IAAK;YAC1Dd,OAAO,CAACe,aAAa,CAAC,IAAID,QAAQ,CAAC;cAAEE,IAAI,EAAE;YAAmB,CAAC,CAAC,CAAC;UACrE,CAAC,CAAC;QACN;QAEApE,IAAI,CAAC6B,UAAU,CAACD,KAAK,CAAC;QACtB5B,IAAI,CAAC6B,UAAU,CAACuB,OAAO,CAAC;MAC5B,CAAC,CAAC,OAAOhB,KAAK,EAAE;QACZ,MAAMmB,GAAG,GAAInB,KAAK,CAAWoB,OAAO;QACpCnE,MAAM,CAAC+C,KAAK,CAAC,mCAAmCC,OAAO,EAAE,EAAEkB,GAAG,EAAE,YAAY,CAAC;QAC7ElE,MAAM,CAACoE,cAAc,CAAC,2BAA2BpB,OAAO,kBAAkBkB,GAAG,EAAE,CAAC;MACpF;IACJ;EACJ;EAAC,IAAAc,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAA9E,UAAA,GAAAA,UAAA;EAAA,OAAA8E,SAAA;AAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FormLayout-dbg.js","names":["SchemaNormalizer","___core_SchemaNormalizer","Logger","___utils_Logger","FormLayout","render","schema","modelName","engine","onSubmit","container","VBox","renderType","form","SimpleForm","editable","title","layout","labelSpanXL","labelSpanL","labelSpanM","labelSpanS","adjustLabelSpan","emptySpanXL","emptySpanL","emptySpanM","emptySpanS","columnsXL","columnsL","columnsM","singleContainerFullSize","uiLayout","Array","isArray","warn","addItem","tableElements","hasFormFields","renderElement","element","type","label","addContent","Title","text","elements","forEach","scope","startsWith","error","meta","bindingPath","propKey","resolveScope","isCollectionOfRecords","items","properties","hasExplicitWidget","ui","widget","isSubLayout","debug","push","_renderScalarField","field","subSchema","control","generateLayout","addStyleClass","msg","message","showErrorPopup","labelText","Label","required","effectiveMeta","generateField","fullWidth","sap","require","GridData","setLayoutData","span","__exports","__esModule"],"sources":["FormLayout.ts"],"sourcesContent":["/**\n * @file FormLayout.ts\n * @description Generates a fully responsive SAP Fiori Form layout (SimpleForm).\n */\n\nimport SimpleForm from \"sap/ui/layout/form/SimpleForm\";\nimport Label from \"sap/m/Label\";\nimport Title from \"sap/ui/core/Title\";\nimport VBox from \"sap/m/VBox\";\nimport { IPropertyMetadata, ISchema, ILayoutElement } from \"../interfaces/ISchema\";\nimport { ILayoutManager } from \"../interfaces/ILayoutManager\";\nimport { Engine } from \"../core/Engine\";\nimport { SchemaNormalizer } from \"../core/SchemaNormalizer\";\nimport { Logger } from \"../utils/Logger\";\nimport Control from \"sap/ui/core/Control\";\n\n/**\n * Layout Manager responsible for generating a fully responsive SAP Fiori SimpleForm.\n * It traverses the `uiLayout` tree defined in the schema to build the form groups and fields,\n * completely separating visual orchestration from data modeling.\n * @namespace nz.co.siliconst.ui5.metaui.layouts\n * @public\n */\nexport class FormLayout implements ILayoutManager {\n /**\n * Renders the JSON Schema properties into a UI5 SimpleForm using the uiLayout definitions.\n * \n * @param schema The active JSON schema subset.\n * @param modelName The bound UI5 model name.\n * @param engine The central orchestrator for delegating plugin generation.\n * @param onSubmit Optional submit hook.\n * @returns {Control} The VBox wrapper containing the generated form.\n */\n public render(schema: ISchema, modelName: string, engine: Engine, onSubmit?: () => void): Control {\n const container = new VBox({ renderType: \"Bare\" });\n const form = new SimpleForm({\n editable: true,\n title: schema.title,\n layout: \"ResponsiveGridLayout\",\n labelSpanXL: 4, labelSpanL: 4, labelSpanM: 4, labelSpanS: 12,\n adjustLabelSpan: false,\n emptySpanXL: 0, emptySpanL: 0, emptySpanM: 0, emptySpanS: 0,\n columnsXL: 1, columnsL: 1, columnsM: 1,\n singleContainerFullSize: false\n });\n\n if (!schema.uiLayout || !Array.isArray(schema.uiLayout)) {\n Logger.warn(\"[MetaUI] Missing 'uiLayout' array in schema. Form will not render any fields.\");\n container.addItem(form);\n return container;\n }\n\n const tableElements: { scope: string, meta: IPropertyMetadata, label?: string }[] = [];\n let hasFormFields = false;\n\n // Recursively render layout elements\n const renderElement = (element: ILayoutElement) => {\n if (element.type === \"Group\") {\n if (element.label) {\n form.addContent(new Title({ text: element.label }));\n }\n \n if (element.elements && Array.isArray(element.elements)) {\n element.elements.forEach(renderElement);\n }\n } else if (element.type === \"Control\") {\n if (!element.scope || !element.scope.startsWith(\"#/properties/\")) {\n Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, \"\", \"FormLayout\");\n return;\n }\n \n const { meta, bindingPath, propKey } = SchemaNormalizer.resolveScope(schema, element.scope);\n \n if (!meta) {\n Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, \"\", \"FormLayout\");\n return;\n }\n\n // Architectural Boundary: Separate Field Controls (Plugins) from Sub-Layouts (LayoutManagers)\n // A property is delegated to a Sub-Layout Manager (Table) ONLY if it represents a collection of complex objects.\n // Collections of primitives, or explicitly assigned widgets (like multiSelect), remain in the Form as Field Plugins.\n const isCollectionOfRecords = meta.items?.type === \"object\" || meta.items?.properties;\n const hasExplicitWidget = !!meta.ui?.widget;\n const isSubLayout = meta.type === \"array\" && isCollectionOfRecords && !hasExplicitWidget;\n\n if (isSubLayout) {\n Logger.debug(\"[MetaUI FormLayout]\", `Routing property '${propKey}' to Table Sub-Layout.`, \"FormLayout\");\n tableElements.push({ scope: bindingPath, meta, label: element.label });\n } else {\n hasFormFields = true;\n Logger.debug(\"[MetaUI FormLayout]\", `Rendering scalar field '${bindingPath}'.`, \"FormLayout\");\n this._renderScalarField(form, element, bindingPath, meta, modelName, engine);\n }\n } else {\n Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, \"\", \"FormLayout\");\n }\n };\n\n // Render everything defined in the layout\n schema.uiLayout.forEach(renderElement);\n\n if (hasFormFields) {\n container.addItem(form);\n }\n\n // Render array/table sub-layouts full width below the form\n tableElements.forEach(field => {\n try {\n const subSchema = {\n type: \"array\",\n title: field.label || field.meta.ui?.label || field.scope,\n items: field.meta.items || { type: \"object\", properties: {} },\n uiLayout: field.meta.items?.uiLayout // Pass down sub-layout if available\n };\n \n const control = engine.generateLayout(subSchema as ISchema, modelName, `/${field.scope}`);\n if (control) {\n control.addStyleClass(\"sapUiSmallMarginTop\");\n container.addItem(control);\n }\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render array field ${field.scope}`, msg, \"FormLayout\");\n Logger.showErrorPopup(`Failed to render array field '${field.scope}'.\\n\\nDetails: ${msg}`);\n }\n });\n\n return container;\n }\n\n private _renderScalarField(form: SimpleForm, element: ILayoutElement, propKey: string, meta: IPropertyMetadata, modelName: string, engine: Engine): void {\n try {\n const labelText = element.label || meta.ui?.label || propKey;\n const label = new Label({\n text: labelText,\n required: meta.required\n });\n\n // Override widget if specified in the layout element\n const effectiveMeta = { ...meta };\n if (element.widget) {\n effectiveMeta.ui = { ...meta.ui, widget: element.widget };\n }\n\n const control = engine.generateField(effectiveMeta, `/${propKey}`, modelName);\n\n if (effectiveMeta.ui?.fullWidth) {\n sap.ui.require([\"sap/ui/layout/GridData\"], (GridData: any) => {\n control.setLayoutData(new GridData({ span: \"XL12 L12 M12 S12\" }));\n });\n }\n\n form.addContent(label);\n form.addContent(control);\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render field ${propKey}`, msg, \"FormLayout\");\n Logger.showErrorPopup(`Failed to render field '${propKey}'.\\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AC7BC,GAAG,CAACpB,EAAE,CAACqB,OAAO,CAAC,CAAC,wBAAwB,CAAC,EAAGC,QAAa,IAAK;YAC1Dd,OAAO,CAACe,aAAa,CAAC,IAAID,QAAQ,CAAC;cAAEE,IAAI,EAAE;YAAmB,CAAC,CAAC,CAAC;UACrE,CAAC,CAAC;QACN;QAEArE,IAAI,CAAC6B,UAAU,CAACD,KAAK,CAAC;QACtB5B,IAAI,CAAC6B,UAAU,CAACwB,OAAO,CAAC;MAC5B,CAAC,CAAC,OAAOjB,KAAK,EAAE;QACZ,MAAMoB,GAAG,GAAIpB,KAAK,CAAWqB,OAAO;QACpCpE,MAAM,CAAC+C,KAAK,CAAC,mCAAmCG,OAAO,EAAE,EAAEiB,GAAG,EAAE,YAAY,CAAC;QAC7EnE,MAAM,CAACqE,cAAc,CAAC,2BAA2BnB,OAAO,kBAAkBiB,GAAG,EAAE,CAAC;MACpF;IACJ;EACJ;EAAC,IAAAc,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAA/E,UAAA,GAAAA,UAAA;EAAA,OAAA+E,SAAA;AAAA","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLayout.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,+CAA+C,CAAC;IAU/D,OAAO,EAAqB,OAAO,EAAkB,MAAM,+CAA+C,CAAC;IAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;IACtF,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"FormLayout.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,+CAA+C,CAAC;IAU/D,OAAO,EAAqB,OAAO,EAAkB,MAAM,+CAA+C,CAAC;IAC3G,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;IACtF,OAAO,EAAE,MAAM,EAAE,MAAM,wCAAwC,CAAC;IAGhE,OAAO,OAAO,MAAM,qBAAqB,CAAC;IAE1C;;;;;;OAMG;IACH,MAAa,UAAW,YAAW,cAAc;QAC7C;;;;;;;;WAQG;QACI,MAAM,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO;QAiGjG,OAAO,CAAC,kBAAkB;KA8B7B;CAEA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
sap.ui.define(["sap/ui/layout/form/SimpleForm","sap/m/Label","sap/ui/core/Title","sap/m/VBox","../utils/Logger"],function(e,t,a,r,o){"use strict";const
|
|
1
|
+
sap.ui.define(["sap/ui/layout/form/SimpleForm","sap/m/Label","sap/ui/core/Title","sap/m/VBox","../core/SchemaNormalizer","../utils/Logger"],function(e,t,a,r,o,i){"use strict";const n=o["SchemaNormalizer"];const s=i["Logger"];class l{render(t,o,i,l){const u=new r({renderType:"Bare"});const p=new e({editable:true,title:t.title,layout:"ResponsiveGridLayout",labelSpanXL:4,labelSpanL:4,labelSpanM:4,labelSpanS:12,adjustLabelSpan:false,emptySpanXL:0,emptySpanL:0,emptySpanM:0,emptySpanS:0,columnsXL:1,columnsL:1,columnsM:1,singleContainerFullSize:false});if(!t.uiLayout||!Array.isArray(t.uiLayout)){s.warn("[MetaUI] Missing 'uiLayout' array in schema. Form will not render any fields.");u.addItem(p);return u}const d=[];let y=false;const c=e=>{if(e.type==="Group"){if(e.label){p.addContent(new a({text:e.label}))}if(e.elements&&Array.isArray(e.elements)){e.elements.forEach(c)}}else if(e.type==="Control"){if(!e.scope||!e.scope.startsWith("#/properties/")){s.error(`[MetaUI] Invalid scope '${e.scope}' in uiLayout Control.`,"","FormLayout");return}const{meta:a,bindingPath:r,propKey:l}=n.resolveScope(t,e.scope);if(!a){s.error(`[MetaUI] Property '${l}' not found in schema definitions.`,"","FormLayout");return}const u=a.items?.type==="object"||a.items?.properties;const c=!!a.ui?.widget;const m=a.type==="array"&&u&&!c;if(m){s.debug("[MetaUI FormLayout]",`Routing property '${l}' to Table Sub-Layout.`,"FormLayout");d.push({scope:r,meta:a,label:e.label})}else{y=true;s.debug("[MetaUI FormLayout]",`Rendering scalar field '${r}'.`,"FormLayout");this._renderScalarField(p,e,r,a,o,i)}}else{s.warn(`[MetaUI] Unsupported layout element type '${e.type}'.`,"","FormLayout")}};t.uiLayout.forEach(c);if(y){u.addItem(p)}d.forEach(e=>{try{const t={type:"array",title:e.label||e.meta.ui?.label||e.scope,items:e.meta.items||{type:"object",properties:{}},uiLayout:e.meta.items?.uiLayout};const a=i.generateLayout(t,o,`/${e.scope}`);if(a){a.addStyleClass("sapUiSmallMarginTop");u.addItem(a)}}catch(t){const a=t.message;s.error(`[MetaUI] Failed to render array field ${e.scope}`,a,"FormLayout");s.showErrorPopup(`Failed to render array field '${e.scope}'.\n\nDetails: ${a}`)}});return u}_renderScalarField(e,a,r,o,i,n){try{const s=a.label||o.ui?.label||r;const l=new t({text:s,required:o.required});const u={...o};if(a.widget){u.ui={...o.ui,widget:a.widget}}const p=n.generateField(u,`/${r}`,i);if(u.ui?.fullWidth){sap.ui.require(["sap/ui/layout/GridData"],e=>{p.setLayoutData(new e({span:"XL12 L12 M12 S12"}))})}e.addContent(l);e.addContent(p)}catch(e){const t=e.message;s.error(`[MetaUI] Failed to render field ${r}`,t,"FormLayout");s.showErrorPopup(`Failed to render field '${r}'.\n\nDetails: ${t}`)}}}var u={__esModule:true};u.FormLayout=l;return u});
|
|
2
2
|
//# sourceMappingURL=FormLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormLayout.js","names":["Logger","___utils_Logger","FormLayout","render","schema","modelName","engine","onSubmit","container","VBox","renderType","form","SimpleForm","editable","title","layout","labelSpanXL","labelSpanL","labelSpanM","labelSpanS","adjustLabelSpan","emptySpanXL","emptySpanL","emptySpanM","emptySpanS","columnsXL","columnsL","columnsM","singleContainerFullSize","uiLayout","Array","isArray","warn","addItem","tableElements","hasFormFields","renderElement","element","type","label","addContent","Title","text","elements","forEach","scope","startsWith","error","propKey","replace","meta","properties","isCollectionOfRecords","items","hasExplicitWidget","ui","widget","isSubLayout","debug","push","this","_renderScalarField","field","subSchema","control","generateLayout","addStyleClass","msg","message","showErrorPopup","labelText","Label","required","effectiveMeta","generateField","fullWidth","sap","require","GridData","setLayoutData","span","__exports","__esModule"],"sources":["FormLayout.ts"],"sourcesContent":["/**\n * @file FormLayout.ts\n * @description Generates a fully responsive SAP Fiori Form layout (SimpleForm).\n */\n\nimport SimpleForm from \"sap/ui/layout/form/SimpleForm\";\nimport Label from \"sap/m/Label\";\nimport Title from \"sap/ui/core/Title\";\nimport VBox from \"sap/m/VBox\";\nimport { IPropertyMetadata, ISchema, ILayoutElement } from \"../interfaces/ISchema\";\nimport { ILayoutManager } from \"../interfaces/ILayoutManager\";\nimport { Engine } from \"../core/Engine\";\nimport { Logger } from \"../utils/Logger\";\nimport Control from \"sap/ui/core/Control\";\n\n/**\n * Layout Manager responsible for generating a fully responsive SAP Fiori SimpleForm.\n * It traverses the `uiLayout` tree defined in the schema to build the form groups and fields,\n * completely separating visual orchestration from data modeling.\n * @namespace nz.co.siliconst.ui5.metaui.layouts\n * @public\n */\nexport class FormLayout implements ILayoutManager {\n /**\n * Renders the JSON Schema properties into a UI5 SimpleForm using the uiLayout definitions.\n * \n * @param schema The active JSON schema subset.\n * @param modelName The bound UI5 model name.\n * @param engine The central orchestrator for delegating plugin generation.\n * @param onSubmit Optional submit hook.\n * @returns {Control} The VBox wrapper containing the generated form.\n */\n public render(schema: ISchema, modelName: string, engine: Engine, onSubmit?: () => void): Control {\n const container = new VBox({ renderType: \"Bare\" });\n const form = new SimpleForm({\n editable: true,\n title: schema.title,\n layout: \"ResponsiveGridLayout\",\n labelSpanXL: 4, labelSpanL: 4, labelSpanM: 4, labelSpanS: 12,\n adjustLabelSpan: false,\n emptySpanXL: 0, emptySpanL: 0, emptySpanM: 0, emptySpanS: 0,\n columnsXL: 1, columnsL: 1, columnsM: 1,\n singleContainerFullSize: false\n });\n\n if (!schema.uiLayout || !Array.isArray(schema.uiLayout)) {\n Logger.warn(\"[MetaUI] Missing 'uiLayout' array in schema. Form will not render any fields.\");\n container.addItem(form);\n return container;\n }\n\n const tableElements: { scope: string, meta: IPropertyMetadata, label?: string }[] = [];\n let hasFormFields = false;\n\n // Recursively render layout elements\n const renderElement = (element: ILayoutElement) => {\n if (element.type === \"Group\") {\n if (element.label) {\n form.addContent(new Title({ text: element.label }));\n }\n \n if (element.elements && Array.isArray(element.elements)) {\n element.elements.forEach(renderElement);\n }\n } else if (element.type === \"Control\") {\n if (!element.scope || !element.scope.startsWith(\"#/properties/\")) {\n Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, \"\", \"FormLayout\");\n return;\n }\n \n const propKey = element.scope.replace(\"#/properties/\", \"\");\n const meta = schema.properties?.[propKey];\n \n if (!meta) {\n Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, \"\", \"FormLayout\");\n return;\n }\n\n // Architectural Boundary: Separate Field Controls (Plugins) from Sub-Layouts (LayoutManagers)\n // A property is delegated to a Sub-Layout Manager (Table) ONLY if it represents a collection of complex objects.\n // Collections of primitives, or explicitly assigned widgets (like multiSelect), remain in the Form as Field Plugins.\n const isCollectionOfRecords = meta.items?.type === \"object\" || meta.items?.properties;\n const hasExplicitWidget = !!meta.ui?.widget;\n const isSubLayout = meta.type === \"array\" && isCollectionOfRecords && !hasExplicitWidget;\n\n if (isSubLayout) {\n Logger.debug(\"[MetaUI FormLayout]\", `Routing property '${propKey}' to Table Sub-Layout.`, \"FormLayout\");\n tableElements.push({ scope: propKey, meta, label: element.label });\n } else {\n hasFormFields = true;\n Logger.debug(\"[MetaUI FormLayout]\", `Rendering scalar field '${propKey}'.`, \"FormLayout\");\n this._renderScalarField(form, element, propKey, meta, modelName, engine);\n }\n } else {\n Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, \"\", \"FormLayout\");\n }\n };\n\n // Render everything defined in the layout\n schema.uiLayout.forEach(renderElement);\n\n if (hasFormFields) {\n container.addItem(form);\n }\n\n // Render array/table sub-layouts full width below the form\n tableElements.forEach(field => {\n try {\n const subSchema = {\n type: \"array\",\n title: field.label || field.meta.ui?.label || field.scope,\n items: field.meta.items || { type: \"object\", properties: {} },\n uiLayout: field.meta.items?.uiLayout // Pass down sub-layout if available\n };\n \n const control = engine.generateLayout(subSchema as ISchema, modelName, `/${field.scope}`);\n if (control) {\n control.addStyleClass(\"sapUiSmallMarginTop\");\n container.addItem(control);\n }\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render array field ${field.scope}`, msg, \"FormLayout\");\n Logger.showErrorPopup(`Failed to render array field '${field.scope}'.\\n\\nDetails: ${msg}`);\n }\n });\n\n return container;\n }\n\n private _renderScalarField(form: SimpleForm, element: ILayoutElement, propKey: string, meta: IPropertyMetadata, modelName: string, engine: Engine): void {\n try {\n const labelText = element.label || meta.ui?.label || propKey;\n const label = new Label({\n text: labelText,\n required: meta.required\n });\n\n // Override widget if specified in the layout element\n const effectiveMeta = { ...meta };\n if (element.widget) {\n effectiveMeta.ui = { ...meta.ui, widget: element.widget };\n }\n\n const control = engine.generateField(effectiveMeta, `/${propKey}`, modelName);\n\n if (effectiveMeta.ui?.fullWidth) {\n sap.ui.require([\"sap/ui/layout/GridData\"], (GridData: any) => {\n control.setLayoutData(new GridData({ span: \"XL12 L12 M12 S12\" }));\n });\n }\n\n form.addContent(label);\n form.addContent(control);\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render field ${propKey}`, msg, \"FormLayout\");\n Logger.showErrorPopup(`Failed to render field '${propKey}'.\\n\\nDetails: ${msg}`);\n }\n }\n}\n"],"mappings":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,EAAKsB,WAInB,MAAMC,EAAgB,IAAKvB,GAC3B,GAAIb,EAAQmB,OAAQ,CAChBiB,EAAclB,GAAK,IAAKL,EAAKK,GAAIC,OAAQnB,EAAQmB,OACrD,CAEA,MAAMQ,EAAU1D,EAAOoE,cAAcD,EAAe,IAAIzB,IAAW3C,GAEnE,GAAIoE,EAAclB,IAAIoB,UAAW,CAC7BC,IAAIrB,GAAGsB,QAAQ,CAAC,0BAA4BC,IACxCd,EAAQe,cAAc,IAAID,EAAS,CAAEE,KAAM,uBAEnD,CAEArE,EAAK6B,WAAWD,GAChB5B,EAAK6B,WAAWwB,EACpB,CAAE,MAAOjB,GACL,MAAMoB,EAAOpB,EAAgBqB,QAC7BpE,EAAO+C,MAAM,mCAAmCC,IAAWmB,EAAK,cAChEnE,EAAOqE,eAAe,2BAA2BrB,mBAAyBmB,IAC9E,CACJ,EACH,IAAAc,EAAA,CAAAC,WAAA,MAAAD,EAAA/E,aAAA,OAAA+E,CAAA","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"FormLayout.js","names":["SchemaNormalizer","___core_SchemaNormalizer","Logger","___utils_Logger","FormLayout","render","schema","modelName","engine","onSubmit","container","VBox","renderType","form","SimpleForm","editable","title","layout","labelSpanXL","labelSpanL","labelSpanM","labelSpanS","adjustLabelSpan","emptySpanXL","emptySpanL","emptySpanM","emptySpanS","columnsXL","columnsL","columnsM","singleContainerFullSize","uiLayout","Array","isArray","warn","addItem","tableElements","hasFormFields","renderElement","element","type","label","addContent","Title","text","elements","forEach","scope","startsWith","error","meta","bindingPath","propKey","resolveScope","isCollectionOfRecords","items","properties","hasExplicitWidget","ui","widget","isSubLayout","debug","push","this","_renderScalarField","field","subSchema","control","generateLayout","addStyleClass","msg","message","showErrorPopup","labelText","Label","required","effectiveMeta","generateField","fullWidth","sap","require","GridData","setLayoutData","span","__exports","__esModule"],"sources":["FormLayout.ts"],"sourcesContent":["/**\n * @file FormLayout.ts\n * @description Generates a fully responsive SAP Fiori Form layout (SimpleForm).\n */\n\nimport SimpleForm from \"sap/ui/layout/form/SimpleForm\";\nimport Label from \"sap/m/Label\";\nimport Title from \"sap/ui/core/Title\";\nimport VBox from \"sap/m/VBox\";\nimport { IPropertyMetadata, ISchema, ILayoutElement } from \"../interfaces/ISchema\";\nimport { ILayoutManager } from \"../interfaces/ILayoutManager\";\nimport { Engine } from \"../core/Engine\";\nimport { SchemaNormalizer } from \"../core/SchemaNormalizer\";\nimport { Logger } from \"../utils/Logger\";\nimport Control from \"sap/ui/core/Control\";\n\n/**\n * Layout Manager responsible for generating a fully responsive SAP Fiori SimpleForm.\n * It traverses the `uiLayout` tree defined in the schema to build the form groups and fields,\n * completely separating visual orchestration from data modeling.\n * @namespace nz.co.siliconst.ui5.metaui.layouts\n * @public\n */\nexport class FormLayout implements ILayoutManager {\n /**\n * Renders the JSON Schema properties into a UI5 SimpleForm using the uiLayout definitions.\n * \n * @param schema The active JSON schema subset.\n * @param modelName The bound UI5 model name.\n * @param engine The central orchestrator for delegating plugin generation.\n * @param onSubmit Optional submit hook.\n * @returns {Control} The VBox wrapper containing the generated form.\n */\n public render(schema: ISchema, modelName: string, engine: Engine, onSubmit?: () => void): Control {\n const container = new VBox({ renderType: \"Bare\" });\n const form = new SimpleForm({\n editable: true,\n title: schema.title,\n layout: \"ResponsiveGridLayout\",\n labelSpanXL: 4, labelSpanL: 4, labelSpanM: 4, labelSpanS: 12,\n adjustLabelSpan: false,\n emptySpanXL: 0, emptySpanL: 0, emptySpanM: 0, emptySpanS: 0,\n columnsXL: 1, columnsL: 1, columnsM: 1,\n singleContainerFullSize: false\n });\n\n if (!schema.uiLayout || !Array.isArray(schema.uiLayout)) {\n Logger.warn(\"[MetaUI] Missing 'uiLayout' array in schema. Form will not render any fields.\");\n container.addItem(form);\n return container;\n }\n\n const tableElements: { scope: string, meta: IPropertyMetadata, label?: string }[] = [];\n let hasFormFields = false;\n\n // Recursively render layout elements\n const renderElement = (element: ILayoutElement) => {\n if (element.type === \"Group\") {\n if (element.label) {\n form.addContent(new Title({ text: element.label }));\n }\n \n if (element.elements && Array.isArray(element.elements)) {\n element.elements.forEach(renderElement);\n }\n } else if (element.type === \"Control\") {\n if (!element.scope || !element.scope.startsWith(\"#/properties/\")) {\n Logger.error(`[MetaUI] Invalid scope '${element.scope}' in uiLayout Control.`, \"\", \"FormLayout\");\n return;\n }\n \n const { meta, bindingPath, propKey } = SchemaNormalizer.resolveScope(schema, element.scope);\n \n if (!meta) {\n Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, \"\", \"FormLayout\");\n return;\n }\n\n // Architectural Boundary: Separate Field Controls (Plugins) from Sub-Layouts (LayoutManagers)\n // A property is delegated to a Sub-Layout Manager (Table) ONLY if it represents a collection of complex objects.\n // Collections of primitives, or explicitly assigned widgets (like multiSelect), remain in the Form as Field Plugins.\n const isCollectionOfRecords = meta.items?.type === \"object\" || meta.items?.properties;\n const hasExplicitWidget = !!meta.ui?.widget;\n const isSubLayout = meta.type === \"array\" && isCollectionOfRecords && !hasExplicitWidget;\n\n if (isSubLayout) {\n Logger.debug(\"[MetaUI FormLayout]\", `Routing property '${propKey}' to Table Sub-Layout.`, \"FormLayout\");\n tableElements.push({ scope: bindingPath, meta, label: element.label });\n } else {\n hasFormFields = true;\n Logger.debug(\"[MetaUI FormLayout]\", `Rendering scalar field '${bindingPath}'.`, \"FormLayout\");\n this._renderScalarField(form, element, bindingPath, meta, modelName, engine);\n }\n } else {\n Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, \"\", \"FormLayout\");\n }\n };\n\n // Render everything defined in the layout\n schema.uiLayout.forEach(renderElement);\n\n if (hasFormFields) {\n container.addItem(form);\n }\n\n // Render array/table sub-layouts full width below the form\n tableElements.forEach(field => {\n try {\n const subSchema = {\n type: \"array\",\n title: field.label || field.meta.ui?.label || field.scope,\n items: field.meta.items || { type: \"object\", properties: {} },\n uiLayout: field.meta.items?.uiLayout // Pass down sub-layout if available\n };\n \n const control = engine.generateLayout(subSchema as ISchema, modelName, `/${field.scope}`);\n if (control) {\n control.addStyleClass(\"sapUiSmallMarginTop\");\n container.addItem(control);\n }\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render array field ${field.scope}`, msg, \"FormLayout\");\n Logger.showErrorPopup(`Failed to render array field '${field.scope}'.\\n\\nDetails: ${msg}`);\n }\n });\n\n return container;\n }\n\n private _renderScalarField(form: SimpleForm, element: ILayoutElement, propKey: string, meta: IPropertyMetadata, modelName: string, engine: Engine): void {\n try {\n const labelText = element.label || meta.ui?.label || propKey;\n const label = new Label({\n text: labelText,\n required: meta.required\n });\n\n // Override widget if specified in the layout element\n const effectiveMeta = { ...meta };\n if (element.widget) {\n effectiveMeta.ui = { ...meta.ui, widget: element.widget };\n }\n\n const control = engine.generateField(effectiveMeta, `/${propKey}`, modelName);\n\n if (effectiveMeta.ui?.fullWidth) {\n sap.ui.require([\"sap/ui/layout/GridData\"], (GridData: any) => {\n control.setLayoutData(new GridData({ span: \"XL12 L12 M12 S12\" }));\n });\n }\n\n form.addContent(label);\n form.addContent(control);\n } catch (error) {\n const msg = (error as Error).message;\n Logger.error(`[MetaUI] Failed to render field ${propKey}`, msg, \"FormLayout\");\n Logger.showErrorPopup(`Failed to render field '${propKey}'.\\n\\nDetails: ${msg}`);\n }\n }\n}\n"],"mappings":"qLAYSA,EAAgBC,EAAA,0BAChBC,EAAMC,EAAA,UAUR,MAAMC,EAUFC,OAAOC,EAAiBC,EAAmBC,EAAgBC,GAC9D,MAAMC,EAAY,IAAIC,EAAK,CAAEC,WAAY,SACzC,MAAMC,EAAO,IAAIC,EAAW,CACxBC,SAAU,KACVC,MAAOV,EAAOU,MACdC,OAAQ,uBACRC,YAAa,EAAGC,WAAY,EAAGC,WAAY,EAAGC,WAAY,GAC1DC,gBAAiB,MACjBC,YAAa,EAAGC,WAAY,EAAGC,WAAY,EAAGC,WAAY,EAC1DC,UAAW,EAAGC,SAAU,EAAGC,SAAU,EACrCC,wBAAyB,Q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AAWyB,EACpB,CAAE,MAAOlB,GACL,MAAMqB,EAAOrB,EAAgBsB,QAC7BrE,EAAO+C,MAAM,mCAAmCG,IAAWkB,EAAK,cAChEpE,EAAOsE,eAAe,2BAA2BpB,mBAAyBkB,IAC9E,CACJ,EACH,IAAAc,EAAA,CAAAC,WAAA,MAAAD,EAAAhF,aAAA,OAAAgF,CAAA","ignoreList":[]}
|
|
@@ -10,6 +10,7 @@ import VBox from "sap/m/VBox";
|
|
|
10
10
|
import { IPropertyMetadata, ISchema, ILayoutElement } from "../interfaces/ISchema";
|
|
11
11
|
import { ILayoutManager } from "../interfaces/ILayoutManager";
|
|
12
12
|
import { Engine } from "../core/Engine";
|
|
13
|
+
import { SchemaNormalizer } from "../core/SchemaNormalizer";
|
|
13
14
|
import { Logger } from "../utils/Logger";
|
|
14
15
|
import Control from "sap/ui/core/Control";
|
|
15
16
|
|
|
@@ -68,8 +69,7 @@ export class FormLayout implements ILayoutManager {
|
|
|
68
69
|
return;
|
|
69
70
|
}
|
|
70
71
|
|
|
71
|
-
const propKey =
|
|
72
|
-
const meta = schema.properties?.[propKey];
|
|
72
|
+
const { meta, bindingPath, propKey } = SchemaNormalizer.resolveScope(schema, element.scope);
|
|
73
73
|
|
|
74
74
|
if (!meta) {
|
|
75
75
|
Logger.error(`[MetaUI] Property '${propKey}' not found in schema definitions.`, "", "FormLayout");
|
|
@@ -85,11 +85,11 @@ export class FormLayout implements ILayoutManager {
|
|
|
85
85
|
|
|
86
86
|
if (isSubLayout) {
|
|
87
87
|
Logger.debug("[MetaUI FormLayout]", `Routing property '${propKey}' to Table Sub-Layout.`, "FormLayout");
|
|
88
|
-
tableElements.push({ scope:
|
|
88
|
+
tableElements.push({ scope: bindingPath, meta, label: element.label });
|
|
89
89
|
} else {
|
|
90
90
|
hasFormFields = true;
|
|
91
|
-
Logger.debug("[MetaUI FormLayout]", `Rendering scalar field '${
|
|
92
|
-
this._renderScalarField(form, element,
|
|
91
|
+
Logger.debug("[MetaUI FormLayout]", `Rendering scalar field '${bindingPath}'.`, "FormLayout");
|
|
92
|
+
this._renderScalarField(form, element, bindingPath, meta, modelName, engine);
|
|
93
93
|
}
|
|
94
94
|
} else {
|
|
95
95
|
Logger.warn(`[MetaUI] Unsupported layout element type '${element.type}'.`, "", "FormLayout");
|