@siliconst/metaui 1.0.2 → 1.2.0
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/README.md +134 -123
- package/package.json +3 -2
- package/src/nz/co/siliconst/ui5/metaui/.library +7 -7
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost-dbg.js +299 -163
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.d.ts +54 -6
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.ts +292 -162
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine-dbg.js +51 -43
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.d.ts +5 -0
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.ts +49 -40
- package/src/nz/co/siliconst/ui5/metaui/core/Engine-dbg.js +81 -58
- package/src/nz/co/siliconst/ui5/metaui/core/Engine-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.d.ts +5 -12
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/Engine.ts +82 -56
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus-dbg.js +65 -50
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.d.ts +9 -0
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/EventBus.ts +60 -45
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js +72 -59
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts +6 -4
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.ts +71 -56
- package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js +145 -36
- 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 +13 -8
- 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 +157 -31
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager-dbg.js +55 -55
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/core/StateManager.ts +56 -56
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus-dbg.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.ts +29 -29
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager-dbg.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.d.ts +6 -12
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.ts +21 -26
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin-dbg.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.d.ts +3 -20
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.ts +14 -33
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts +33 -43
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.ts +70 -70
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout-dbg.js +23 -38
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.d.ts +4 -17
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.ts +22 -34
- package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js +98 -56
- 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 +7 -7
- 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 +97 -60
- package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js +102 -90
- 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 +4 -8
- 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 +119 -102
- package/src/nz/co/siliconst/ui5/metaui/library-dbg.js +43 -32
- package/src/nz/co/siliconst/ui5/metaui/library-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/library-preload.js +22 -17
- package/src/nz/co/siliconst/ui5/metaui/library-preload.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/library.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/library.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/library.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/library.ts +55 -43
- package/src/nz/co/siliconst/ui5/metaui/manifest.json +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin-dbg.js +68 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.d.ts +15 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.ts +71 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin-dbg.js +54 -59
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.d.ts +8 -27
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.ts +56 -58
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin-dbg.js +41 -42
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.d.ts +2 -2
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.ts +41 -42
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin-dbg.js +68 -60
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.d.ts +2 -2
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.ts +69 -63
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin-dbg.js +68 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.ts +68 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin-dbg.js +66 -66
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.d.ts +2 -2
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.ts +65 -65
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin-dbg.js +55 -53
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.d.ts +3 -3
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.ts +56 -55
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin-dbg.js +56 -53
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin-dbg.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.d.ts +2 -2
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.d.ts.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.js +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.js.map +1 -1
- package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.ts +58 -55
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin-dbg.js +43 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.ts +42 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin-dbg.js +58 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.ts +58 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin-dbg.js +74 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin-dbg.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.d.ts +18 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.d.ts.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.js +2 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.js.map +1 -0
- package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.ts +71 -0
- package/ui5.yaml +3 -3
- package/test-resources/App.js +0 -11
- package/test-resources/Main.controller.js +0 -73
- package/test-resources/Main.view.xml +0 -42
- package/test-resources/index.html +0 -21
- package/test-resources/mockData.json +0 -27
- package/test-resources/mockSchema.json +0 -98
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
sap.ui.define(["sap/m/Button"], function (Button) {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
class ArrayPlugin {
|
|
5
|
+
render(field, bindingPath, modelName) {
|
|
6
|
+
// In tables, bindingPath is usually passed simply as the key (e.g. 'lineItems' or '/lineItems')
|
|
7
|
+
const propKey = bindingPath.startsWith("/") ? bindingPath.substring(1) : bindingPath;
|
|
8
|
+
return new Button({
|
|
9
|
+
text: "View Records",
|
|
10
|
+
icon: "sap-icon://list",
|
|
11
|
+
press: oEvent => {
|
|
12
|
+
const btn = oEvent.getSource();
|
|
13
|
+
const context = btn.getBindingContext(modelName);
|
|
14
|
+
if (!context) return;
|
|
15
|
+
const rowData = context.getObject();
|
|
16
|
+
const nestedData = rowData[propKey] || [];
|
|
17
|
+
|
|
18
|
+
// Synthesize a v2 schema for the nested array dialog as an object wrapper
|
|
19
|
+
const subSchema = {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
[propKey]: {
|
|
23
|
+
type: "array",
|
|
24
|
+
ui: {
|
|
25
|
+
label: field.ui?.label || propKey
|
|
26
|
+
},
|
|
27
|
+
items: field.items || {
|
|
28
|
+
type: "object",
|
|
29
|
+
properties: {} // inference will handle it if empty
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
sap.ui.require(["nz/co/siliconst/ui5/metaui/controls/GeneratorHost"], GeneratorHost => {
|
|
35
|
+
const host = new GeneratorHost({
|
|
36
|
+
schemaDefinition: subSchema,
|
|
37
|
+
initialData: {
|
|
38
|
+
[propKey]: nestedData
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// V2 Fix: Capture the nested dialog's save event and update the parent model!
|
|
43
|
+
host.attachSubmit(e => {
|
|
44
|
+
const payload = e.getParameter("payload");
|
|
45
|
+
const updatedArray = payload[propKey];
|
|
46
|
+
const parentModel = btn.getModel(modelName);
|
|
47
|
+
const contextPath = btn.getBindingContext(modelName).getPath();
|
|
48
|
+
|
|
49
|
+
// Push changes back to parent model to force UI5 bindings to refresh
|
|
50
|
+
parentModel.setProperty(`${contextPath}/${propKey}`, updatedArray);
|
|
51
|
+
});
|
|
52
|
+
host.openInDialog(`Nested Records: ${field.ui?.label || propKey}`, "Close");
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
validate() {
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
onStateChange(newMetadata) {}
|
|
61
|
+
}
|
|
62
|
+
var __exports = {
|
|
63
|
+
__esModule: true
|
|
64
|
+
};
|
|
65
|
+
__exports.ArrayPlugin = ArrayPlugin;
|
|
66
|
+
return __exports;
|
|
67
|
+
});
|
|
68
|
+
//# sourceMappingURL=ArrayPlugin-dbg.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayPlugin-dbg.js","names":["ArrayPlugin","render","field","bindingPath","modelName","propKey","startsWith","substring","Button","text","icon","press","oEvent","btn","getSource","context","getBindingContext","rowData","getObject","nestedData","subSchema","type","properties","ui","label","items","sap","require","GeneratorHost","host","schemaDefinition","initialData","attachSubmit","e","payload","getParameter","updatedArray","parentModel","getModel","contextPath","getPath","setProperty","openInDialog","validate","onStateChange","newMetadata","__exports","__esModule"],"sources":["ArrayPlugin.ts"],"sourcesContent":["/**\n * @file ArrayPlugin.ts\n * @description Renders a button that drills down into a nested table (array) via a recursive Dialog using v2 schema.\n */\n\nimport { IPlugin } from \"../interfaces/IPlugin\";\nimport { IPropertyMetadata } from \"../interfaces/ISchema\";\nimport Control from \"sap/ui/core/Control\";\nimport Button from \"sap/m/Button\";\nimport JSONModel from \"sap/ui/model/json/JSONModel\";\n\nexport class ArrayPlugin implements IPlugin {\n public render(field: IPropertyMetadata, bindingPath: string, modelName: string): Control {\n // In tables, bindingPath is usually passed simply as the key (e.g. 'lineItems' or '/lineItems')\n const propKey = bindingPath.startsWith(\"/\") ? bindingPath.substring(1) : bindingPath;\n \n return new Button({\n text: \"View Records\",\n icon: \"sap-icon://list\",\n press: (oEvent: any) => {\n const btn = oEvent.getSource() as Button;\n const context = btn.getBindingContext(modelName);\n if (!context) return;\n \n const rowData = context.getObject();\n const nestedData = rowData[propKey] || [];\n \n // Synthesize a v2 schema for the nested array dialog as an object wrapper\n const subSchema = {\n type: \"object\",\n properties: {\n [propKey]: {\n type: \"array\",\n ui: { label: field.ui?.label || propKey },\n items: field.items || {\n type: \"object\",\n properties: {} // inference will handle it if empty\n }\n }\n }\n };\n\n sap.ui.require([\"nz/co/siliconst/ui5/metaui/controls/GeneratorHost\"], (GeneratorHost: any) => {\n const host = new GeneratorHost({\n schemaDefinition: subSchema,\n initialData: {\n [propKey]: nestedData\n }\n });\n\n // V2 Fix: Capture the nested dialog's save event and update the parent model!\n host.attachSubmit((e: any) => {\n const payload = e.getParameter(\"payload\");\n const updatedArray = payload[propKey];\n \n const parentModel = btn.getModel(modelName) as JSONModel;\n const contextPath = btn.getBindingContext(modelName).getPath();\n \n // Push changes back to parent model to force UI5 bindings to refresh\n parentModel.setProperty(`${contextPath}/${propKey}`, updatedArray);\n });\n\n host.openInDialog(`Nested Records: ${field.ui?.label || propKey}`, \"Close\");\n });\n }\n });\n }\n\n public validate(): boolean { return true; }\n public onStateChange(newMetadata: IPropertyMetadata): void {}\n}\n"],"mappings":";;;EAWO,MAAMA,WAAW,CAAoB;IACjCC,MAAMA,CAACC,KAAwB,EAAEC,WAAmB,EAAEC,SAAiB,EAAW;MACrF;MACA,MAAMC,OAAO,GAAGF,WAAW,CAACG,UAAU,CAAC,GAAG,CAAC,GAAGH,WAAW,CAACI,SAAS,CAAC,CAAC,CAAC,GAAGJ,WAAW;MAEpF,OAAO,IAAIK,MAAM,CAAC;QACdC,IAAI,EAAE,cAAc;QACpBC,IAAI,EAAE,iBAAiB;QACvBC,KAAK,EAAGC,MAAW,IAAK;UACpB,MAAMC,GAAG,GAAGD,MAAM,CAACE,SAAS,CAAC,CAAW;UACxC,MAAMC,OAAO,GAAGF,GAAG,CAACG,iBAAiB,CAACZ,SAAS,CAAC;UAChD,IAAI,CAACW,OAAO,EAAE;UAEd,MAAME,OAAO,GAAGF,OAAO,CAACG,SAAS,CAAC,CAAC;UACnC,MAAMC,UAAU,GAAGF,OAAO,CAACZ,OAAO,CAAC,IAAI,EAAE;;UAEzC;UACA,MAAMe,SAAS,GAAG;YACdC,IAAI,EAAE,QAAQ;YACdC,UAAU,EAAE;cACR,CAACjB,OAAO,GAAG;gBACPgB,IAAI,EAAE,OAAO;gBACbE,EAAE,EAAE;kBAAEC,KAAK,EAAEtB,KAAK,CAACqB,EAAE,EAAEC,KAAK,IAAInB;gBAAQ,CAAC;gBACzCoB,KAAK,EAAEvB,KAAK,CAACuB,KAAK,IAAI;kBAClBJ,IAAI,EAAE,QAAQ;kBACdC,UAAU,EAAE,CAAC,CAAC,CAAC;gBACnB;cACJ;YACJ;UACJ,CAAC;UAEDI,GAAG,CAACH,EAAE,CAACI,OAAO,CAAC,CAAC,mDAAmD,CAAC,EAAGC,aAAkB,IAAK;YAC1F,MAAMC,IAAI,GAAG,IAAID,aAAa,CAAC;cAC3BE,gBAAgB,EAAEV,SAAS;cAC3BW,WAAW,EAAE;gBACT,CAAC1B,OAAO,GAAGc;cACf;YACJ,CAAC,CAAC;;YAEF;YACAU,IAAI,CAACG,YAAY,CAAEC,CAAM,IAAK;cAC1B,MAAMC,OAAO,GAAGD,CAAC,CAACE,YAAY,CAAC,SAAS,CAAC;cACzC,MAAMC,YAAY,GAAGF,OAAO,CAAC7B,OAAO,CAAC;cAErC,MAAMgC,WAAW,GAAGxB,GAAG,CAACyB,QAAQ,CAAClC,SAAS,CAAc;cACxD,MAAMmC,WAAW,GAAG1B,GAAG,CAACG,iBAAiB,CAACZ,SAAS,CAAC,CAACoC,OAAO,CAAC,CAAC;;cAE9D;cACAH,WAAW,CAACI,WAAW,CAAC,GAAGF,WAAW,IAAIlC,OAAO,EAAE,EAAE+B,YAAY,CAAC;YACtE,CAAC,CAAC;YAEFP,IAAI,CAACa,YAAY,CAAC,mBAAmBxC,KAAK,CAACqB,EAAE,EAAEC,KAAK,IAAInB,OAAO,EAAE,EAAE,OAAO,CAAC;UAC/E,CAAC,CAAC;QACN;MACJ,CAAC,CAAC;IACN;IAEOsC,QAAQA,CAAA,EAAY;MAAE,OAAO,IAAI;IAAE;IACnCC,aAAaA,CAACC,WAA8B,EAAQ,CAAC;EAChE;EAAC,IAAAC,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAA9C,WAAA,GAAAA,WAAA;EAAA,OAAA8C,SAAA;AAAA","ignoreList":[]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare module "nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin" {
|
|
2
|
+
/**
|
|
3
|
+
* @file ArrayPlugin.ts
|
|
4
|
+
* @description Renders a button that drills down into a nested table (array) via a recursive Dialog using v2 schema.
|
|
5
|
+
*/
|
|
6
|
+
import { IPlugin } from "nz/co/siliconst/ui5/metaui/interfaces/IPlugin";
|
|
7
|
+
import { IPropertyMetadata } from "nz/co/siliconst/ui5/metaui/interfaces/ISchema";
|
|
8
|
+
import Control from "sap/ui/core/Control";
|
|
9
|
+
export class ArrayPlugin implements IPlugin {
|
|
10
|
+
render(field: IPropertyMetadata, bindingPath: string, modelName: string): Control;
|
|
11
|
+
validate(): boolean;
|
|
12
|
+
onStateChange(newMetadata: IPropertyMetadata): void;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ArrayPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayPlugin.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,gDAAgD,CAAC;IAChE;;;OAGG;IAEH,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;IACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;IAClF,OAAO,OAAO,MAAM,qBAAqB,CAAC;IAI1C,MAAa,WAAY,YAAW,OAAO;QAChC,MAAM,CAAC,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO;QAwDjF,QAAQ,IAAI,OAAO;QACnB,aAAa,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI;KAC7D;CAEA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
sap.ui.define(["sap/m/Button"],function(t){"use strict";class e{render(e,n,s){const o=n.startsWith("/")?n.substring(1):n;return new t({text:"View Records",icon:"sap-icon://list",press:t=>{const n=t.getSource();const i=n.getBindingContext(s);if(!i)return;const r=i.getObject();const a=r[o]||[];const c={type:"object",properties:{[o]:{type:"array",ui:{label:e.ui?.label||o},items:e.items||{type:"object",properties:{}}}}};sap.ui.require(["nz/co/siliconst/ui5/metaui/controls/GeneratorHost"],t=>{const i=new t({schemaDefinition:c,initialData:{[o]:a}});i.attachSubmit(t=>{const e=t.getParameter("payload");const i=e[o];const r=n.getModel(s);const a=n.getBindingContext(s).getPath();r.setProperty(`${a}/${o}`,i)});i.openInDialog(`Nested Records: ${e.ui?.label||o}`,"Close")})}})}validate(){return true}onStateChange(t){}}var n={__esModule:true};n.ArrayPlugin=e;return n});
|
|
2
|
+
//# sourceMappingURL=ArrayPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayPlugin.js","names":["ArrayPlugin","render","field","bindingPath","modelName","propKey","startsWith","substring","Button","text","icon","press","oEvent","btn","getSource","context","getBindingContext","rowData","getObject","nestedData","subSchema","type","properties","ui","label","items","sap","require","GeneratorHost","host","schemaDefinition","initialData","attachSubmit","e","payload","getParameter","updatedArray","parentModel","getModel","contextPath","getPath","setProperty","openInDialog","validate","onStateChange","newMetadata","__exports","__esModule"],"sources":["ArrayPlugin.ts"],"sourcesContent":["/**\n * @file ArrayPlugin.ts\n * @description Renders a button that drills down into a nested table (array) via a recursive Dialog using v2 schema.\n */\n\nimport { IPlugin } from \"../interfaces/IPlugin\";\nimport { IPropertyMetadata } from \"../interfaces/ISchema\";\nimport Control from \"sap/ui/core/Control\";\nimport Button from \"sap/m/Button\";\nimport JSONModel from \"sap/ui/model/json/JSONModel\";\n\nexport class ArrayPlugin implements IPlugin {\n public render(field: IPropertyMetadata, bindingPath: string, modelName: string): Control {\n // In tables, bindingPath is usually passed simply as the key (e.g. 'lineItems' or '/lineItems')\n const propKey = bindingPath.startsWith(\"/\") ? bindingPath.substring(1) : bindingPath;\n \n return new Button({\n text: \"View Records\",\n icon: \"sap-icon://list\",\n press: (oEvent: any) => {\n const btn = oEvent.getSource() as Button;\n const context = btn.getBindingContext(modelName);\n if (!context) return;\n \n const rowData = context.getObject();\n const nestedData = rowData[propKey] || [];\n \n // Synthesize a v2 schema for the nested array dialog as an object wrapper\n const subSchema = {\n type: \"object\",\n properties: {\n [propKey]: {\n type: \"array\",\n ui: { label: field.ui?.label || propKey },\n items: field.items || {\n type: \"object\",\n properties: {} // inference will handle it if empty\n }\n }\n }\n };\n\n sap.ui.require([\"nz/co/siliconst/ui5/metaui/controls/GeneratorHost\"], (GeneratorHost: any) => {\n const host = new GeneratorHost({\n schemaDefinition: subSchema,\n initialData: {\n [propKey]: nestedData\n }\n });\n\n // V2 Fix: Capture the nested dialog's save event and update the parent model!\n host.attachSubmit((e: any) => {\n const payload = e.getParameter(\"payload\");\n const updatedArray = payload[propKey];\n \n const parentModel = btn.getModel(modelName) as JSONModel;\n const contextPath = btn.getBindingContext(modelName).getPath();\n \n // Push changes back to parent model to force UI5 bindings to refresh\n parentModel.setProperty(`${contextPath}/${propKey}`, updatedArray);\n });\n\n host.openInDialog(`Nested Records: ${field.ui?.label || propKey}`, \"Close\");\n });\n }\n });\n }\n\n public validate(): boolean { return true; }\n public onStateChange(newMetadata: IPropertyMetadata): void {}\n}\n"],"mappings":"wDAWO,MAAMA,EACFC,OAAOC,EAA0BC,EAAqBC,GAEzD,MAAMC,EAAUF,EAAYG,WAAW,KAAOH,EAAYI,UAAU,GAAKJ,EAEzE,OAAO,IAAIK,EAAO,CACdC,KAAM,eACNC,KAAM,kBACNC,MAAQC,IACJ,MAAMC,EAAMD,EAAOE,YACnB,MAAMC,EAAUF,EAAIG,kBAAkBZ,GACtC,IAAKW,EAAS,OAEd,MAAME,EAAUF,EAAQG,YACxB,MAAMC,EAAaF,EAAQZ,IAAY,GAGvC,MAAMe,EAAY,CACdC,KAAM,SACNC,WAAY,CACRjB,CAACA,GAAU,CACPgB,KAAM,QACNE,GAAI,CAAEC,MAAOtB,EAAMqB,IAAIC,OAASnB,GAChCoB,MAAOvB,EAAMuB,OAAS,CAClBJ,KAAM,SACNC,WAAY,CAAC,MAM7BI,IAAIH,GAAGI,QAAQ,CAAC,qDAAuDC,IACnE,MAAMC,EAAO,IAAID,EAAc,CAC3BE,iBAAkBV,EAClBW,YAAa,CACT1B,CAACA,GAAUc,KAKnBU,EAAKG,aAAcC,IACf,MAAMC,EAAUD,EAAEE,aAAa,WAC/B,MAAMC,EAAeF,EAAQ7B,GAE7B,MAAMgC,EAAcxB,EAAIyB,SAASlC,GACjC,MAAMmC,EAAc1B,EAAIG,kBAAkBZ,GAAWoC,UAGrDH,EAAYI,YAAY,GAAGF,KAAelC,IAAW+B,KAGzDP,EAAKa,aAAa,mBAAmBxC,EAAMqB,IAAIC,OAASnB,IAAW,aAInF,CAEOsC,WAAsB,OAAO,IAAM,CACnCC,cAAcC,GAAuC,EAC/D,IAAAC,EAAA,CAAAC,WAAA,MAAAD,EAAA9C,cAAA,OAAA8C,CAAA","ignoreList":[]}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file ArrayPlugin.ts
|
|
3
|
+
* @description Renders a button that drills down into a nested table (array) via a recursive Dialog using v2 schema.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IPlugin } from "../interfaces/IPlugin";
|
|
7
|
+
import { IPropertyMetadata } from "../interfaces/ISchema";
|
|
8
|
+
import Control from "sap/ui/core/Control";
|
|
9
|
+
import Button from "sap/m/Button";
|
|
10
|
+
import JSONModel from "sap/ui/model/json/JSONModel";
|
|
11
|
+
|
|
12
|
+
export class ArrayPlugin implements IPlugin {
|
|
13
|
+
public render(field: IPropertyMetadata, bindingPath: string, modelName: string): Control {
|
|
14
|
+
// In tables, bindingPath is usually passed simply as the key (e.g. 'lineItems' or '/lineItems')
|
|
15
|
+
const propKey = bindingPath.startsWith("/") ? bindingPath.substring(1) : bindingPath;
|
|
16
|
+
|
|
17
|
+
return new Button({
|
|
18
|
+
text: "View Records",
|
|
19
|
+
icon: "sap-icon://list",
|
|
20
|
+
press: (oEvent: any) => {
|
|
21
|
+
const btn = oEvent.getSource() as Button;
|
|
22
|
+
const context = btn.getBindingContext(modelName);
|
|
23
|
+
if (!context) return;
|
|
24
|
+
|
|
25
|
+
const rowData = context.getObject();
|
|
26
|
+
const nestedData = rowData[propKey] || [];
|
|
27
|
+
|
|
28
|
+
// Synthesize a v2 schema for the nested array dialog as an object wrapper
|
|
29
|
+
const subSchema = {
|
|
30
|
+
type: "object",
|
|
31
|
+
properties: {
|
|
32
|
+
[propKey]: {
|
|
33
|
+
type: "array",
|
|
34
|
+
ui: { label: field.ui?.label || propKey },
|
|
35
|
+
items: field.items || {
|
|
36
|
+
type: "object",
|
|
37
|
+
properties: {} // inference will handle it if empty
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
sap.ui.require(["nz/co/siliconst/ui5/metaui/controls/GeneratorHost"], (GeneratorHost: any) => {
|
|
44
|
+
const host = new GeneratorHost({
|
|
45
|
+
schemaDefinition: subSchema,
|
|
46
|
+
initialData: {
|
|
47
|
+
[propKey]: nestedData
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// V2 Fix: Capture the nested dialog's save event and update the parent model!
|
|
52
|
+
host.attachSubmit((e: any) => {
|
|
53
|
+
const payload = e.getParameter("payload");
|
|
54
|
+
const updatedArray = payload[propKey];
|
|
55
|
+
|
|
56
|
+
const parentModel = btn.getModel(modelName) as JSONModel;
|
|
57
|
+
const contextPath = btn.getBindingContext(modelName).getPath();
|
|
58
|
+
|
|
59
|
+
// Push changes back to parent model to force UI5 bindings to refresh
|
|
60
|
+
parentModel.setProperty(`${contextPath}/${propKey}`, updatedArray);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
host.openInDialog(`Nested Records: ${field.ui?.label || propKey}`, "Close");
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public validate(): boolean { return true; }
|
|
70
|
+
public onStateChange(newMetadata: IPropertyMetadata): void {}
|
|
71
|
+
}
|
|
@@ -1,60 +1,55 @@
|
|
|
1
|
-
sap.ui.define(["../core/EventBus"], function (___core_EventBus) {
|
|
2
|
-
"use strict";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* @file BasePlugin.ts
|
|
6
|
-
* @description Abstract foundation for all MetaUI plugins, enforcing lifecycle hooks.
|
|
7
|
-
*/
|
|
8
|
-
const EventBus = ___core_EventBus["EventBus"];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
__esModule: true
|
|
56
|
-
};
|
|
57
|
-
__exports.BasePlugin = BasePlugin;
|
|
58
|
-
return __exports;
|
|
59
|
-
});
|
|
1
|
+
sap.ui.define(["../core/EventBus"], function (___core_EventBus) {
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @file BasePlugin.ts
|
|
6
|
+
* @description Abstract foundation for all MetaUI plugins, enforcing lifecycle hooks for v2 Schema.
|
|
7
|
+
*/
|
|
8
|
+
const EventBus = ___core_EventBus["EventBus"];
|
|
9
|
+
class BasePlugin {
|
|
10
|
+
control = null;
|
|
11
|
+
metadata = null;
|
|
12
|
+
fieldKey = "";
|
|
13
|
+
onStateChange(newMetadata) {
|
|
14
|
+
this.metadata = newMetadata;
|
|
15
|
+
this.applyState();
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Helper to apply common UI directives (like readOnly, visibleOn) directly to any control.
|
|
19
|
+
*/
|
|
20
|
+
applyCommonDirectives(control, metadata, modelName = "meta") {
|
|
21
|
+
if (metadata.ui?.readOnly !== undefined && typeof control.setEditable === "function") {
|
|
22
|
+
control.setEditable(!metadata.ui.readOnly);
|
|
23
|
+
}
|
|
24
|
+
if (metadata.ui?.visibleOn) {
|
|
25
|
+
const expr = `{= ${metadata.ui.visibleOn.replace(/\$root\./g, `${modelName}>/`).replace(/\./g, '/')} }`;
|
|
26
|
+
control.bindProperty("visible", {
|
|
27
|
+
parts: [{
|
|
28
|
+
path: "meta>/"
|
|
29
|
+
}],
|
|
30
|
+
formatter: () => false
|
|
31
|
+
});
|
|
32
|
+
// The ConditionEngine handles actual binding injection, but here we can set a fallback or natively bind if we bypass ConditionEngine.
|
|
33
|
+
control.bindProperty("visible", expr);
|
|
34
|
+
}
|
|
35
|
+
if (metadata.ui?.enabledOn && typeof control.setEnabled === "function") {
|
|
36
|
+
const expr = `{= ${metadata.ui.enabledOn.replace(/\$root\./g, `${modelName}>/`).replace(/\./g, '/')} }`;
|
|
37
|
+
control.bindProperty("enabled", expr);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
publishChange(newValue) {
|
|
41
|
+
if (this.metadata && this.fieldKey) {
|
|
42
|
+
EventBus.getInstance().publishFieldChange({
|
|
43
|
+
fieldName: this.fieldKey,
|
|
44
|
+
newValue: newValue
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
var __exports = {
|
|
50
|
+
__esModule: true
|
|
51
|
+
};
|
|
52
|
+
__exports.BasePlugin = BasePlugin;
|
|
53
|
+
return __exports;
|
|
54
|
+
});
|
|
60
55
|
//# sourceMappingURL=BasePlugin-dbg.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasePlugin-dbg.js","names":["EventBus","___core_EventBus","BasePlugin","control","metadata","onStateChange","newMetadata","applyState","publishChange","newValue","getInstance","publishFieldChange","fieldName","__exports","__esModule"],"sources":["BasePlugin.ts"],"sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"BasePlugin-dbg.js","names":["EventBus","___core_EventBus","BasePlugin","control","metadata","fieldKey","onStateChange","newMetadata","applyState","applyCommonDirectives","modelName","ui","readOnly","undefined","setEditable","visibleOn","expr","replace","bindProperty","parts","path","formatter","enabledOn","setEnabled","publishChange","newValue","getInstance","publishFieldChange","fieldName","__exports","__esModule"],"sources":["BasePlugin.ts"],"sourcesContent":["/**\n * @file BasePlugin.ts\n * @description Abstract foundation for all MetaUI plugins, enforcing lifecycle hooks for v2 Schema.\n */\n\nimport { IPlugin } from \"../interfaces/IPlugin\";\nimport { IPropertyMetadata } from \"../interfaces/ISchema\";\nimport { EventBus } from \"../core/EventBus\";\nimport Control from \"sap/ui/core/Control\";\n\nexport abstract class BasePlugin implements IPlugin {\n protected control: Control | null = null;\n protected metadata: IPropertyMetadata | null = null;\n protected fieldKey: string = \"\";\n\n public abstract render(fieldMetadata: IPropertyMetadata, bindingPath: string, modelName?: string): Control;\n\n public abstract validate(): boolean;\n\n public onStateChange(newMetadata: IPropertyMetadata): void {\n this.metadata = newMetadata;\n this.applyState();\n }\n\n protected abstract applyState(): void;\n\n /**\n * Helper to apply common UI directives (like readOnly, visibleOn) directly to any control.\n */\n protected applyCommonDirectives(control: any, metadata: IPropertyMetadata, modelName: string = \"meta\"): void {\n if (metadata.ui?.readOnly !== undefined && typeof control.setEditable === \"function\") {\n control.setEditable(!metadata.ui.readOnly);\n }\n\n if (metadata.ui?.visibleOn) {\n const expr = `{= ${metadata.ui.visibleOn.replace(/\\$root\\./g, `${modelName}>/`).replace(/\\./g, '/')} }`;\n control.bindProperty(\"visible\", { parts: [{ path: \"meta>/\" }], formatter: () => false });\n // The ConditionEngine handles actual binding injection, but here we can set a fallback or natively bind if we bypass ConditionEngine.\n control.bindProperty(\"visible\", expr);\n }\n \n if (metadata.ui?.enabledOn && typeof control.setEnabled === \"function\") {\n const expr = `{= ${metadata.ui.enabledOn.replace(/\\$root\\./g, `${modelName}>/`).replace(/\\./g, '/')} }`;\n control.bindProperty(\"enabled\", expr);\n }\n }\n\n protected publishChange(newValue: any): void {\n if (this.metadata && this.fieldKey) {\n EventBus.getInstance().publishFieldChange({\n fieldName: this.fieldKey,\n newValue: newValue\n });\n }\n }\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;EAHA,MAOSA,QAAQ,GAAAC,gBAAA;EAGV,MAAeC,UAAU,CAAoB;IACtCC,OAAO,GAAmB,IAAI;IAC9BC,QAAQ,GAA6B,IAAI;IACzCC,QAAQ,GAAW,EAAE;IAMxBC,aAAaA,CAACC,WAA8B,EAAQ;MACvD,IAAI,CAACH,QAAQ,GAAGG,WAAW;MAC3B,IAAI,CAACC,UAAU,CAAC,CAAC;IACrB;IAIA;AACJ;AACA;IACcC,qBAAqBA,CAACN,OAAY,EAAEC,QAA2B,EAAEM,SAAiB,GAAG,MAAM,EAAQ;MACzG,IAAIN,QAAQ,CAACO,EAAE,EAAEC,QAAQ,KAAKC,SAAS,IAAI,OAAOV,OAAO,CAACW,WAAW,KAAK,UAAU,EAAE;QAClFX,OAAO,CAACW,WAAW,CAAC,CAACV,QAAQ,CAACO,EAAE,CAACC,QAAQ,CAAC;MAC9C;MAEA,IAAIR,QAAQ,CAACO,EAAE,EAAEI,SAAS,EAAE;QACxB,MAAMC,IAAI,GAAG,MAAMZ,QAAQ,CAACO,EAAE,CAACI,SAAS,CAACE,OAAO,CAAC,WAAW,EAAE,GAAGP,SAAS,IAAI,CAAC,CAACO,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI;QACvGd,OAAO,CAACe,YAAY,CAAC,SAAS,EAAE;UAAEC,KAAK,EAAE,CAAC;YAAEC,IAAI,EAAE;UAAS,CAAC,CAAC;UAAEC,SAAS,EAAEA,CAAA,KAAM;QAAM,CAAC,CAAC;QACxF;QACAlB,OAAO,CAACe,YAAY,CAAC,SAAS,EAAEF,IAAI,CAAC;MACzC;MAEA,IAAIZ,QAAQ,CAACO,EAAE,EAAEW,SAAS,IAAI,OAAOnB,OAAO,CAACoB,UAAU,KAAK,UAAU,EAAE;QACpE,MAAMP,IAAI,GAAG,MAAMZ,QAAQ,CAACO,EAAE,CAACW,SAAS,CAACL,OAAO,CAAC,WAAW,EAAE,GAAGP,SAAS,IAAI,CAAC,CAACO,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI;QACvGd,OAAO,CAACe,YAAY,CAAC,SAAS,EAAEF,IAAI,CAAC;MACzC;IACJ;IAEUQ,aAAaA,CAACC,QAAa,EAAQ;MACzC,IAAI,IAAI,CAACrB,QAAQ,IAAI,IAAI,CAACC,QAAQ,EAAE;QAChCL,QAAQ,CAAC0B,WAAW,CAAC,CAAC,CAACC,kBAAkB,CAAC;UACtCC,SAAS,EAAE,IAAI,CAACvB,QAAQ;UACxBoB,QAAQ,EAAEA;QACd,CAAC,CAAC;MACN;IACJ;EACJ;EAAC,IAAAI,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAA3B,UAAA,GAAAA,UAAA;EAAA,OAAA2B,SAAA;AAAA","ignoreList":[]}
|
|
@@ -1,42 +1,23 @@
|
|
|
1
1
|
declare module "nz/co/siliconst/ui5/metaui/plugins/BasePlugin" {
|
|
2
2
|
/**
|
|
3
3
|
* @file BasePlugin.ts
|
|
4
|
-
* @description Abstract foundation for all MetaUI plugins, enforcing lifecycle hooks.
|
|
4
|
+
* @description Abstract foundation for all MetaUI plugins, enforcing lifecycle hooks for v2 Schema.
|
|
5
5
|
*/
|
|
6
6
|
import { IPlugin } from "nz/co/siliconst/ui5/metaui/interfaces/IPlugin";
|
|
7
|
-
import {
|
|
7
|
+
import { IPropertyMetadata } from "nz/co/siliconst/ui5/metaui/interfaces/ISchema";
|
|
8
8
|
import Control from "sap/ui/core/Control";
|
|
9
|
-
/**
|
|
10
|
-
* Abstract class providing baseline properties and event publishing hooks for all UI5 controls.
|
|
11
|
-
*/
|
|
12
9
|
export abstract class BasePlugin implements IPlugin {
|
|
13
|
-
/** The actual generated UI5 control. */
|
|
14
10
|
protected control: Control | null;
|
|
15
|
-
|
|
16
|
-
protected
|
|
17
|
-
|
|
18
|
-
* Must be implemented by concrete classes to generate the specific control.
|
|
19
|
-
* @param fieldMetadata The immutable schema configuration.
|
|
20
|
-
* @param bindingPath The exact model path where this field's data is stored.
|
|
21
|
-
*/
|
|
22
|
-
abstract render(fieldMetadata: IFieldMetadata, bindingPath: string): Control;
|
|
23
|
-
/**
|
|
24
|
-
* Must be implemented by concrete classes to run data integrity checks.
|
|
25
|
-
*/
|
|
11
|
+
protected metadata: IPropertyMetadata | null;
|
|
12
|
+
protected fieldKey: string;
|
|
13
|
+
abstract render(fieldMetadata: IPropertyMetadata, bindingPath: string, modelName?: string): Control;
|
|
26
14
|
abstract validate(): boolean;
|
|
27
|
-
|
|
28
|
-
* Triggered by the ConditionEngine when cross-field rules alter this field's metadata.
|
|
29
|
-
* @param newMetadata The dynamically updated rules.
|
|
30
|
-
*/
|
|
31
|
-
onStateChange(newMetadata: IFieldMetadata): void;
|
|
32
|
-
/**
|
|
33
|
-
* Abstract hook for concrete plugins to re-bind their visibility or read-only states natively.
|
|
34
|
-
*/
|
|
15
|
+
onStateChange(newMetadata: IPropertyMetadata): void;
|
|
35
16
|
protected abstract applyState(): void;
|
|
36
17
|
/**
|
|
37
|
-
*
|
|
38
|
-
* @param newValue The newly entered/selected value.
|
|
18
|
+
* Helper to apply common UI directives (like readOnly, visibleOn) directly to any control.
|
|
39
19
|
*/
|
|
20
|
+
protected applyCommonDirectives(control: any, metadata: IPropertyMetadata, modelName?: string): void;
|
|
40
21
|
protected publishChange(newValue: any): void;
|
|
41
22
|
}
|
|
42
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasePlugin.d.ts","sourceRoot":"
|
|
1
|
+
{"version":3,"file":"BasePlugin.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,+CAA+C,CAAC;IAC/D;;;OAGG;IAEH,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;IACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,+CAA+C,CAAC;IAElF,OAAO,OAAO,MAAM,qBAAqB,CAAC;IAE1C,eAAsB,UAAW,YAAW,OAAO;QAC/C,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAQ;QACzC,SAAS,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAQ;QACpD,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAM;iBAEhB,MAAM,CAAC,aAAa,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO;iBAE1F,QAAQ,IAAI,OAAO;QAE5B,aAAa,CAAC,WAAW,EAAE,iBAAiB,GAAG,IAAI;QAK1D,SAAS,CAAC,QAAQ,CAAC,UAAU,IAAI,IAAI;QAErC;;WAEG;QACH,SAAS,CAAC,qBAAqB,CAAC,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,iBAAiB,EAAE,SAAS,GAAE,MAAe,GAAG,IAAI;QAkB5G,SAAS,CAAC,aAAa,CAAC,QAAQ,EAAE,GAAG,GAAG,IAAI;KAQ/C;CAEA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
sap.ui.define(["../core/EventBus"],function(e){"use strict";const t=e["EventBus"];class
|
|
1
|
+
sap.ui.define(["../core/EventBus"],function(e){"use strict";const t=e["EventBus"];class i{control=null;metadata=null;fieldKey="";onStateChange(e){this.metadata=e;this.applyState()}applyCommonDirectives(e,t,i="meta"){if(t.ui?.readOnly!==undefined&&typeof e.setEditable==="function"){e.setEditable(!t.ui.readOnly)}if(t.ui?.visibleOn){const a=`{= ${t.ui.visibleOn.replace(/\$root\./g,`${i}>/`).replace(/\./g,"/")} }`;e.bindProperty("visible",{parts:[{path:"meta>/"}],formatter:()=>false});e.bindProperty("visible",a)}if(t.ui?.enabledOn&&typeof e.setEnabled==="function"){const a=`{= ${t.ui.enabledOn.replace(/\$root\./g,`${i}>/`).replace(/\./g,"/")} }`;e.bindProperty("enabled",a)}}publishChange(e){if(this.metadata&&this.fieldKey){t.getInstance().publishFieldChange({fieldName:this.fieldKey,newValue:e})}}}var a={__esModule:true};a.BasePlugin=i;return a});
|
|
2
2
|
//# sourceMappingURL=BasePlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BasePlugin.js","names":["EventBus","___core_EventBus","BasePlugin","control","metadata","onStateChange","newMetadata","this","applyState","publishChange","newValue","getInstance","publishFieldChange","fieldName","__exports","__esModule"],"sources":["BasePlugin.ts"],"sourcesContent":["/**\
|
|
1
|
+
{"version":3,"file":"BasePlugin.js","names":["EventBus","___core_EventBus","BasePlugin","control","metadata","fieldKey","onStateChange","newMetadata","this","applyState","applyCommonDirectives","modelName","ui","readOnly","undefined","setEditable","visibleOn","expr","replace","bindProperty","parts","path","formatter","enabledOn","setEnabled","publishChange","newValue","getInstance","publishFieldChange","fieldName","__exports","__esModule"],"sources":["BasePlugin.ts"],"sourcesContent":["/**\n * @file BasePlugin.ts\n * @description Abstract foundation for all MetaUI plugins, enforcing lifecycle hooks for v2 Schema.\n */\n\nimport { IPlugin } from \"../interfaces/IPlugin\";\nimport { IPropertyMetadata } from \"../interfaces/ISchema\";\nimport { EventBus } from \"../core/EventBus\";\nimport Control from \"sap/ui/core/Control\";\n\nexport abstract class BasePlugin implements IPlugin {\n protected control: Control | null = null;\n protected metadata: IPropertyMetadata | null = null;\n protected fieldKey: string = \"\";\n\n public abstract render(fieldMetadata: IPropertyMetadata, bindingPath: string, modelName?: string): Control;\n\n public abstract validate(): boolean;\n\n public onStateChange(newMetadata: IPropertyMetadata): void {\n this.metadata = newMetadata;\n this.applyState();\n }\n\n protected abstract applyState(): void;\n\n /**\n * Helper to apply common UI directives (like readOnly, visibleOn) directly to any control.\n */\n protected applyCommonDirectives(control: any, metadata: IPropertyMetadata, modelName: string = \"meta\"): void {\n if (metadata.ui?.readOnly !== undefined && typeof control.setEditable === \"function\") {\n control.setEditable(!metadata.ui.readOnly);\n }\n\n if (metadata.ui?.visibleOn) {\n const expr = `{= ${metadata.ui.visibleOn.replace(/\\$root\\./g, `${modelName}>/`).replace(/\\./g, '/')} }`;\n control.bindProperty(\"visible\", { parts: [{ path: \"meta>/\" }], formatter: () => false });\n // The ConditionEngine handles actual binding injection, but here we can set a fallback or natively bind if we bypass ConditionEngine.\n control.bindProperty(\"visible\", expr);\n }\n \n if (metadata.ui?.enabledOn && typeof control.setEnabled === \"function\") {\n const expr = `{= ${metadata.ui.enabledOn.replace(/\\$root\\./g, `${modelName}>/`).replace(/\\./g, '/')} }`;\n control.bindProperty(\"enabled\", expr);\n }\n }\n\n protected publishChange(newValue: any): void {\n if (this.metadata && this.fieldKey) {\n EventBus.getInstance().publishFieldChange({\n fieldName: this.fieldKey,\n newValue: newValue\n });\n }\n }\n}\n"],"mappings":"4DAAA,MAOSA,EAAQC,EAAA,YAGV,MAAeC,EACRC,QAA0B,KAC1BC,SAAqC,KACrCC,SAAmB,GAMtBC,cAAcC,GACjBC,KAAKJ,SAAWG,EAChBC,KAAKC,YACT,CAOUC,sBAAsBP,EAAcC,EAA6BO,EAAoB,QAC3F,GAAIP,EAASQ,IAAIC,WAAaC,kBAAoBX,EAAQY,cAAgB,WAAY,CAClFZ,EAAQY,aAAaX,EAASQ,GAAGC,SACrC,CAEA,GAAIT,EAASQ,IAAII,UAAW,CACxB,MAAMC,EAAO,MAAMb,EAASQ,GAAGI,UAAUE,QAAQ,YAAa,GAAGP,OAAeO,QAAQ,MAAO,SAC/Ff,EAAQgB,aAAa,UAAW,CAAEC,MAAO,CAAC,CAAEC,KAAM,WAAaC,UAAWA,IAAM,QAEhFnB,EAAQgB,aAAa,UAAWF,EACpC,CAEA,GAAIb,EAASQ,IAAIW,kBAAoBpB,EAAQqB,aAAe,WAAY,CACpE,MAAMP,EAAO,MAAMb,EAASQ,GAAGW,UAAUL,QAAQ,YAAa,GAAGP,OAAeO,QAAQ,MAAO,SAC/Ff,EAAQgB,aAAa,UAAWF,EACpC,CACJ,CAEUQ,cAAcC,GACpB,GAAIlB,KAAKJ,UAAYI,KAAKH,SAAU,CAChCL,EAAS2B,cAAcC,mBAAmB,CACtCC,UAAWrB,KAAKH,SAChBqB,SAAUA,GAElB,CACJ,EACH,IAAAI,EAAA,CAAAC,WAAA,MAAAD,EAAA5B,aAAA,OAAA4B,CAAA","ignoreList":[]}
|
|
@@ -1,58 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file BasePlugin.ts
|
|
3
|
-
* @description Abstract foundation for all MetaUI plugins, enforcing lifecycle hooks.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { IPlugin } from "../interfaces/IPlugin";
|
|
7
|
-
import {
|
|
8
|
-
import { EventBus } from "../core/EventBus";
|
|
9
|
-
import Control from "sap/ui/core/Control";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
*/
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @file BasePlugin.ts
|
|
3
|
+
* @description Abstract foundation for all MetaUI plugins, enforcing lifecycle hooks for v2 Schema.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { IPlugin } from "../interfaces/IPlugin";
|
|
7
|
+
import { IPropertyMetadata } from "../interfaces/ISchema";
|
|
8
|
+
import { EventBus } from "../core/EventBus";
|
|
9
|
+
import Control from "sap/ui/core/Control";
|
|
10
|
+
|
|
11
|
+
export abstract class BasePlugin implements IPlugin {
|
|
12
|
+
protected control: Control | null = null;
|
|
13
|
+
protected metadata: IPropertyMetadata | null = null;
|
|
14
|
+
protected fieldKey: string = "";
|
|
15
|
+
|
|
16
|
+
public abstract render(fieldMetadata: IPropertyMetadata, bindingPath: string, modelName?: string): Control;
|
|
17
|
+
|
|
18
|
+
public abstract validate(): boolean;
|
|
19
|
+
|
|
20
|
+
public onStateChange(newMetadata: IPropertyMetadata): void {
|
|
21
|
+
this.metadata = newMetadata;
|
|
22
|
+
this.applyState();
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
protected abstract applyState(): void;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Helper to apply common UI directives (like readOnly, visibleOn) directly to any control.
|
|
29
|
+
*/
|
|
30
|
+
protected applyCommonDirectives(control: any, metadata: IPropertyMetadata, modelName: string = "meta"): void {
|
|
31
|
+
if (metadata.ui?.readOnly !== undefined && typeof control.setEditable === "function") {
|
|
32
|
+
control.setEditable(!metadata.ui.readOnly);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (metadata.ui?.visibleOn) {
|
|
36
|
+
const expr = `{= ${metadata.ui.visibleOn.replace(/\$root\./g, `${modelName}>/`).replace(/\./g, '/')} }`;
|
|
37
|
+
control.bindProperty("visible", { parts: [{ path: "meta>/" }], formatter: () => false });
|
|
38
|
+
// The ConditionEngine handles actual binding injection, but here we can set a fallback or natively bind if we bypass ConditionEngine.
|
|
39
|
+
control.bindProperty("visible", expr);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (metadata.ui?.enabledOn && typeof control.setEnabled === "function") {
|
|
43
|
+
const expr = `{= ${metadata.ui.enabledOn.replace(/\$root\./g, `${modelName}>/`).replace(/\./g, '/')} }`;
|
|
44
|
+
control.bindProperty("enabled", expr);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
protected publishChange(newValue: any): void {
|
|
49
|
+
if (this.metadata && this.fieldKey) {
|
|
50
|
+
EventBus.getInstance().publishFieldChange({
|
|
51
|
+
fieldName: this.fieldKey,
|
|
52
|
+
newValue: newValue
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|