feat: complete framework P2 deltas
This commit is contained in:
@@ -117,15 +117,21 @@ public final class EngineclassDelta {
|
||||
EngineclassDelta::dataImportSaveScriptButton,
|
||||
EngineclassDelta::dataImportTemplateDownloadButton,
|
||||
EngineclassDelta::dataImportBaseDataDownloadButton);
|
||||
register("com.dsasp.client.dataimport.view.DataExcelImportView",
|
||||
EngineclassDelta::dataImportExecuteButton);
|
||||
|
||||
// 功能/视图管理与自定义列表:先补高级配置 XML 源码编辑入口;可视化设计器另走独立路由。
|
||||
// 功能/视图管理与自定义列表:补高级配置 XML 源码编辑入口,并接入现有 amis-editor 设计器。
|
||||
register("com.dsasp.client.viewframework.component.UserFunDesignComponent",
|
||||
EngineclassDelta::viewTemplateDesignButton,
|
||||
EngineclassDelta::viewTemplateXmlButton);
|
||||
register("com.dsasp.client.viewframework.component.UserPageDesignComponent",
|
||||
EngineclassDelta::viewPageDesignButton,
|
||||
EngineclassDelta::viewPageXmlButton);
|
||||
register("com.dsasp.client.viewframework.component.UserFunDesignCustomComponent",
|
||||
EngineclassDelta::viewTemplateCustomDesignButton,
|
||||
EngineclassDelta::viewTemplateCustomXmlButton);
|
||||
register("com.dsasp.client.viewframework.component.UserPageDesignCustomComponent",
|
||||
EngineclassDelta::viewPageCustomDesignButton,
|
||||
EngineclassDelta::viewPageCustomXmlButton);
|
||||
|
||||
// 消息查看:MessageReceiveView/MessageSendView 在默认 GridTemplateComponent 之上加「查看」按钮。
|
||||
@@ -591,6 +597,22 @@ public final class EngineclassDelta {
|
||||
return downloadButton("下载基础数据", "fa fa-download", "/api/dataimport/basedata");
|
||||
}
|
||||
|
||||
private static Map<String, Object> dataImportExecuteButton(String pkField) {
|
||||
Map<String, Object> btn = new LinkedHashMap<>();
|
||||
btn.put("type", "button");
|
||||
btn.put("id", "执行");
|
||||
btn.put("label", "执行");
|
||||
btn.put("icon", "fa fa-play");
|
||||
btn.put("level", "primary");
|
||||
btn.put("disabledOn", "${!selectedItems || selectedItems.length !== 1}");
|
||||
btn.put("confirmText", "确认执行选中的数据导入文件?");
|
||||
btn.put("actionType", "ajax");
|
||||
btn.put("api", mapOf(
|
||||
"method", "post",
|
||||
"url", "/api/dataimport/execute?fileId=" + selectedSingleFieldExpr(pkField)));
|
||||
return btn;
|
||||
}
|
||||
|
||||
private static Map<String, Object> scheduleJobNotifyButton(String pkField) {
|
||||
String idExpr = selectedSingleFieldExpr(pkField);
|
||||
Map<String, Object> form = mapOf(
|
||||
@@ -742,21 +764,52 @@ public final class EngineclassDelta {
|
||||
"VIEW_TEMPLATE", "VIEW_TEMPLATE_ID", pkField, "XML", "xml");
|
||||
}
|
||||
|
||||
private static Map<String, Object> viewTemplateDesignButton(String pkField) {
|
||||
return designerButton("编辑模板", "fa fa-magic",
|
||||
selectedSingleFieldExpr(pkField == null || pkField.isBlank() ? "VIEW_TEMPLATE_ID" : pkField));
|
||||
}
|
||||
|
||||
private static Map<String, Object> viewPageXmlButton(String pkField) {
|
||||
return fieldEditorButton("高级配置", "fa fa-code",
|
||||
"VIEW_PAGE", "VIEW_PAGE_ID", pkField, "XML", "xml");
|
||||
}
|
||||
|
||||
private static Map<String, Object> viewPageDesignButton(String pkField) {
|
||||
return designerButton("编辑页面", "fa fa-magic",
|
||||
selectedSingleFieldExpr(pkField == null || pkField.isBlank() ? "VIEW_PAGE_ID" : pkField));
|
||||
}
|
||||
|
||||
private static Map<String, Object> viewTemplateCustomXmlButton(String pkField) {
|
||||
return fieldEditorButton("高级配置", "fa fa-code",
|
||||
"VIEW_TEMPLATE_CUSTOM", "VIEW_TEMPLATE_CUSTOM_ID", pkField, "XML", "xml");
|
||||
}
|
||||
|
||||
private static Map<String, Object> viewTemplateCustomDesignButton(String pkField) {
|
||||
return designerButton("编辑模板", "fa fa-magic", "${selectedItems[0].TEMPLATEID}");
|
||||
}
|
||||
|
||||
private static Map<String, Object> viewPageCustomXmlButton(String pkField) {
|
||||
return fieldEditorButton("高级配置", "fa fa-code",
|
||||
"VIEW_PAGE_CUSTOM", "VIEW_PAGE_CUSTOM_ID", pkField, "XML", "xml");
|
||||
}
|
||||
|
||||
private static Map<String, Object> viewPageCustomDesignButton(String pkField) {
|
||||
return designerButton("编辑页面", "fa fa-magic", "${selectedItems[0].PAGEID}");
|
||||
}
|
||||
|
||||
private static Map<String, Object> designerButton(String label, String icon, String templateIdExpr) {
|
||||
Map<String, Object> btn = new LinkedHashMap<>();
|
||||
btn.put("type", "button");
|
||||
btn.put("id", label);
|
||||
btn.put("label", label);
|
||||
btn.put("icon", icon);
|
||||
btn.put("disabledOn", "${!selectedItems || selectedItems.length !== 1}");
|
||||
btn.put("actionType", "url");
|
||||
btn.put("url", "/editor.html?templateId=" + templateIdExpr);
|
||||
btn.put("blank", true);
|
||||
return btn;
|
||||
}
|
||||
|
||||
private static Map<String, Object> fieldEditorButton(String label, String icon, String tableName,
|
||||
String idField, String pkField,
|
||||
String fieldName, String language) {
|
||||
|
||||
@@ -48,6 +48,16 @@ class TemplateToAmisConverterTest {
|
||||
return (Map<String, Object>) page.get("body");
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Map<String, Object> findToolbarButton(Map<String, Object> crud, String label) {
|
||||
List<Object> toolbar = (List<Object>) crud.get("headerToolbar");
|
||||
return toolbar.stream()
|
||||
.filter(o -> o instanceof Map && label.equals(((Map<String, Object>) o).get("label")))
|
||||
.map(o -> (Map<String, Object>) o)
|
||||
.findFirst()
|
||||
.orElseThrow();
|
||||
}
|
||||
|
||||
/** form.body 现为显式行布局(group 行 + 宽控件行),展平回字段序列供字段级断言用。 */
|
||||
@SuppressWarnings("unchecked")
|
||||
private static List<Map<String, Object>> flattenFormBody(Map<String, Object> form) {
|
||||
@@ -1221,6 +1231,65 @@ class TemplateToAmisConverterTest {
|
||||
assertEquals("/api/dataimport/template?configId=${selectedItems[0].PM_DEMO_ID}", api.get("url"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void engineclass_DataExcelImportView_注入执行按钮() {
|
||||
String xml = "<crud entityid='e1'><display/></crud>";
|
||||
ConversionResult r = converter.convertGraded(xml, null,
|
||||
"com.dsasp.client.dataimport.view.DataExcelImportView",
|
||||
"数据导入文件管理", new ArrayList<>(), noPage);
|
||||
Map<String, Object> crud = body(r.getSchema());
|
||||
List<Object> toolbar = (List<Object>) crud.get("headerToolbar");
|
||||
Map<String, Object> execute = toolbar.stream()
|
||||
.filter(o -> o instanceof Map && "执行".equals(((Map<String, Object>) o).get("label")))
|
||||
.map(o -> (Map<String, Object>) o).findFirst().orElseThrow();
|
||||
|
||||
assertEquals("ajax", execute.get("actionType"));
|
||||
assertEquals("${!selectedItems || selectedItems.length !== 1}", execute.get("disabledOn"));
|
||||
Map<String, Object> api = (Map<String, Object>) execute.get("api");
|
||||
assertEquals("post", api.get("method"));
|
||||
assertEquals("/api/dataimport/execute?fileId=${selectedItems[0].PM_DEMO_ID}", api.get("url"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void engineclass_功能和视图管理注入设计器入口() {
|
||||
String xml = "<crud entityid='e1'><display/></crud>";
|
||||
|
||||
ConversionResult fun = converter.convertGraded(xml, null,
|
||||
"com.dsasp.client.viewframework.component.UserFunDesignComponent",
|
||||
"功能管理", new ArrayList<>(), noPage);
|
||||
Map<String, Object> funButton = findToolbarButton(body(fun.getSchema()), "编辑模板");
|
||||
assertEquals("url", funButton.get("actionType"));
|
||||
assertEquals("/editor.html?templateId=${selectedItems[0].PM_DEMO_ID}", funButton.get("url"));
|
||||
assertEquals(true, funButton.get("blank"));
|
||||
|
||||
ConversionResult page = converter.convertGraded(xml, null,
|
||||
"com.dsasp.client.viewframework.component.UserPageDesignComponent",
|
||||
"视图管理", new ArrayList<>(), noPage);
|
||||
Map<String, Object> pageButton = findToolbarButton(body(page.getSchema()), "编辑页面");
|
||||
assertEquals("url", pageButton.get("actionType"));
|
||||
assertEquals("/editor.html?templateId=${selectedItems[0].PM_DEMO_ID}", pageButton.get("url"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void engineclass_功能和视图自定义列表设计器入口使用底层模板和页面Id() {
|
||||
String xml = "<crud entityid='e1'><display/></crud>";
|
||||
|
||||
ConversionResult customFun = converter.convertGraded(xml, null,
|
||||
"com.dsasp.client.viewframework.component.UserFunDesignCustomComponent",
|
||||
"功能编辑列表-自定义", new ArrayList<>(), noPage);
|
||||
Map<String, Object> customFunButton = findToolbarButton(body(customFun.getSchema()), "编辑模板");
|
||||
assertEquals("/editor.html?templateId=${selectedItems[0].TEMPLATEID}", customFunButton.get("url"));
|
||||
|
||||
ConversionResult customPage = converter.convertGraded(xml, null,
|
||||
"com.dsasp.client.viewframework.component.UserPageDesignCustomComponent",
|
||||
"视图编辑列表-自定义", new ArrayList<>(), noPage);
|
||||
Map<String, Object> customPageButton = findToolbarButton(body(customPage.getSchema()), "编辑页面");
|
||||
assertEquals("/editor.html?templateId=${selectedItems[0].PAGEID}", customPageButton.get("url"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
void engineclass_ScheduleJobSettingComponent_注入设置提醒人规则编辑器() {
|
||||
|
||||
Reference in New Issue
Block a user