发布 v1.10 #5
@@ -118,12 +118,29 @@ public class WorkflowRunningParameterResolver {
|
||||
private Map<String, Object> resolveStartFormMeta(JSONObject startNodeData) {
|
||||
JSONObject rawMeta = startNodeData == null ? null : startNodeData.getJSONObject("startFormMeta");
|
||||
Map<String, Object> meta = new LinkedHashMap<>();
|
||||
meta.put("title", trimToDefault(rawMeta == null ? null : rawMeta.getString("title"), DEFAULT_START_FORM_TITLE));
|
||||
meta.put("description", trimToDefault(rawMeta == null ? null : rawMeta.getString("description"), DEFAULT_START_FORM_DESCRIPTION));
|
||||
// Missing values use defaults; an explicit empty string means the user cleared the field.
|
||||
meta.put("title", resolveOptionalStartFormText(rawMeta, "title", DEFAULT_START_FORM_TITLE));
|
||||
meta.put("description", resolveOptionalStartFormText(rawMeta, "description", DEFAULT_START_FORM_DESCRIPTION));
|
||||
meta.put("submitText", trimToDefault(rawMeta == null ? null : rawMeta.getString("submitText"), DEFAULT_START_FORM_SUBMIT_TEXT));
|
||||
return meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析允许用户主动清空的开始表单文案。
|
||||
*
|
||||
* @param meta 开始节点表单元数据
|
||||
* @param key 文案字段名
|
||||
* @param fallback 字段缺失时的默认文案
|
||||
* @return 配置文案;字段缺失时返回默认文案,显式空字符串保持为空
|
||||
*/
|
||||
private String resolveOptionalStartFormText(JSONObject meta, String key, String fallback) {
|
||||
if (meta == null || !meta.containsKey(key)) {
|
||||
return fallback;
|
||||
}
|
||||
String value = meta.getString(key);
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
|
||||
private List<Map<String, Object>> resolveStartFormSchema(JSONObject startNodeData, List<Parameter> parameters) {
|
||||
JSONArray rawSchema = startNodeData == null ? null : startNodeData.getJSONArray("startFormSchema");
|
||||
List<Map<String, Object>> schema = new ArrayList<>();
|
||||
|
||||
@@ -38,11 +38,14 @@ const submitLoading = ref(false);
|
||||
const startFormMeta = computed(() => {
|
||||
const meta = props.workflowParams?.startFormMeta || {};
|
||||
return {
|
||||
title: String(meta.title || '').trim() || props.workflowParams?.title || '',
|
||||
title:
|
||||
meta.title == null
|
||||
? props.workflowParams?.title || ''
|
||||
: String(meta.title).trim(),
|
||||
description:
|
||||
String(meta.description || '').trim() ||
|
||||
props.workflowParams?.description ||
|
||||
'',
|
||||
meta.description == null
|
||||
? props.workflowParams?.description || ''
|
||||
: String(meta.description).trim(),
|
||||
submitText: String(meta.submitText || '').trim() || $t('button.run'),
|
||||
};
|
||||
});
|
||||
|
||||
@@ -855,8 +855,8 @@ describe('workflow node fields', () => {
|
||||
systemReserved: true,
|
||||
});
|
||||
expect(normalized.startFormMeta).toMatchObject({
|
||||
title: '开始问答',
|
||||
description: '请先补充必要信息,再开始执行工作流。',
|
||||
title: '',
|
||||
description: '',
|
||||
submitText: '开始',
|
||||
});
|
||||
expect(normalized.parameters[0]).toMatchObject({
|
||||
|
||||
@@ -439,8 +439,9 @@ function createDefaultStartFormMeta(): StartFormMeta {
|
||||
export function normalizeStartFormMeta(meta?: Partial<StartFormMeta> | null): StartFormMeta {
|
||||
const fallback = createDefaultStartFormMeta();
|
||||
return {
|
||||
title: trimString(meta?.title) || fallback.title,
|
||||
description: trimString(meta?.description) || fallback.description,
|
||||
// Missing values use defaults; an explicit empty string means the user cleared the field.
|
||||
title: meta?.title == null ? fallback.title : trimString(meta.title),
|
||||
description: meta?.description == null ? fallback.description : trimString(meta.description),
|
||||
submitText: trimString(meta?.submitText) || fallback.submitText,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -37,11 +37,14 @@ const submitLoading = ref(false);
|
||||
const startFormMeta = computed(() => {
|
||||
const meta = props.workflowParams?.startFormMeta || {};
|
||||
return {
|
||||
title: String(meta.title || '').trim() || props.workflowParams?.title || '',
|
||||
title:
|
||||
meta.title == null
|
||||
? props.workflowParams?.title || ''
|
||||
: String(meta.title).trim(),
|
||||
description:
|
||||
String(meta.description || '').trim() ||
|
||||
props.workflowParams?.description ||
|
||||
'',
|
||||
meta.description == null
|
||||
? props.workflowParams?.description || ''
|
||||
: String(meta.description).trim(),
|
||||
submitText: String(meta.submitText || '').trim() || $t('button.run'),
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user