@lcap/nasl 1.0.2 → 2.12.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/out/automate/engine/index.d.ts +1 -0
- package/out/automate/engine/index.js +34 -12
- package/out/automate/engine/index.js.map +1 -1
- package/out/automate/engine/operators.d.ts +10 -2
- package/out/automate/engine/operators.js +105 -7
- package/out/automate/engine/operators.js.map +1 -1
- package/out/automate/engine/uniqueName.d.ts +8 -2
- package/out/automate/engine/uniqueName.js +72 -4
- package/out/automate/engine/uniqueName.js.map +1 -1
- package/out/automate/engine/utils.d.ts +1 -0
- package/out/automate/engine/utils.js +92 -67
- package/out/automate/engine/utils.js.map +1 -1
- package/out/automate/template/process.d.ts +9 -0
- package/out/automate/template/process.js +10976 -0
- package/out/automate/template/process.js.map +1 -0
- package/out/bak/translator.js +1 -0
- package/out/bak/translator.js.map +1 -1
- package/out/common/BaseNode.d.ts +5 -0
- package/out/common/BaseNode.js +24 -3
- package/out/common/BaseNode.js.map +1 -1
- package/out/concepts/App__.d.ts +51 -49
- package/out/concepts/App__.js +86 -53
- package/out/concepts/App__.js.map +1 -1
- package/out/concepts/BindAttribute__.js +2 -2
- package/out/concepts/BindAttribute__.js.map +1 -1
- package/out/concepts/BindDirective__.js +10 -3
- package/out/concepts/BindDirective__.js.map +1 -1
- package/out/concepts/BindEvent__.js +15 -6
- package/out/concepts/BindEvent__.js.map +1 -1
- package/out/concepts/BooleanLiteral__.d.ts +4 -0
- package/out/concepts/BooleanLiteral__.js +11 -0
- package/out/concepts/BooleanLiteral__.js.map +1 -1
- package/out/concepts/CallFunction__.js +8 -2
- package/out/concepts/CallFunction__.js.map +1 -1
- package/out/concepts/CallLogic__.js +48 -30
- package/out/concepts/CallLogic__.js.map +1 -1
- package/out/concepts/CallQueryComponent__.d.ts +8 -7
- package/out/concepts/CallQueryComponent__.js +86 -76
- package/out/concepts/CallQueryComponent__.js.map +1 -1
- package/out/concepts/Comment__.js +1 -1
- package/out/concepts/Comment__.js.map +1 -1
- package/out/concepts/ConfigGroup__.d.ts +1 -0
- package/out/concepts/ConfigGroup__.js +7 -0
- package/out/concepts/ConfigGroup__.js.map +1 -1
- package/out/concepts/ConfigProperty__.d.ts +1 -0
- package/out/concepts/ConfigProperty__.js +3 -0
- package/out/concepts/ConfigProperty__.js.map +1 -1
- package/out/concepts/Configuration__.d.ts +1 -0
- package/out/concepts/Configuration__.js +3 -0
- package/out/concepts/Configuration__.js.map +1 -1
- package/out/concepts/DataSource__.d.ts +143 -0
- package/out/concepts/DataSource__.js +318 -0
- package/out/concepts/DataSource__.js.map +1 -0
- package/out/concepts/Destination__.js +8 -8
- package/out/concepts/Destination__.js.map +1 -1
- package/out/concepts/End__.js +2 -2
- package/out/concepts/End__.js.map +1 -1
- package/out/concepts/EntityIndex__.d.ts +5 -0
- package/out/concepts/EntityIndex__.js +6 -0
- package/out/concepts/EntityIndex__.js.map +1 -1
- package/out/concepts/EntityProperty__.d.ts +9 -0
- package/out/concepts/EntityProperty__.js +19 -2
- package/out/concepts/EntityProperty__.js.map +1 -1
- package/out/concepts/Entity__.d.ts +5 -0
- package/out/concepts/Entity__.js +20 -10
- package/out/concepts/Entity__.js.map +1 -1
- package/out/concepts/Enum__.js +12 -6
- package/out/concepts/Enum__.js.map +1 -1
- package/out/concepts/ForEachStatement__.js +2 -2
- package/out/concepts/ForEachStatement__.js.map +1 -1
- package/out/concepts/Function__.d.ts +18 -0
- package/out/concepts/Function__.js +96 -1
- package/out/concepts/Function__.js.map +1 -1
- package/out/concepts/Identifier__.js +6 -15
- package/out/concepts/Identifier__.js.map +1 -1
- package/out/concepts/IfStatement__.js +8 -8
- package/out/concepts/IfStatement__.js.map +1 -1
- package/out/concepts/Interface__.js +19 -12
- package/out/concepts/Interface__.js.map +1 -1
- package/out/concepts/JSBlock__.js +3 -5
- package/out/concepts/JSBlock__.js.map +1 -1
- package/out/concepts/Logic__.js +44 -44
- package/out/concepts/Logic__.js.map +1 -1
- package/out/concepts/Module__.d.ts +116 -194
- package/out/concepts/Module__.js +31 -114
- package/out/concepts/Module__.js.map +1 -1
- package/out/concepts/Namespace__.d.ts +0 -86
- package/out/concepts/Namespace__.js +1 -108
- package/out/concepts/Namespace__.js.map +1 -1
- package/out/concepts/Param__.d.ts +2 -1
- package/out/concepts/Param__.js +1 -1
- package/out/concepts/Param__.js.map +1 -1
- package/out/concepts/ProcessElement__.js +30 -10
- package/out/concepts/ProcessElement__.js.map +1 -1
- package/out/concepts/Process__.d.ts +1 -1
- package/out/concepts/Process__.js +17 -10
- package/out/concepts/Process__.js.map +1 -1
- package/out/concepts/QueryFieldExpression__.js +8 -1
- package/out/concepts/QueryFieldExpression__.js.map +1 -1
- package/out/concepts/QueryFromExpression__.d.ts +4 -0
- package/out/concepts/QueryFromExpression__.js +13 -2
- package/out/concepts/QueryFromExpression__.js.map +1 -1
- package/out/concepts/QueryJoinExpression__.d.ts +4 -0
- package/out/concepts/QueryJoinExpression__.js +14 -3
- package/out/concepts/QueryJoinExpression__.js.map +1 -1
- package/out/concepts/Return__.js +1 -1
- package/out/concepts/Return__.js.map +1 -1
- package/out/concepts/Role__.js +10 -3
- package/out/concepts/Role__.js.map +1 -1
- package/out/concepts/SqlQueryComponent__.d.ts +14 -0
- package/out/concepts/SqlQueryComponent__.js +48 -5
- package/out/concepts/SqlQueryComponent__.js.map +1 -1
- package/out/concepts/StringLiteral__.d.ts +1 -1
- package/out/concepts/StringLiteral__.js +1 -1
- package/out/concepts/StructureProperty__.js +6 -5
- package/out/concepts/StructureProperty__.js.map +1 -1
- package/out/concepts/Structure__.js +19 -12
- package/out/concepts/Structure__.js.map +1 -1
- package/out/concepts/SwitchCase__.d.ts +1 -1
- package/out/concepts/SwitchCase__.js +23 -25
- package/out/concepts/SwitchCase__.js.map +1 -1
- package/out/concepts/SwitchStatement__.js +1 -6
- package/out/concepts/SwitchStatement__.js.map +1 -1
- package/out/concepts/TypeAnnotation__.d.ts +8 -0
- package/out/concepts/TypeAnnotation__.js +44 -2
- package/out/concepts/TypeAnnotation__.js.map +1 -1
- package/out/concepts/Variable__.js +1 -1
- package/out/concepts/Variable__.js.map +1 -1
- package/out/concepts/ViewElement__.js +25 -20
- package/out/concepts/ViewElement__.js.map +1 -1
- package/out/concepts/View__.d.ts +0 -2
- package/out/concepts/View__.js +27 -32
- package/out/concepts/View__.js.map +1 -1
- package/out/concepts/WhileStatement__.js +4 -4
- package/out/concepts/WhileStatement__.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.auth.js +20 -0
- package/out/concepts/basics/stdlib/nasl.auth.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.process.d.ts +4 -0
- package/out/concepts/basics/stdlib/nasl.process.js +410 -0
- package/out/concepts/basics/stdlib/nasl.process.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.ui.js +1 -11
- package/out/concepts/basics/stdlib/nasl.ui.js.map +1 -1
- package/out/concepts/basics/stdlib/nasl.util.js +280 -2
- package/out/concepts/basics/stdlib/nasl.util.js.map +1 -1
- package/out/concepts/basics/types/index.d.ts +1 -0
- package/out/concepts/basics/types/index.js +4 -1
- package/out/concepts/basics/types/index.js.map +1 -1
- package/out/concepts/index__.d.ts +1 -0
- package/out/concepts/index__.js +1 -0
- package/out/concepts/index__.js.map +1 -1
- package/out/generator/genBundleFiles.d.ts +3 -1
- package/out/generator/genBundleFiles.js +23 -5
- package/out/generator/genBundleFiles.js.map +1 -1
- package/out/generator/genMetaData.d.ts +1 -0
- package/out/generator/genMetaData.js +20 -12
- package/out/generator/genMetaData.js.map +1 -1
- package/out/index.d.ts +1 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/server/createUiTs.js +1 -0
- package/out/server/createUiTs.js.map +1 -1
- package/out/server/getLogics.js +27 -1
- package/out/server/getLogics.js.map +1 -1
- package/out/server/getMemberIdentifier.js +5 -0
- package/out/server/getMemberIdentifier.js.map +1 -1
- package/out/server/getProcesses.d.ts +4 -0
- package/out/server/getProcesses.js +69 -1
- package/out/server/getProcesses.js.map +1 -1
- package/out/server/naslServer.d.ts +1 -0
- package/out/server/naslServer.js +223 -26
- package/out/server/naslServer.js.map +1 -1
- package/out/server/process2LogicNamespace.js +10 -1
- package/out/server/process2LogicNamespace.js.map +1 -1
- package/out/server/translator.js +37 -1
- package/out/server/translator.js.map +1 -1
- package/out/service/creator/errHandles.js +5 -0
- package/out/service/creator/errHandles.js.map +1 -1
- package/out/service/storage/init.d.ts +1 -0
- package/out/service/storage/init.js +95 -84
- package/out/service/storage/init.js.map +1 -1
- package/out/templator/genCreateBlock.js +34 -24
- package/out/templator/genCreateBlock.js.map +1 -1
- package/out/templator/genCurdEditMultipleKeyBlock.js +28 -18
- package/out/templator/genCurdEditMultipleKeyBlock.js.map +1 -1
- package/out/templator/genCurdMultipleKeyBlock.js +45 -29
- package/out/templator/genCurdMultipleKeyBlock.js.map +1 -1
- package/out/templator/genEditTableBlock.js +15 -13
- package/out/templator/genEditTableBlock.js.map +1 -1
- package/out/templator/genEnumSelectBlock.js +1 -1
- package/out/templator/genEnumSelectBlock.js.map +1 -1
- package/out/templator/genGridViewBlock.js +29 -24
- package/out/templator/genGridViewBlock.js.map +1 -1
- package/out/templator/genListViewBlock.js +7 -5
- package/out/templator/genListViewBlock.js.map +1 -1
- package/out/templator/genQueryComponent.js +25 -26
- package/out/templator/genQueryComponent.js.map +1 -1
- package/out/templator/genSelectBlock.js +8 -7
- package/out/templator/genSelectBlock.js.map +1 -1
- package/out/templator/genTableBlock.js +31 -21
- package/out/templator/genTableBlock.js.map +1 -1
- package/out/templator/genUpdateBlock.js +34 -24
- package/out/templator/genUpdateBlock.js.map +1 -1
- package/out/templator/utils.d.ts +2 -2
- package/out/templator/utils.js.map +1 -1
- package/out/test/integration/connect-file.js +6 -6
- package/out/test/integration/connect-file.js.map +1 -1
- package/out/translator/index.js +1 -1
- package/out/translator/index.js.map +1 -1
- package/out/utils/index.d.ts +5 -0
- package/out/utils/index.js +50 -1
- package/out/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/automate/engine/index.js +33 -8
- package/src/automate/engine/operators.js +114 -17
- package/src/automate/engine/uniqueName.js +77 -9
- package/src/automate/engine/utils.js +95 -68
- package/src/automate/template/process.js +10999 -0
- package/src/bak/translator.js +1 -0
- package/src/common/BaseNode.ts +21 -4
- package/src/concepts/App__.ts +128 -94
- package/src/concepts/BindAttribute__.ts +2 -2
- package/src/concepts/BindDirective__.ts +9 -7
- package/src/concepts/BindEvent__.ts +14 -6
- package/src/concepts/BooleanLiteral__.ts +12 -0
- package/src/concepts/CallFunction__.ts +6 -2
- package/src/concepts/CallLogic__.ts +47 -32
- package/src/concepts/CallQueryComponent__.ts +92 -81
- package/src/concepts/Comment__.ts +1 -1
- package/src/concepts/ConfigGroup__.ts +3 -1
- package/src/concepts/ConfigProperty__.ts +4 -0
- package/src/concepts/Configuration__.ts +3 -0
- package/src/concepts/DataSource__.ts +391 -0
- package/src/concepts/Destination__.ts +24 -8
- package/src/concepts/End__.ts +2 -2
- package/src/concepts/EntityIndex__.ts +7 -0
- package/src/concepts/EntityProperty__.ts +20 -2
- package/src/concepts/Entity__.ts +23 -11
- package/src/concepts/Enum__.ts +25 -6
- package/src/concepts/ForEachStatement__.ts +2 -2
- package/src/concepts/Function__.ts +95 -1
- package/src/concepts/Identifier__.ts +15 -15
- package/src/concepts/IfStatement__.ts +9 -9
- package/src/concepts/Interface__.ts +20 -12
- package/src/concepts/JSBlock__.ts +3 -12
- package/src/concepts/Logic__.ts +45 -79
- package/src/concepts/Module__.ts +141 -342
- package/src/concepts/Namespace__.ts +1 -204
- package/src/concepts/Param__.ts +3 -2
- package/src/concepts/ProcessElement__.ts +33 -12
- package/src/concepts/Process__.ts +18 -12
- package/src/concepts/QueryFieldExpression__.ts +9 -1
- package/src/concepts/QueryFromExpression__.ts +13 -2
- package/src/concepts/QueryJoinExpression__.ts +14 -3
- package/src/concepts/Return__.ts +1 -1
- package/src/concepts/Role__.ts +10 -4
- package/src/concepts/SqlQueryComponent__.ts +47 -11
- package/src/concepts/StringLiteral__.ts +1 -1
- package/src/concepts/StructureProperty__.ts +6 -9
- package/src/concepts/Structure__.ts +19 -11
- package/src/concepts/SwitchCase__.ts +23 -27
- package/src/concepts/SwitchStatement__.ts +1 -5
- package/src/concepts/TypeAnnotation__.ts +43 -2
- package/src/concepts/Variable__.ts +1 -1
- package/src/concepts/ViewElement__.ts +26 -39
- package/src/concepts/View__.ts +29 -34
- package/src/concepts/WhileStatement__.ts +4 -4
- package/src/concepts/basics/stdlib/nasl.auth.ts +20 -0
- package/src/concepts/basics/stdlib/nasl.process.ts +406 -0
- package/src/concepts/basics/stdlib/nasl.ui.ts +1 -11
- package/src/concepts/basics/stdlib/nasl.util.ts +281 -2
- package/src/concepts/basics/types/index.ts +1 -0
- package/src/concepts/index__.ts +1 -0
- package/src/generator/genBundleFiles.ts +28 -7
- package/src/generator/genMetaData.ts +22 -13
- package/src/index.ts +1 -1
- package/src/server/createUiTs.ts +1 -0
- package/src/server/getLogics.ts +29 -4
- package/src/server/getMemberIdentifier.ts +4 -0
- package/src/server/getProcesses.ts +68 -0
- package/src/server/naslServer.ts +227 -30
- package/src/server/process2LogicNamespace.ts +29 -19
- package/src/server/translator.ts +39 -1
- package/src/service/creator/errHandles.js +6 -0
- package/src/service/storage/init.ts +97 -86
- package/src/templator/genCreateBlock.ts +35 -26
- package/src/templator/genCurdEditMultipleKeyBlock.ts +29 -21
- package/src/templator/genCurdMultipleKeyBlock.ts +46 -31
- package/src/templator/genEditTableBlock.ts +17 -14
- package/src/templator/genEnumSelectBlock.ts +1 -1
- package/src/templator/genGridViewBlock.ts +30 -25
- package/src/templator/genListViewBlock.ts +10 -7
- package/src/templator/genQueryComponent.ts +28 -27
- package/src/templator/genSelectBlock.ts +9 -8
- package/src/templator/genTableBlock.ts +32 -23
- package/src/templator/genUpdateBlock.ts +35 -25
- package/src/templator/utils.ts +2 -2
- package/src/test/integration/connect-file.ts +6 -6
- package/src/translator/index.ts +1 -1
- package/src/utils/index.ts +51 -0
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* 4. 主键目前支持 Long String Double 类型接口所以只禁用了对应的三个类型
|
|
6
6
|
*/
|
|
7
7
|
import * as utils from '../utils';
|
|
8
|
-
import { App, Namespace, Entity, View, Enum } from '../concepts';
|
|
8
|
+
import { App, Module, Namespace, Entity, View, Enum, DataSource } from '../concepts';
|
|
9
9
|
import {
|
|
10
10
|
NaslCoreTypeAnnotation, NaslUITypeAnnotation,
|
|
11
11
|
NaslTypeAnnotation, NaslLogicItem, NaslNode,
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
} from '.';
|
|
19
19
|
|
|
20
20
|
function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
21
|
-
const
|
|
21
|
+
const dataSource = entity.parentNode as DataSource;
|
|
22
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
22
23
|
const properties = entity.properties.filter(filterProperty('inFilter'));
|
|
23
24
|
return `
|
|
24
25
|
<u-linear-layout justify="space-between">
|
|
@@ -36,13 +37,15 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
36
37
|
} = typeAnnotation || {};
|
|
37
38
|
if (property.relationEntity) {
|
|
38
39
|
// 有外键关联
|
|
39
|
-
const relationEntity =
|
|
40
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
40
41
|
if (relationEntity) {
|
|
41
42
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
42
43
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
43
44
|
if (displayedProperty) {
|
|
44
45
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
45
|
-
|
|
46
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
47
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
48
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
46
49
|
formItem += `
|
|
47
50
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.viewLogicLoad}"
|
|
48
51
|
text-field="${lowerEntityName}.${displayedProperty.name}" value-field="${lowerEntityName}.${relationProperty.name}" :pageable="true" :remote-paging="true" v-model="${vModel}">
|
|
@@ -75,7 +78,7 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
75
78
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
76
79
|
const type = namespaceArr.pop();
|
|
77
80
|
if (type === 'enums') {
|
|
78
|
-
formItem += genEnumSelectBlock(
|
|
81
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
79
82
|
} else {
|
|
80
83
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}"></u-input>`;
|
|
81
84
|
}
|
|
@@ -97,7 +100,8 @@ function genFilterTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroup
|
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGroupMap: Map<string, NameGroup>) {
|
|
100
|
-
const
|
|
103
|
+
const dataSource = entity.parentNode as DataSource;
|
|
104
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
101
105
|
const properties = entity.properties.filter(filterProperty('inForm'));
|
|
102
106
|
|
|
103
107
|
return `
|
|
@@ -129,13 +133,15 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
129
133
|
} = typeAnnotation || {};
|
|
130
134
|
if (property.relationEntity) {
|
|
131
135
|
// 有外键关联
|
|
132
|
-
const relationEntity =
|
|
136
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
133
137
|
if (relationEntity) {
|
|
134
138
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
135
139
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
136
140
|
if (displayedProperty) {
|
|
137
141
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
138
|
-
|
|
142
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
143
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
144
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
139
145
|
formItem += `
|
|
140
146
|
<u-select clearable placeholder="请选择${label}"
|
|
141
147
|
text-field="${lowerEntityName}.${displayedProperty.name}"
|
|
@@ -175,7 +181,7 @@ function genSaveModalTemplate(entity: Entity, nameGroup: NameGroup, selectNameGr
|
|
|
175
181
|
const namespaceArr = propertyTypeNamespace.split('.');
|
|
176
182
|
const type = namespaceArr.pop();
|
|
177
183
|
if (type === 'enums') {
|
|
178
|
-
formItem += genEnumSelectBlock(
|
|
184
|
+
formItem += genEnumSelectBlock(module.findEnumByName(propertyTypeName) as Enum, `${vModel}`, '', `请选择${label}`, true);
|
|
179
185
|
} else {
|
|
180
186
|
formItem += `<u-input v-model="${vModel}" placeholder="请输入${label}" ${property.primaryKey ? `:disabled="${nameGroup.viewVariableIsUpdate}"` : ''}></u-input>`;
|
|
181
187
|
}
|
|
@@ -338,8 +344,8 @@ function genSubmitLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
338
344
|
|
|
339
345
|
function genModifyLogic(entity: Entity, nameGroup: NameGroup) {
|
|
340
346
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
341
|
-
const
|
|
342
|
-
const
|
|
347
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
348
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
343
349
|
|
|
344
350
|
return NaslNode.Logic({
|
|
345
351
|
name: nameGroup.viewLogicModify,
|
|
@@ -353,7 +359,7 @@ function genModifyLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
353
359
|
name: 'scope',
|
|
354
360
|
typeAnnotation: NaslUITypeAnnotation.ScopeOf([
|
|
355
361
|
NaslTypeAnnotation.Reference({
|
|
356
|
-
typeNamespace: `${
|
|
362
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
357
363
|
typeName: nameGroup.structure,
|
|
358
364
|
}),
|
|
359
365
|
]),
|
|
@@ -406,10 +412,11 @@ function genModifyLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
406
412
|
|
|
407
413
|
// 列表(全)
|
|
408
414
|
export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
409
|
-
const
|
|
415
|
+
const dataSource = entity.parentNode as DataSource;
|
|
416
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
410
417
|
|
|
411
418
|
const viewElementMainView = view.getViewElementUniqueName('tableView');
|
|
412
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
419
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
413
420
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
414
421
|
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
415
422
|
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
@@ -424,7 +431,8 @@ export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
424
431
|
nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
|
|
425
432
|
|
|
426
433
|
// 收集所有和本实体关联的实体
|
|
427
|
-
const
|
|
434
|
+
const entitySet: Set<Entity> = new Set();
|
|
435
|
+
entitySet.add(entity);
|
|
428
436
|
const selectNameGroupMap: Map<string, NameGroup> = new Map();
|
|
429
437
|
const newStructures: any[] = [];
|
|
430
438
|
const newLogics: any[] = [];
|
|
@@ -432,17 +440,19 @@ export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
432
440
|
entity.properties.forEach((property) => {
|
|
433
441
|
// 有外键关联
|
|
434
442
|
if (property.relationEntity) {
|
|
435
|
-
const relationEntity =
|
|
443
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
436
444
|
if (relationEntity) {
|
|
437
445
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
438
446
|
if (displayedProperty) {
|
|
439
|
-
|
|
447
|
+
entitySet.add(relationEntity);
|
|
440
448
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
441
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
449
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
442
450
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
443
|
-
|
|
451
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
452
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
453
|
+
selectNameGroupMap.set(key, selectNameGroup);
|
|
444
454
|
const newStructure = genQueryStructure([relationEntity], selectNameGroup);
|
|
445
|
-
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false,
|
|
455
|
+
const newLogic = genQueryLogic([relationEntity], selectNameGroup, false, false, module);
|
|
446
456
|
newStructures.push(newStructure);
|
|
447
457
|
newLogics.push(newLogic);
|
|
448
458
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
@@ -450,10 +460,10 @@ export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
450
460
|
}
|
|
451
461
|
}
|
|
452
462
|
});
|
|
453
|
-
|
|
463
|
+
const allEntities = [...entitySet];
|
|
454
464
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
455
465
|
newStructures.push(entityStructure);
|
|
456
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true,
|
|
466
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
|
|
457
467
|
newLogics.push(entityLogic);
|
|
458
468
|
|
|
459
469
|
return `<template>
|
|
@@ -525,10 +535,11 @@ export function genCurdMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
525
535
|
|
|
526
536
|
// 数据网格(全)
|
|
527
537
|
export function genGridViewMultipleKeyBlock(entity: Entity, view: View) {
|
|
528
|
-
const
|
|
538
|
+
const dataSource = entity.parentNode as DataSource;
|
|
539
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
529
540
|
|
|
530
541
|
const viewElementMainView = view.getViewElementUniqueName('gridView');
|
|
531
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
542
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
532
543
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
533
544
|
nameGroup.viewElementSaveModal = view.getViewElementUniqueName('saveModal');
|
|
534
545
|
nameGroup.viewElementSaveModalForm = view.getViewElementUniqueName('saveModalForm');
|
|
@@ -543,7 +554,8 @@ export function genGridViewMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
543
554
|
nameGroup.viewVariableIsUpdate = view.getVariableUniqueName('isUpdate');
|
|
544
555
|
|
|
545
556
|
// 收集所有和本实体关联的实体
|
|
546
|
-
const
|
|
557
|
+
const entitySet: Set<Entity> = new Set();
|
|
558
|
+
entitySet.add(entity);
|
|
547
559
|
const selectNameGroupMap: Map<string, NameGroup> = new Map();
|
|
548
560
|
const newStructures: any[] = [];
|
|
549
561
|
const newLogics: any[] = [];
|
|
@@ -551,21 +563,23 @@ export function genGridViewMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
551
563
|
entity.properties.forEach((property) => {
|
|
552
564
|
// 有外键关联
|
|
553
565
|
if (property.relationEntity) {
|
|
554
|
-
const relationEntity =
|
|
566
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
555
567
|
if (relationEntity) {
|
|
556
568
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
557
569
|
if (displayedProperty) {
|
|
558
|
-
|
|
570
|
+
entitySet.add(relationEntity);
|
|
559
571
|
const viewElementSelect = view.getViewElementUniqueName('select');
|
|
560
|
-
const selectNameGroup = genUniqueQueryNameGroup(
|
|
572
|
+
const selectNameGroup = genUniqueQueryNameGroup(module, view, viewElementSelect, false, relationEntity.name);
|
|
561
573
|
selectNameGroup.viewElementSelect = viewElementSelect;
|
|
562
|
-
|
|
574
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
575
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
576
|
+
selectNameGroupMap.set(key, selectNameGroup);
|
|
563
577
|
const newStructure = genQueryStructure([
|
|
564
578
|
relationEntity,
|
|
565
579
|
], selectNameGroup);
|
|
566
580
|
const newLogic = genQueryLogic([
|
|
567
581
|
relationEntity,
|
|
568
|
-
], selectNameGroup, false, false,
|
|
582
|
+
], selectNameGroup, false, false, module);
|
|
569
583
|
newStructures.push(newStructure);
|
|
570
584
|
newLogics.push(newLogic);
|
|
571
585
|
newLoadSelectLogics.push(genLoadSelectLogic(relationEntity, selectNameGroup, newLogic));
|
|
@@ -573,9 +587,10 @@ export function genGridViewMultipleKeyBlock(entity: Entity, view: View) {
|
|
|
573
587
|
}
|
|
574
588
|
}
|
|
575
589
|
});
|
|
590
|
+
const allEntities = [...entitySet];
|
|
576
591
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
577
592
|
newStructures.push(entityStructure);
|
|
578
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true,
|
|
593
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
|
|
579
594
|
newLogics.push(entityLogic);
|
|
580
595
|
|
|
581
596
|
return `<template>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as utils from '../utils';
|
|
2
|
-
import { App, Namespace, Entity, EntityProperty } from '../concepts';
|
|
2
|
+
import { App, Module, Namespace, Entity, EntityProperty, DataSource } from '../concepts';
|
|
3
3
|
import {
|
|
4
4
|
getExpression, filterProperty, NameGroup,
|
|
5
5
|
getFirstDisplayedProperty, getParamFromLogic, genCallComponentLogic,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
* @param property 实体属性
|
|
16
16
|
*/
|
|
17
17
|
export function genEditTableColumnTemplate(entity: Entity, property: EntityProperty, nameGroup: NameGroup, selectNameGroupMap?: Map<string, NameGroup>) {
|
|
18
|
-
const
|
|
18
|
+
const dataSource = entity.parentNode as DataSource;
|
|
19
19
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
20
20
|
const valueExpression = `scope.item.${lowerEntityName}.${property.name}`;
|
|
21
21
|
const title = property.label || property.name;
|
|
@@ -45,13 +45,15 @@ export function genEditTableColumnTemplate(entity: Entity, property: EntityPrope
|
|
|
45
45
|
const propertyTypeName = property.typeAnnotation.typeName;
|
|
46
46
|
if (property.relationEntity && selectNameGroupMap) {
|
|
47
47
|
// 有外键关联
|
|
48
|
-
const relationEntity =
|
|
48
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
49
49
|
if (relationEntity) {
|
|
50
50
|
const relationProperty = relationEntity.properties.find((prop) => prop.name === property.relationProperty);
|
|
51
51
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
52
52
|
if (displayedProperty) {
|
|
53
53
|
const lowerEntityName = utils.firstLowerCase(relationEntity.name);
|
|
54
|
-
|
|
54
|
+
// 存在多个属性关联同一个实体的情况,因此加上属性名用以唯一标识
|
|
55
|
+
const key = [property.name, relationEntity.name].join('-');
|
|
56
|
+
const selectNameGroup = selectNameGroupMap.get(key);
|
|
55
57
|
formItem += `
|
|
56
58
|
<u-select clearable placeholder="请选择${label}" :data-source="${selectNameGroup.viewLogicLoad}"
|
|
57
59
|
:autofocus="true" :opened="true" append-to="body" @blur="${nameGroup.viewLogicBlurUpdate}" @select="${nameGroup.viewLogicBlurUpdate}"
|
|
@@ -135,8 +137,9 @@ export function genEditTableTemplate(entity: Entity, nameGroup: NameGroup, selec
|
|
|
135
137
|
* @param entity 实体
|
|
136
138
|
*/
|
|
137
139
|
export function genEditTableLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic: any, supportFilter: boolean) {
|
|
138
|
-
const
|
|
139
|
-
const
|
|
140
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
141
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
142
|
+
|
|
140
143
|
const params = [
|
|
141
144
|
genLogicParam(`${newLogic.params[0].name}`, 'params.page'),
|
|
142
145
|
genLogicParam(`${newLogic.params[1].name}`, 'params.size'),
|
|
@@ -160,7 +163,7 @@ export function genEditTableLoadLogic(entity: Entity, nameGroup: NameGroup, newL
|
|
|
160
163
|
name: 'result',
|
|
161
164
|
typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
|
|
162
165
|
NaslTypeAnnotation.Reference({
|
|
163
|
-
typeNamespace: `${
|
|
166
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
164
167
|
typeName: nameGroup.structure,
|
|
165
168
|
}),
|
|
166
169
|
]),
|
|
@@ -174,7 +177,7 @@ export function genEditTableLoadLogic(entity: Entity, nameGroup: NameGroup, newL
|
|
|
174
177
|
name: 'result',
|
|
175
178
|
}),
|
|
176
179
|
right: NaslLogicItem.CallLogic({
|
|
177
|
-
calleeNamespace: `${
|
|
180
|
+
calleeNamespace: `${moduleNamespace}.logics`,
|
|
178
181
|
calleeName: newLogic.name,
|
|
179
182
|
arguments: params,
|
|
180
183
|
}),
|
|
@@ -190,8 +193,8 @@ export function genEditTableLoadLogic(entity: Entity, nameGroup: NameGroup, newL
|
|
|
190
193
|
*/
|
|
191
194
|
export function genEditTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
192
195
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
193
|
-
const
|
|
194
|
-
const
|
|
196
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
197
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
195
198
|
|
|
196
199
|
const ns = entity.ns;
|
|
197
200
|
const deleteLogic = ns?.logics?.find((logic) => logic.name === `delete`);
|
|
@@ -208,7 +211,7 @@ export function genEditTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
208
211
|
name: 'scope',
|
|
209
212
|
typeAnnotation: NaslUITypeAnnotation.ScopeOf([
|
|
210
213
|
NaslTypeAnnotation.Reference({
|
|
211
|
-
typeNamespace: `${
|
|
214
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
212
215
|
typeName: nameGroup.structure,
|
|
213
216
|
}),
|
|
214
217
|
]),
|
|
@@ -239,8 +242,8 @@ export function genEditTableRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
239
242
|
|
|
240
243
|
export function genBlurUpdateLogic(entity: Entity, nameGroup: NameGroup) {
|
|
241
244
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
242
|
-
const
|
|
243
|
-
const
|
|
245
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
246
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
244
247
|
const ns = entity.ns;
|
|
245
248
|
const updateLogic = ns?.logics?.find((logic) => logic.name === `update`);
|
|
246
249
|
return NaslNode.Logic({
|
|
@@ -255,7 +258,7 @@ export function genBlurUpdateLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
255
258
|
name: 'scope',
|
|
256
259
|
typeAnnotation: NaslUITypeAnnotation.ScopeOf([
|
|
257
260
|
NaslTypeAnnotation.Reference({
|
|
258
|
-
typeNamespace: `${
|
|
261
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
259
262
|
typeName: nameGroup.structure,
|
|
260
263
|
}),
|
|
261
264
|
]),
|
|
@@ -10,7 +10,7 @@ import { Enum } from '../concepts';
|
|
|
10
10
|
*/
|
|
11
11
|
export function genEnumSelectBlock(enumeration: Enum, vModel?: string, size?: string, placeholder?: string, hiddenAll?: boolean) {
|
|
12
12
|
if (config.scope === 'h5')
|
|
13
|
-
return `<van-cascader ${vModel ? ` v-model="${vModel}"` : ''}${placeholder ? ` title="${placeholder}" placeholder="${placeholder}"` : ''}
|
|
13
|
+
return `<van-cascader input-align="left" ${vModel ? ` v-model="${vModel}"` : ''}${placeholder ? ` title="${placeholder}" placeholder="${placeholder}"` : ''}
|
|
14
14
|
:data-source="$utils.EnumList('${enumeration.name}', '${enumeration.getNamespace()}')" labelField="${!hiddenAll ? (placeholder || '') : ''}" :notitleblock="${hiddenAll}"></van-cascader>`;
|
|
15
15
|
|
|
16
16
|
return `<u-select clearable${vModel ? ` v-model="${vModel}"` : ''}${size ? ` size="${size}"` : ''}${placeholder ? ` placeholder="${placeholder}"` : ''}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from '../config';
|
|
2
2
|
import * as utils from '../utils';
|
|
3
|
-
import { App, Namespace, Entity, EntityProperty, View } from '../concepts';
|
|
3
|
+
import { App, Module, Namespace, Entity, EntityProperty, View, DataSource } from '../concepts';
|
|
4
4
|
import {
|
|
5
5
|
getExpression,
|
|
6
6
|
filterProperty,
|
|
@@ -21,14 +21,14 @@ import { NaslCoreTypeAnnotation, NaslUITypeAnnotation, NaslCollectionTypeAnnotat
|
|
|
21
21
|
*/
|
|
22
22
|
export function genGridViewCardTemplate(property: EntityProperty) {
|
|
23
23
|
const entity = property.entity;
|
|
24
|
-
const
|
|
24
|
+
const dataSource = entity.parentNode as DataSource;
|
|
25
25
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
26
26
|
let expression = `scope.item.${lowerEntityName}.${property.name}`;
|
|
27
27
|
const title = property.label || property.name;
|
|
28
28
|
|
|
29
29
|
if (property.relationEntity) {
|
|
30
30
|
// 有外键关联
|
|
31
|
-
const relationEntity =
|
|
31
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
32
32
|
if (relationEntity) {
|
|
33
33
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
34
34
|
if (displayedProperty) {
|
|
@@ -60,14 +60,13 @@ export function genGridViewCardTemplate(property: EntityProperty) {
|
|
|
60
60
|
|
|
61
61
|
export function genH5GridViewCardTemplate(property: EntityProperty) {
|
|
62
62
|
const entity = property.entity;
|
|
63
|
-
const
|
|
63
|
+
const dataSource = entity.parentNode as DataSource;
|
|
64
64
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
65
65
|
let expression = `scope.item.${lowerEntityName}.${property.name}`;
|
|
66
|
-
const title = property.label || property.name;
|
|
67
66
|
|
|
68
67
|
if (property.relationEntity) {
|
|
69
68
|
// 有外键关联
|
|
70
|
-
const relationEntity =
|
|
69
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
71
70
|
if (relationEntity) {
|
|
72
71
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
73
72
|
if (displayedProperty) {
|
|
@@ -149,8 +148,8 @@ export function genH5GridViewTemplate(entity: Entity, nameGroup: NameGroup) {
|
|
|
149
148
|
* @param entity 实体
|
|
150
149
|
*/
|
|
151
150
|
export function genGridViewLoadLogic(entity: Entity, nameGroup: NameGroup, newLogic: any, supportFilter: boolean) {
|
|
152
|
-
const
|
|
153
|
-
const
|
|
151
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
152
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
154
153
|
const params = [
|
|
155
154
|
genLogicParam(`${newLogic.params[0].name}`, 'params.page'),
|
|
156
155
|
genLogicParam(`${newLogic.params[1].name}`, 'params.size'),
|
|
@@ -174,7 +173,7 @@ export function genGridViewLoadLogic(entity: Entity, nameGroup: NameGroup, newLo
|
|
|
174
173
|
name: 'result',
|
|
175
174
|
typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
|
|
176
175
|
NaslTypeAnnotation.Reference({
|
|
177
|
-
typeNamespace: `${
|
|
176
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
178
177
|
typeName: nameGroup.structure,
|
|
179
178
|
}),
|
|
180
179
|
]),
|
|
@@ -188,7 +187,7 @@ export function genGridViewLoadLogic(entity: Entity, nameGroup: NameGroup, newLo
|
|
|
188
187
|
name: 'result',
|
|
189
188
|
}),
|
|
190
189
|
right: NaslLogicItem.CallLogic({
|
|
191
|
-
calleeNamespace: `${
|
|
190
|
+
calleeNamespace: `${moduleNamespace}.logics`,
|
|
192
191
|
calleeName: newLogic.name,
|
|
193
192
|
arguments: params,
|
|
194
193
|
}),
|
|
@@ -204,8 +203,8 @@ export function genGridViewLoadLogic(entity: Entity, nameGroup: NameGroup, newLo
|
|
|
204
203
|
*/
|
|
205
204
|
export function genGridViewRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
206
205
|
const lowerEntityName = utils.firstLowerCase(entity.name);
|
|
207
|
-
const
|
|
208
|
-
const
|
|
206
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
207
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
209
208
|
const ns = entity.ns;
|
|
210
209
|
const deleteLogic = ns?.logics?.find((logic) => logic.name === `delete`);
|
|
211
210
|
const idPropertys = entity.properties.filter((property) => property.primaryKey || property.name === 'id');
|
|
@@ -221,7 +220,7 @@ export function genGridViewRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
221
220
|
name: 'scope',
|
|
222
221
|
typeAnnotation: NaslUITypeAnnotation.ScopeOf([
|
|
223
222
|
NaslTypeAnnotation.Reference({
|
|
224
|
-
typeNamespace: `${
|
|
223
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
225
224
|
typeName: nameGroup.structure,
|
|
226
225
|
}),
|
|
227
226
|
]),
|
|
@@ -260,32 +259,35 @@ export function genGridViewRemoveLogic(entity: Entity, nameGroup: NameGroup) {
|
|
|
260
259
|
*/
|
|
261
260
|
// 数据网格(简)
|
|
262
261
|
export function genGridViewBlock(entity: Entity, view: View) {
|
|
263
|
-
const
|
|
262
|
+
const dataSource = entity.parentNode as DataSource;
|
|
263
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
264
264
|
|
|
265
265
|
const viewElementMainView = view.getViewElementUniqueName('gridView');
|
|
266
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
266
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
267
267
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
268
268
|
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
269
269
|
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
270
270
|
|
|
271
271
|
// 收集所有和本实体关联的实体
|
|
272
|
-
const
|
|
272
|
+
const entitySet: Set<Entity> = new Set();
|
|
273
|
+
entitySet.add(entity);
|
|
273
274
|
const newStructures: any[] = [];
|
|
274
275
|
const newLogics: any[] = [];
|
|
275
276
|
entity.properties.forEach((property) => {
|
|
276
277
|
if (property.relationEntity) {
|
|
277
278
|
// 有外键关联
|
|
278
|
-
const relationEntity =
|
|
279
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
279
280
|
if (relationEntity) {
|
|
280
281
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
281
282
|
if (displayedProperty)
|
|
282
|
-
|
|
283
|
+
entitySet.add(relationEntity);
|
|
283
284
|
}
|
|
284
285
|
}
|
|
285
286
|
});
|
|
287
|
+
const allEntities = [...entitySet];
|
|
286
288
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
287
289
|
newStructures.push(entityStructure);
|
|
288
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true,
|
|
290
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, false, true, module);
|
|
289
291
|
newLogics.push(entityLogic);
|
|
290
292
|
|
|
291
293
|
return `
|
|
@@ -308,32 +310,35 @@ export function genGridViewBlock(entity: Entity, view: View) {
|
|
|
308
310
|
|
|
309
311
|
export function genGridViewCardBlock(property: EntityProperty, view: View) {
|
|
310
312
|
const entity = property.entity;
|
|
311
|
-
const
|
|
313
|
+
const dataSource = entity.parentNode as DataSource;
|
|
314
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
312
315
|
|
|
313
316
|
const viewElementMainView = view.getViewElementUniqueName('gridView');
|
|
314
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
317
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView);
|
|
315
318
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
316
319
|
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
317
320
|
nameGroup.viewLogicRemove = view.getLogicUniqueName('remove');
|
|
318
321
|
|
|
319
322
|
// 收集所有和本实体关联的实体
|
|
320
|
-
const
|
|
323
|
+
const entitySet: Set<Entity> = new Set();
|
|
324
|
+
entitySet.add(entity);
|
|
321
325
|
const newStructures: any[] = [];
|
|
322
326
|
const newLogics: any[] = [];
|
|
323
327
|
entity.properties.forEach((property) => {
|
|
324
328
|
if (property.relationEntity) {
|
|
325
329
|
// 有外键关联
|
|
326
|
-
const relationEntity =
|
|
330
|
+
const relationEntity = dataSource?.findEntityByName(property.relationEntity);
|
|
327
331
|
if (relationEntity) {
|
|
328
332
|
const displayedProperty = getFirstDisplayedProperty(relationEntity);
|
|
329
333
|
if (displayedProperty)
|
|
330
|
-
|
|
334
|
+
entitySet.add(relationEntity);
|
|
331
335
|
}
|
|
332
336
|
}
|
|
333
337
|
});
|
|
338
|
+
const allEntities = [...entitySet];
|
|
334
339
|
const entityStructure = genQueryStructure(allEntities, nameGroup);
|
|
335
340
|
newStructures.push(entityStructure);
|
|
336
|
-
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true,
|
|
341
|
+
const entityLogic = genQueryLogic(allEntities, nameGroup, true, true, module);
|
|
337
342
|
newLogics.push(entityLogic);
|
|
338
343
|
|
|
339
344
|
return `
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { config } from '../config';
|
|
2
2
|
import * as utils from '../utils';
|
|
3
|
-
import { App, Namespace, Entity, EntityProperty, View } from '../concepts';
|
|
3
|
+
import { App, Module, Namespace, Entity, EntityProperty, View, DataSource } from '../concepts';
|
|
4
4
|
import { getExpression, genUniqueQueryNameGroup, getFirstDisplayedProperty, genQueryLogic, genQueryStructure, genLogicParam } from '.';
|
|
5
5
|
import {
|
|
6
6
|
NameGroup, NaslUITypeAnnotation, NaslCollectionTypeAnnotation,
|
|
@@ -39,8 +39,10 @@ export function genH5ListViewTemplate(property: EntityProperty, nameGroup: NameG
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
export function genLoadListViewLogic(entity: Entity, nameGroup: NameGroup, newStructures: Array<any>, newLogics: Array<any>) {
|
|
42
|
-
const parentNode = entity.parentNode as App | Namespace;
|
|
43
|
-
|
|
42
|
+
const parentNode = entity.parentNode as App | Module | Namespace;
|
|
43
|
+
|
|
44
|
+
const moduleNode = utils.findClosestModule(entity) as App | Module;
|
|
45
|
+
const moduleNamespace = moduleNode?.getNamespace();
|
|
44
46
|
|
|
45
47
|
// Select 和 table 不一样,直接在内部产生了
|
|
46
48
|
const entityStructure = genQueryStructure([entity], nameGroup);
|
|
@@ -61,7 +63,7 @@ export function genLoadListViewLogic(entity: Entity, nameGroup: NameGroup, newSt
|
|
|
61
63
|
name: 'result',
|
|
62
64
|
typeAnnotation: NaslCollectionTypeAnnotation.PageOf([
|
|
63
65
|
NaslTypeAnnotation.Reference({
|
|
64
|
-
typeNamespace: `${
|
|
66
|
+
typeNamespace: `${moduleNamespace}.structures`,
|
|
65
67
|
typeName: nameGroup.structure,
|
|
66
68
|
}),
|
|
67
69
|
]),
|
|
@@ -75,7 +77,7 @@ export function genLoadListViewLogic(entity: Entity, nameGroup: NameGroup, newSt
|
|
|
75
77
|
name: 'result',
|
|
76
78
|
}),
|
|
77
79
|
right: NaslLogicItem.CallLogic({
|
|
78
|
-
calleeNamespace: `${
|
|
80
|
+
calleeNamespace: `${moduleNamespace}.logics`,
|
|
79
81
|
calleeName: entityLogic.name,
|
|
80
82
|
arguments: [
|
|
81
83
|
genLogicParam(`${entityLogic.params[0].name}`, 'params.page'),
|
|
@@ -92,10 +94,11 @@ export function genLoadListViewLogic(entity: Entity, nameGroup: NameGroup, newSt
|
|
|
92
94
|
* 生成实体选择框区块
|
|
93
95
|
*/
|
|
94
96
|
export function genListViewBlock(entity: Entity, view: View, property: EntityProperty) {
|
|
95
|
-
const
|
|
97
|
+
const dataSource = entity.parentNode as DataSource;
|
|
98
|
+
const module = dataSource.parentNode as App | Module | Namespace;
|
|
96
99
|
|
|
97
100
|
const viewElementMainView = view.getViewElementUniqueName('listView');
|
|
98
|
-
const nameGroup = genUniqueQueryNameGroup(
|
|
101
|
+
const nameGroup = genUniqueQueryNameGroup(module, view, viewElementMainView, false);
|
|
99
102
|
nameGroup.viewElementMainView = viewElementMainView;
|
|
100
103
|
nameGroup.viewVariableEntity = view.getVariableUniqueName(utils.firstLowerCase(entity.name));
|
|
101
104
|
|