Skip to content

[WC-3441] DG2: export column enhancements#2287

Open
yordan-st wants to merge 2 commits into
mainfrom
feat/WC-3441_DG2-export-column-enhancements
Open

[WC-3441] DG2: export column enhancements#2287
yordan-st wants to merge 2 commits into
mainfrom
feat/WC-3441_DG2-export-column-enhancements

Conversation

@yordan-st

@yordan-st yordan-st commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Pull request type

Bug fix (non-breaking change which fixes an issue)


Description

When export type is set to "Default" for attribute columns, the exported Excel cells now use the attribute's own formatter (number precision, date pattern) instead of exporting raw values without formatting.

Also hides the export type and format properties in Studio Pro for dynamic text columns, since they have no effect.

What should be covered while testing?

  1. Attribute column with exportType "Default" and a Decimal attribute configured with 2 decimal places → exported cell should have format #,##0.00
  2. Attribute column with exportType "Default" and a DateTime attribute with custom pattern dd/MM/yyyy → exported cell should have Excel format dd/mm/yyyy
  3. Attribute column with exportType "Number" or "Date" (custom) → still uses the manually specified export format (unchanged behavior)
  4. Dynamic text column → Studio Pro should NOT show export type, export number format, or export date format properties
  5. Custom content columns → unchanged behavior, all export types still work
  6. Existing configurations with no changes → no regression, everything exports as before

@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from 6696f2e to 39c37d2 Compare June 22, 2026 16:01
@yordan-st yordan-st marked this pull request as ready for review June 22, 2026 16:11
@yordan-st yordan-st requested a review from a team as a code owner June 22, 2026 16:11
@github-actions

This comment has been minimized.

@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from 39c37d2 to 96a5c83 Compare June 23, 2026 12:10
@github-actions

This comment has been minimized.

iobuhov
iobuhov previously approved these changes Jun 23, 2026
@yordan-st yordan-st force-pushed the feat/WC-3441_DG2-export-column-enhancements branch from c94f30c to adc9e02 Compare June 24, 2026 12:51
@github-actions

Copy link
Copy Markdown
Contributor

AI Code Review

⚠️ Approved with suggestions — low-severity items only, safe to merge


What was reviewed

File Change
packages/pluggableWidgets/datagrid-web/CHANGELOG.md Added [Unreleased] entries for new feature and fix
packages/pluggableWidgets/datagrid-web/src/Datagrid.editorConfig.ts Hide export properties in Studio Pro for dynamicText columns
packages/pluggableWidgets/datagrid-web/src/features/data-export/cell-readers.ts New getAttributeDefaultFormat() function; branch attribute reader on exportType === "default"
packages/pluggableWidgets/datagrid-web/src/features/data-export/__tests__/cell-readers.spec.ts 4 new unit tests for the default format path
packages/pluggableWidgets/datagrid-web/openspec/*.{yaml,md} OpenSpec design/proposal/tasks documents (non-runtime)

Skipped (out of scope): dist/, pnpm-lock.yaml


Findings

⚠️ Low — M→m replacement is too broad for compound datetime patterns

File: packages/pluggableWidgets/datagrid-web/src/features/data-export/cell-readers.ts line 124
Note: The regex /M/g replaces every capital M in the pattern, which is correct for month tokens (MM, MMM, MMMM). However, some Mendix patterns include locale tags like [$-en-US] that could also contain an uppercase M. The existing hasTimeComponent already demonstrates the pattern of stripping locale tags first (line 98). This is an edge case but worth noting for future patterns:

// Safer approach mirrors hasTimeComponent:
const sanitized = cfg.pattern.replace(/\[.*?\]/g, "");
return sanitized.replace(/M/g, "m");

⚠️ Low — Missing test: exportType = "default" with no formatter on attribute falls through gracefully

File: packages/pluggableWidgets/datagrid-web/src/features/data-export/__tests__/cell-readers.spec.ts
Note: There is no test covering the case where exportType === "default" and the attribute has no formatter property (i.e., formatter is undefined). This is the most common real-world state (Mendix 9 runtimes or attributes not yet configured). The code handles it correctly via the early if (!formatter) return undefined guard, but a test would document and protect this contract:

it("returns locale default format when attribute has no formatter and exportType is default", () => {
    const attr = listAttribute(() => new Date("2024-06-15T00:00:00Z")) as any;
    // no attr.formatter assignment
    const col = column("Created", c => {
        c.showContentAs = "attribute";
        c.attribute = attr;
        c.exportType = "default";
    });
    const cell = readSingleCell(col);
    expect(cell.t).toBe("d");
    expect(cell.z).toBe("dd-mm-yyyy"); // locale fallback
});

Positives

  • getAttributeDefaultFormat is well-scoped and isolated — it only reads from props.attribute.formatter and returns a plain string, making it easy to test and reason about independently.
  • The as any casts in the test file are confined to the test setup layer (mutating the mock) and don't leak into production types — correct pattern for extending test mocks without polluting typings.
  • The editorConfig change correctly uses hideNestedPropertiesIn (batch hide) rather than three separate hidePropertyIn calls, consistent with the pattern already used elsewhere in the same function (line 30).
  • CHANGELOG entries follow Keep a Changelog format with user-facing language (no implementation details).
  • Test structure uses the existing column / readSingleCell helpers rather than duplicating boilerplate — consistent with the rest of the spec file.

@yordan-st yordan-st requested a review from iobuhov June 24, 2026 13:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants