From b9c31c3bdfe5607f96c1d0b07365b3b2b72e9f58 Mon Sep 17 00:00:00 2001 From: ukrbublik Date: Mon, 8 May 2023 19:44:08 +0300 Subject: [PATCH] wip #912 todo --- packages/core/modules/export/queryString.js | 11 ++++++----- packages/core/modules/index.d.ts | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/core/modules/export/queryString.js b/packages/core/modules/export/queryString.js index 8e34ec91d..df1c1481c 100644 --- a/packages/core/modules/export/queryString.js +++ b/packages/core/modules/export/queryString.js @@ -49,7 +49,7 @@ const formatGroup = (item, config, meta, isForDisplay = false, parentField = nul const isRuleGroup = (type === "rule_group"); // TIP: don't cut group for mode == 'struct' and don't do aggr format (maybe later) - const groupField = isRuleGroup && mode == "array" ? properties.get("field") : null; + const groupField = isRuleGroup && mode != "struct" ? properties.get("field") : null; const canHaveEmptyChildren = isRuleGroup && mode == "array"; const not = properties.get("not"); const list = children @@ -63,7 +63,7 @@ const formatGroup = (item, config, meta, isForDisplay = false, parentField = nul conjunction = defaultConjunction(config); const conjunctionDefinition = config.conjunctions[conjunction]; - const conjStr = list.size ? conjunctionDefinition.formatConj(list, conjunction, not, isForDisplay) : null; + const conjStr = list.size ? conjunctionDefinition.formatConj(list, conjunction, not, isForDisplay, groupField) : null; let ret; if (groupField) { @@ -192,8 +192,6 @@ const formatRule = (item, config, meta, isForDisplay = false, parentField = null const [formattedValue, valueSrc, valueType] = formatItemValue( config, properties, meta, operator, isForDisplay, parentField ); - if (formattedValue === undefined) - return undefined; const args = [ formattedField, @@ -211,6 +209,9 @@ const formatRule = (item, config, meta, isForDisplay = false, parentField = null if (returnArgs) { return args; } else { + if (formattedValue === undefined) + return undefined; + //format expr let ret = fn.call(config.ctx, ...args); @@ -274,7 +275,7 @@ const formatField = (config, meta, field, isForDisplay, parentField = null, cutP const fieldLabel2 = fieldDefinition.label2 || fieldFullLabel; const formatFieldFn = config.settings.formatField; const fieldName = formatFieldName(field, config, meta, cutParentField ? parentField : null, {useTableName: true}); - ret = formatFieldFn(fieldName, fieldParts, fieldLabel2, fieldDefinition, config, isForDisplay); + ret = formatFieldFn(fieldName, fieldParts, fieldLabel2, fieldDefinition, config, isForDisplay, parentField); } return ret; }; diff --git a/packages/core/modules/index.d.ts b/packages/core/modules/index.d.ts index 091b7ed89..50a2c427b 100644 --- a/packages/core/modules/index.d.ts +++ b/packages/core/modules/index.d.ts @@ -534,7 +534,7 @@ export type Widgets = TypedMap>; // Conjunctions ///////////////// -type FormatConj = (children: ImmutableList, conj: string, not: boolean, isForDisplay?: boolean) => string; +type FormatConj = (children: ImmutableList, conj: string, not: boolean, isForDisplay?: boolean, groupField?: string) => string; type SqlFormatConj = (children: ImmutableList, conj: string, not: boolean) => string; type SpelFormatConj = (children: ImmutableList, conj: string, not: boolean, omitBrackets?: boolean) => string; @@ -841,7 +841,7 @@ type ChangeFieldStrategy = "default" | "keep" | "first" | "none"; type FormatReverse = (q: string, op: string, reversedOp: string, operatorDefinition: Operator, revOperatorDefinition: Operator, isForDisplay: boolean) => string; type SqlFormatReverse = (q: string) => string; type SpelFormatReverse = (q: string) => string; -type FormatField = (field: string, parts: Array, label2: string, fieldDefinition: Field, config: Config, isForDisplay: boolean) => string; +type FormatField = (field: string, parts: Array, label2: string, fieldDefinition: Field, config: Config, isForDisplay: boolean, parentField?: string) => string; type FormatSpelField = (field: string, parentField: string | null, parts: Array, partsExt: Array, fieldDefinition: Field, config: Config) => string; type CanCompareFieldWithField = (leftField: string, leftFieldConfig: Field, rightField: string, rightFieldConfig: Field, op: string) => boolean; type FormatAggr = (whereStr: string, aggrField: string, operator: string, value: string | ImmutableList, valueSrc: ValueSource, valueType: string, opDef: Operator, operatorOptions: AnyObject, isForDisplay: boolean, aggrFieldDef: Field) => string;