@masterteam/form-builder 0.0.46 → 0.0.47
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.
|
@@ -28,7 +28,7 @@ import { CrudStateBase, handleApiRequest, RadioCardsFieldConfig, ValidatorConfig
|
|
|
28
28
|
import { DynamicForm } from '@masterteam/forms/dynamic-form';
|
|
29
29
|
import { ToggleField } from '@masterteam/components/toggle-field';
|
|
30
30
|
import { ModalRef } from '@masterteam/components/dialog';
|
|
31
|
-
import { CONDITION_FUNCTION_CATEGORIES, CONDITION_OPERATORS, FormulaToolbar, FormulaEditor, serializeTokens, tokenizeFormulaTemplate } from '@masterteam/components/formula';
|
|
31
|
+
import { CONDITION_FUNCTION_CATEGORIES, CONDITION_OPERATORS, FormulaToolbar, FormulaEditor, serializeTokens, tokenizeFormulaTemplate, serializeTokensForDisplay } from '@masterteam/components/formula';
|
|
32
32
|
import { Tooltip } from '@masterteam/components/tooltip';
|
|
33
33
|
import { ClientForm } from '@masterteam/forms/client-form';
|
|
34
34
|
import { Table } from '@masterteam/components/table';
|
|
@@ -2161,7 +2161,12 @@ class FBValidationRuleForm {
|
|
|
2161
2161
|
this.messageArControl.setValue(data.message?.ar ?? '');
|
|
2162
2162
|
this.severityControl.setValue(data.severity ?? 'error');
|
|
2163
2163
|
const builder = this.parseStoredFormulaTokens(data.formulaTokens);
|
|
2164
|
-
|
|
2164
|
+
// `formulaTokens` is the canonical formula payload; `formulaText` is only a
|
|
2165
|
+
// human-readable preview (it may hold a friendly description, e.g.
|
|
2166
|
+
// "Finish Date must be on or after Start Date", not a valid expression).
|
|
2167
|
+
// Hydrate the editor from the tokens so the validator receives the real
|
|
2168
|
+
// formula — fall back to `formulaText` only when no tokens are stored.
|
|
2169
|
+
const expression = serializeTokens(builder) || data.formulaText?.trim() || '';
|
|
2165
2170
|
this.formulaControl.setValue({
|
|
2166
2171
|
expression,
|
|
2167
2172
|
builder,
|
|
@@ -2233,13 +2238,17 @@ class FBValidationRuleForm {
|
|
|
2233
2238
|
if (builder.length === 0 && expression) {
|
|
2234
2239
|
builder = tokenizeFormulaTemplate(expression);
|
|
2235
2240
|
}
|
|
2236
|
-
|
|
2237
|
-
|
|
2241
|
+
// The back-end stores/compiles `formulaTokens` as the executable EXPRESSION
|
|
2242
|
+
// string — a JSON token array is rejected with 400 VAL_001. `formulaText` is
|
|
2243
|
+
// only a human-readable preview, so emit the friendly display-name
|
|
2244
|
+
// serialization (falling back to the raw expression).
|
|
2245
|
+
const formulaExpression = expression || serializeTokens(builder);
|
|
2246
|
+
if (!formulaExpression || builder.length === 0) {
|
|
2238
2247
|
return null;
|
|
2239
2248
|
}
|
|
2240
2249
|
return {
|
|
2241
|
-
formulaTokens:
|
|
2242
|
-
formulaText,
|
|
2250
|
+
formulaTokens: formulaExpression,
|
|
2251
|
+
formulaText: serializeTokensForDisplay(builder) || formulaExpression,
|
|
2243
2252
|
};
|
|
2244
2253
|
}
|
|
2245
2254
|
handleSaveError(error) {
|