Skip to content

Commit

Permalink
没有设置meta时也允许单独使用view模型
Browse files Browse the repository at this point in the history
  • Loading branch information
entropy-cloud committed Sep 3, 2023
1 parent 3104b89 commit 3d93df3
Show file tree
Hide file tree
Showing 10 changed files with 106 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15780,6 +15780,10 @@
"name": "getJavaTypeName",
"parameterTypes": []
},
{
"name": "getJsonType",
"parameterTypes": []
},
{
"name": "getMandatoryJavaClass",
"parameterTypes": []
Expand Down Expand Up @@ -36876,6 +36880,10 @@
"name": "getBeforeExecute",
"parameterTypes": []
},
{
"name": "getDecisionMatrxi",
"parameterTypes": []
},
{
"name": "getRoleIds",
"parameterTypes": []
Expand All @@ -36894,6 +36902,12 @@
"java.lang.String"
]
},
{
"name": "setDecisionMatrix",
"parameterTypes": [
"java.lang.String"
]
},
{
"name": "setRuleInputs",
"parameterTypes": [
Expand Down Expand Up @@ -38394,6 +38408,13 @@
"io.nop.core.context.IServiceContext"
]
},
{
"name": "getInputJsonSchema",
"parameterTypes": [
"io.nop.rule.api.beans.RuleKeyBean",
"io.nop.core.context.IServiceContext"
]
},
{
"name": "getOutputFields",
"parameterTypes": [
Expand Down
10 changes: 7 additions & 3 deletions nop-demo/nop-quarkus-demo/src/main/resources/nop-vfs-index.txt
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@
/nop/report/imp/xpt.imp.xml
/nop/report/spl/spl.xlib
/nop/rule/_module
/nop/rule/auth/_nop-rule-api.action-auth.xml
/nop/rule/auth/_nop-rule.action-auth.xml
/nop/rule/auth/nop-rule.action-auth.xml
/nop/rule/auth/nop-rule.data-auth.xml
Expand Down Expand Up @@ -369,6 +370,9 @@
/nop/rule/pages/NopRuleRole/_gen/_NopRuleRole.view.xml
/nop/rule/pages/NopRuleRole/main.page.yaml
/nop/rule/pages/NopRuleRole/picker.page.yaml
/nop/rule/pages/RuleService/RuleService.view.xml
/nop/rule/pages/RuleService/_RuleService.view.xml
/nop/rule/pages/RuleService/main.page.yaml
/nop/schema/action-auth.xdef
/nop/schema/api.xdef
/nop/schema/beans.xdef
Expand Down Expand Up @@ -556,9 +560,9 @@
/nop/templates/antlr/src/main/java/{parser.packagePath}/{parser.name}ParseTreeParser.java.xgen
/nop/templates/api-web/@init.xrun
/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/auth/_{apiModelName}-api.action-auth.xml.xgen
/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel}/_{serviceModel.name}.view.xml.xgen
/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel}/main.page.yaml.xgen
/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel}/{serviceModel.name}.view.xml.xgen
/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel.name}/_{serviceModel.name}.view.xml.xgen
/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel.name}/main.page.yaml.xgen
/nop/templates/api-web/src/main/resources/_vfs/{moduleId}/pages/{serviceModel.name}/{serviceModel.name}.view.xml.xgen
/nop/templates/api/@init.xrun
/nop/templates/api/{apiModuleName}/src/main/java/{apiPackagePath}/beans/_gen/_{messageModel.name}.java.xgen
/nop/templates/api/{apiModuleName}/src/main/java/{apiPackagePath}/beans/{messageModel.name}.java.xgen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ public interface NopRuleDaoConstants extends _NopRuleDaoConstants {
String OUTPUTS_NAME = "outputs";

String BEFORE_EXECUTE_NAME = "beforeExecute";

String DECISION_MATRIX_NAME = "decisionMatrix";
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.util.Set;

import static io.nop.rule.dao.NopRuleDaoConstants.BEFORE_EXECUTE_NAME;
import static io.nop.rule.dao.NopRuleDaoConstants.DECISION_MATRIX_NAME;
import static io.nop.rule.dao.NopRuleDaoConstants.INPUTS_NAME;
import static io.nop.rule.dao.NopRuleDaoConstants.OUTPUTS_NAME;
import static io.nop.rule.dao.NopRuleDaoConstants.RULE_TAG_NAME;
Expand Down Expand Up @@ -52,4 +53,12 @@ public String getBeforeExecute() {
public void setBeforeExecute(String value) {
getModelTextXmlComponent().setChildBodyXml(RULE_TAG_NAME, BEFORE_EXECUTE_NAME, value);
}

public String getDecisionMatrxi() {
return getModelTextXmlComponent().getChildBodyXml(DECISION_MATRIX_NAME);
}

public void setDecisionMatrix(String value) {
getModelTextXmlComponent().setChildBodyXml(RULE_TAG_NAME, DECISION_MATRIX_NAME, value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@
ui:uploadAccept=".rule.xlsx">
<schema stdDomain="file"/>
</prop>

<prop name="decisionMatrix" displayName="决策矩阵配置" ui:show="L">
<schema stdDomain="xml" />
</prop>
</props>
</meta>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
<form id="edit" layoutControl="tabs" size="xl" x:prototype="template">
<layout>
==baseInfo[基本信息]====
__useImportFile importFile
ruleName[规则名称] ruleVersion[规则版本]
displayName[显示名称] ruleGroup[规则分组]
ruleType[规则类型] status[状态]
Expand All @@ -44,29 +45,67 @@

==extConfig[扩展配置]==
beforeExecute

==matrixConfig[决策矩阵配置]==
decisionMatrix
</layout>

<cells>
<!-- custom=true表示此字段不需要在meta中定义
两个下划线作为前缀表示此字段仅在前端使用,不会提交到后台
-->
<cell id="__useImportFile" custom="true" stdDomain="boolean">
</cell>

<cell id="importFile" stdDomain="file">
<visibleOn>${__useImportFile}</visibleOn>
</cell>

<cell id="ruleInputs">
<visibleOn>${!__useImportFile}</visibleOn>
<gen-control>
return { "$ref": "inputDefinition" }
</gen-control>
</cell>

<cell id="ruleOutputs">
<visibleOn>${!__useImportFile}</visibleOn>
<gen-control>
return { "$ref":"outputDefinition" }
</gen-control>
</cell>

<cell id="decisionMatrix">
<visibleOn>${ruleType == 'MATRX}</visibleOn>
</cell>
</cells>
</form>


<form id="view" x:prototype="edit">
<!-- 继承的_NopRuleDefinition模型中已经定义了layout,这里希望使用edit所对应的layout,所以要删除继承的部分。
x:prototype在x:extends执行完毕之后执行。
-->
<layout x:override="remove"/>
<form id="view" x:prototype="template">
<layout>
==baseInfo[基本信息]====
ruleName[规则名称] ruleVersion[规则版本]
displayName[显示名称] ruleGroup[规则分组]
ruleType[规则类型] status[状态]
description[描述]
remark[备注]

==authConfig[权限配置]===
!ruleRoles

==inputsConfig[输入]===
!ruleInputs

==outputsConfig[输出]===
!ruleOutputs

==extConfig[扩展配置]==
beforeExecute

==matrixConfig[决策矩阵配置]==
decisionMatrix
</layout>

<cells>
<cell id="ruleInputs">
Expand All @@ -80,6 +119,10 @@
return { "$ref": "viewOutputDefinition" }
</gen-control>
</cell>

<cell id="decisionMatrix">
<visibleOn>${ruleType == 'MATX'}</visibleOn>
</cell>
</cells>
</form>

Expand Down
2 changes: 1 addition & 1 deletion nop-ui/src/main/java/io/nop/xui/utils/XuiHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public static String getFormSelection(UiFormModel formModel, IObjMeta objMeta) {

public static Set<String> getFormProps(UiFormModel formModel, IObjMeta objMeta) {
Set<String> propNames = new LinkedHashSet<>();
if (formModel == null)
if (formModel == null || objMeta == null)
return propNames;
formModel.getTables().forEach(table -> {
table.forEachRealCell((cell, ri, ci) -> {
Expand Down
14 changes: 8 additions & 6 deletions nop-ui/src/main/java/io/nop/xui/utils/XuiViewAnalyzer.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ public class XuiViewAnalyzer {
*/
public FieldSelectionBean getListSelection(UiGridModel gridModel, IObjMeta objMeta) {
FieldSelectionBean selection = new FieldSelectionBean();
appendPkFields(selection, objMeta);
if (objMeta != null)
appendPkFields(selection, objMeta);

for (UiGridColModel colModel : gridModel.getCols()) {
String prop = colModel.getProp() == null ? colModel.getId() : colModel.getProp();
IObjPropMeta propMeta = objMeta.getProp(prop);
IObjPropMeta propMeta = objMeta == null ? null : objMeta.getProp(prop);
if (propMeta != null) {
if (!propMeta.isReadable())
continue;
Expand Down Expand Up @@ -107,10 +108,11 @@ public FieldSelectionBean getListSelection(UiGridModel gridModel, IObjMeta objMe

public FieldSelectionBean getFormSelection(UiFormModel formModel, IObjMeta objMeta) {
Guard.notNull(formModel, "formModel");
Guard.notNull(objMeta, "objMeta");
//Guard.notNull(objMeta, "objMeta");

FieldSelectionBean selection = new FieldSelectionBean();
appendPkFields(selection, objMeta);
if (objMeta != null)
appendPkFields(selection, objMeta);

if (formModel.getLayout() != null) {
for (ILayoutGroupModel group : formModel.getLayout().getGroups()) {
Expand Down Expand Up @@ -141,7 +143,7 @@ private void collectSelection(FieldSelectionBean selection, ILayoutGroupModel gr
table.forEachLayoutCell(lc -> {
UiFormCellModel cellModel = formModel.getCell(lc.getId());
String prop = cellModel == null || cellModel.getProp() == null ? lc.getId() : cellModel.getProp();
IObjPropMeta propMeta = objMeta.getProp(prop);
IObjPropMeta propMeta = objMeta == null ? null : objMeta.getProp(prop);
if (propMeta != null) {
// 不可读的数据不会进入selection
if (!propMeta.isReadable())
Expand Down Expand Up @@ -304,7 +306,7 @@ static void addDepend(Set<String> depends, IObjMeta objMeta, Consumer<String> ac
continue;

String prop = StringHelper.firstPart(depend, '.');
if (objMeta.getProp(prop) == null) {
if (objMeta != null && objMeta.getProp(prop) == null) {
onMissing.accept(depend);
} else {
action.accept(depend);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
let objMeta = SchemaLoader.loadXMeta(viewModel.objMeta);
let controlLib = XplLibHelper.loadLib(viewModel.controlLib || '/nop/web/xlib/control.xlib');
let bizObjName = viewModel.bizObjName;
let i18nRoot = objMeta['i18n:root'] || bizObjName;
let i18nRoot = objMeta?.['i18n:root'] || bizObjName;
</c:script>

<c:choose>
Expand Down
7 changes: 5 additions & 2 deletions nop-xlang/src/main/java/io/nop/xlang/xmeta/SchemaLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/
package io.nop.xlang.xmeta;

import io.nop.api.core.util.Guard;
import io.nop.commons.util.StringHelper;
import io.nop.core.lang.xml.XNode;
import io.nop.core.resource.component.ResourceComponentManager;
import io.nop.xlang.XLangConstants;
Expand All @@ -19,13 +19,16 @@
public class SchemaLoader {

public static IObjMeta loadXMeta(String path) {
Guard.notEmpty(path, "metaPath");
if (StringHelper.isEmpty(path))
return null;
IObjMeta meta = (IObjMeta) ResourceComponentManager.instance().loadComponentModel(path,
XLangConstants.MODEL_TYPE_XMETA);
return meta;
}

public static IXDefinition loadXDefinition(String path) {
if(StringHelper.isEmpty(path))
return null;
IXDefinition xdef = (IXDefinition) ResourceComponentManager.instance().loadComponentModel(path,
XLangConstants.MODEL_TYPE_XDEF);
return xdef;
Expand Down

0 comments on commit 3d93df3

Please sign in to comment.