fix: 修复工作流开始表单文案清空回退
- 保留标题和说明的显式空值 - 同步运行页与后端解析逻辑
This commit is contained in:
@@ -118,12 +118,29 @@ public class WorkflowRunningParameterResolver {
|
|||||||
private Map<String, Object> resolveStartFormMeta(JSONObject startNodeData) {
|
private Map<String, Object> resolveStartFormMeta(JSONObject startNodeData) {
|
||||||
JSONObject rawMeta = startNodeData == null ? null : startNodeData.getJSONObject("startFormMeta");
|
JSONObject rawMeta = startNodeData == null ? null : startNodeData.getJSONObject("startFormMeta");
|
||||||
Map<String, Object> meta = new LinkedHashMap<>();
|
Map<String, Object> meta = new LinkedHashMap<>();
|
||||||
meta.put("title", trimToDefault(rawMeta == null ? null : rawMeta.getString("title"), DEFAULT_START_FORM_TITLE));
|
// Missing values use defaults; an explicit empty string means the user cleared the field.
|
||||||
meta.put("description", trimToDefault(rawMeta == null ? null : rawMeta.getString("description"), DEFAULT_START_FORM_DESCRIPTION));
|
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));
|
meta.put("submitText", trimToDefault(rawMeta == null ? null : rawMeta.getString("submitText"), DEFAULT_START_FORM_SUBMIT_TEXT));
|
||||||
return meta;
|
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) {
|
private List<Map<String, Object>> resolveStartFormSchema(JSONObject startNodeData, List<Parameter> parameters) {
|
||||||
JSONArray rawSchema = startNodeData == null ? null : startNodeData.getJSONArray("startFormSchema");
|
JSONArray rawSchema = startNodeData == null ? null : startNodeData.getJSONArray("startFormSchema");
|
||||||
List<Map<String, Object>> schema = new ArrayList<>();
|
List<Map<String, Object>> schema = new ArrayList<>();
|
||||||
|
|||||||
@@ -38,11 +38,14 @@ const submitLoading = ref(false);
|
|||||||
const startFormMeta = computed(() => {
|
const startFormMeta = computed(() => {
|
||||||
const meta = props.workflowParams?.startFormMeta || {};
|
const meta = props.workflowParams?.startFormMeta || {};
|
||||||
return {
|
return {
|
||||||
title: String(meta.title || '').trim() || props.workflowParams?.title || '',
|
title:
|
||||||
|
meta.title == null
|
||||||
|
? props.workflowParams?.title || ''
|
||||||
|
: String(meta.title).trim(),
|
||||||
description:
|
description:
|
||||||
String(meta.description || '').trim() ||
|
meta.description == null
|
||||||
props.workflowParams?.description ||
|
? props.workflowParams?.description || ''
|
||||||
'',
|
: String(meta.description).trim(),
|
||||||
submitText: String(meta.submitText || '').trim() || $t('button.run'),
|
submitText: String(meta.submitText || '').trim() || $t('button.run'),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -855,8 +855,8 @@ describe('workflow node fields', () => {
|
|||||||
systemReserved: true,
|
systemReserved: true,
|
||||||
});
|
});
|
||||||
expect(normalized.startFormMeta).toMatchObject({
|
expect(normalized.startFormMeta).toMatchObject({
|
||||||
title: '开始问答',
|
title: '',
|
||||||
description: '请先补充必要信息,再开始执行工作流。',
|
description: '',
|
||||||
submitText: '开始',
|
submitText: '开始',
|
||||||
});
|
});
|
||||||
expect(normalized.parameters[0]).toMatchObject({
|
expect(normalized.parameters[0]).toMatchObject({
|
||||||
|
|||||||
@@ -439,8 +439,9 @@ function createDefaultStartFormMeta(): StartFormMeta {
|
|||||||
export function normalizeStartFormMeta(meta?: Partial<StartFormMeta> | null): StartFormMeta {
|
export function normalizeStartFormMeta(meta?: Partial<StartFormMeta> | null): StartFormMeta {
|
||||||
const fallback = createDefaultStartFormMeta();
|
const fallback = createDefaultStartFormMeta();
|
||||||
return {
|
return {
|
||||||
title: trimString(meta?.title) || fallback.title,
|
// Missing values use defaults; an explicit empty string means the user cleared the field.
|
||||||
description: trimString(meta?.description) || fallback.description,
|
title: meta?.title == null ? fallback.title : trimString(meta.title),
|
||||||
|
description: meta?.description == null ? fallback.description : trimString(meta.description),
|
||||||
submitText: trimString(meta?.submitText) || fallback.submitText,
|
submitText: trimString(meta?.submitText) || fallback.submitText,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,14 @@ const submitLoading = ref(false);
|
|||||||
const startFormMeta = computed(() => {
|
const startFormMeta = computed(() => {
|
||||||
const meta = props.workflowParams?.startFormMeta || {};
|
const meta = props.workflowParams?.startFormMeta || {};
|
||||||
return {
|
return {
|
||||||
title: String(meta.title || '').trim() || props.workflowParams?.title || '',
|
title:
|
||||||
|
meta.title == null
|
||||||
|
? props.workflowParams?.title || ''
|
||||||
|
: String(meta.title).trim(),
|
||||||
description:
|
description:
|
||||||
String(meta.description || '').trim() ||
|
meta.description == null
|
||||||
props.workflowParams?.description ||
|
? props.workflowParams?.description || ''
|
||||||
'',
|
: String(meta.description).trim(),
|
||||||
submitText: String(meta.submitText || '').trim() || $t('button.run'),
|
submitText: String(meta.submitText || '').trim() || $t('button.run'),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user