Skip to content

Support AOC column formatters in yui-polyfill#16

Open
SvenBrunk wants to merge 1 commit intoOXID-eSales:b-8.0.xfrom
SvenBrunk:yui-polyfill-column-formatter
Open

Support AOC column formatters in yui-polyfill#16
SvenBrunk wants to merge 1 commit intoOXID-eSales:b-8.0.xfrom
SvenBrunk:yui-polyfill-column-formatter

Conversation

@SvenBrunk
Copy link
Copy Markdown
Contributor

What changed

This updates the AOC/DataTable polyfill row renderer so column definitions can use a formatter(elCell, oRecord, oColumn, oData) callback, matching the YUI 2 DataTable column API shape that the admin templates already use.

When a formatter is present on the matching column definition, the polyfill now calls it with:

  • the cell liner element
  • a small record-compatible object exposing getData() and _oData
  • the column definition
  • the current cell value

When no formatter is configured, rendering falls back to the previous text/truncation behavior.

Why

The replacement AOC widget accepts the same column definition shape as the old YUI 2 DataTable integration, and several core popup templates already pass formatter: YAHOO.oxid.aoc.custFormatter in their column definitions. The polyfill also declares custFormatter(elCell, oRecord, oColumn, oData), which strongly suggests formatter support was intended.

However, the current polyfill row renderer ignores the column's formatter property and always writes the raw value into the cell. This means admin popups and modules cannot customize cell rendering through the documented column configuration and have to post-process the generated DOM after dataReturnEvent instead.

This came up while building an assignment popup for a shipping-zone module. The popup needs to render a stored include/exclude value as a localized label. Because the formatter callback is ignored today, the module has to carry a hidden label element and rewrite matching cells after every data reload. Calling the column formatter in the polyfill removes that workaround and restores the expected AOC/DataTable extension point.

Compatibility

This is intended to be backward compatible:

  • Existing columns without a formatter use the same rendering branch as before.
  • Existing formatters receive the YUI-style arguments.
  • oRecord.getData() returns the row object, which supports existing core code such as article_extend.html.twig.
  • oRecord.getData(field) also returns a single field value for formatter implementations that use keyed access.

Verification

  • Ran node --check out/admin_twig/src/js/widgets/yui-polyfill.js.
  • No JavaScript test harness appears to be present in this repository.

Manual verification path:

  1. Open an admin AOC popup with a column definition that includes a formatter.
  2. Set the formatter to write a known value, for example elCell.innerText = 'hello';.
  3. Confirm the rendered cell shows hello.
  4. Confirm a column without a formatter still renders and truncates long text as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants