Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify export to query string to fit Expr language #913

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions packages/core/modules/export/queryString.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

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 === "array" ? properties.get("field") : null;
const groupOperator = type === "rule_group" ? properties.get("operator") : null;
const groupOperatorCardinality = groupOperator ? config.operators[groupOperator]?.cardinality ?? 1 : undefined;
const canHaveEmptyChildren = isRuleGroup && mode === "array" && groupOperatorCardinality >= 1;
Expand All @@ -71,7 +71,7 @@
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) {
Expand Down Expand Up @@ -245,6 +245,9 @@
if (returnArgs) {
return args;
} else {
if (formattedValue === undefined)
return undefined;

Check warning on line 249 in packages/core/modules/export/queryString.js

View check run for this annotation

Codecov / codecov/patch

packages/core/modules/export/queryString.js#L249

Added line #L249 was not covered by tests

//format expr
let ret = fn.call(config.ctx, ...args);

Expand Down Expand Up @@ -317,7 +320,7 @@
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);
} else if(isDebugMode) {
ret = "?";
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/modules/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ export type Widgets<C = Config> = TypedMap<Widget<C>>;
// Conjunctions
/////////////////

type FormatConj = (children: ImmutableList<string>, conj: string, not: boolean, isForDisplay?: boolean) => string;
type FormatConj = (children: ImmutableList<string>, conj: string, not: boolean, isForDisplay?: boolean, groupField?: string) => string;
type SqlFormatConj = (children: ImmutableList<string>, conj: string, not: boolean) => string;
type SpelFormatConj = (children: ImmutableList<string>, conj: string, not: boolean, omitBrackets?: boolean) => string;

Expand Down Expand Up @@ -1240,7 +1240,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: FieldPath, parts: Array<string>, label2: string, fieldDefinition: Field, config: Config, isForDisplay: boolean) => string;
type FormatField = (field: FieldPath, parts: Array<string>, label2: string, fieldDefinition: Field, config: Config, isForDisplay: boolean, parentField?: string) => string;
type FormatSpelField = (field: FieldPath, parentField: FieldPath | null, parts: Array<string>, partsExt: Array<SpelFieldMeta>, fieldDefinition: Field, config: Config) => string;
type CanCompareFieldWithField = (leftField: FieldPath, leftFieldConfig: Field, rightField: FieldPath, rightFieldConfig: Field, op: string) => boolean;
type FormatAggr = (whereStr: string, aggrField: FieldPath, operator: string, value: string | ImmutableList<string>, valueSrc: ValueSource, valueType: string, opDef: Operator, operatorOptions: OperatorOptionsI, isForDisplay: boolean, aggrFieldDef: Field) => string;
Expand Down