Add format options for number and date fields#57
Merged
Conversation
Threads parsed number_format and date_format through fieldMapping into EditableCell, where formatNumberValue and formatDateValue produce the display string via Intl. The site locale comes from wp.date.getSettings() so a single site renders the same numbers and dates for every viewer, the way dateI18n does on the public side.
The column header dropdown now has an Edit field item that opens a Notion-style cascading panel: Number format / Decimal places for numbers; Date format / Time for dates. Each row anchors its own choice flyout, selections auto-save through core-data, and the panel opens on hover with a grace timer so the cursor can travel from the trigger to the panel without losing it. Menu groups are reorganized to put property-config items at the top and column-lifecycle ones at the bottom.
Existing number fields don't have number_format meta until someone opens Edit field, but formatNumberValue was passing min/max fraction digits of 0 to Intl whenever decimals weren't configured. That silently rounded values like 1.25 to 1. Now we only set fraction digits when the user explicitly picks one, and the Decimal places menu has a Default option (the implicit state) so picking a number format no longer auto-saves decimals: 0.
`date` fields have no time component: the value is stored as YYYY-MM-DD, the inline editor strips time on commit, and the renderer returns before consulting time options for date-only values. Showing 12-hour / 24-hour controls for them saved a setting that nothing could read.
A fresh datetime field with no saved date_format showed `Time: Off` in the popover even though the cell rendered HH:MM, because formatDateValue defaults `time` to true for datetime while findTimeOption always returned Off when config.time was falsy. Pass the field type into findTimeOption so it falls back to the same default the renderer uses (12-hour for datetime, off for date).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Closes #123
Adds formatting options for number and date fields.
Number fields can render as plain numbers, percentages, or currency, with a chosen decimal count. Date fields can choose the date layout and whether to show time.
The setting lives on the field, so the whole column updates together, survives reloads, and copies when the field is duplicated. Values render with
Intlusing the WordPress site locale.Testing
npm testandcomposer test.Screenshot