@@ -74,6 +74,55 @@ export function useObjectGridGenerateColumns({
7474 /** objectstack#33317 — `false` ⇒ the host's row click opens nothing (`ObjectGrid`'s prop). */
7575 rowOpensRecord ?: boolean ;
7676} ) {
77+ // One object field's column draft, as the SYNTHESIZED path (no authored
78+ // `columns` / `fields`) draws it: the field's own renderer, its translated
79+ // label, and field-level security (`null` for a field the viewer may not
80+ // read, or one the object does not declare). Shared with the phone card,
81+ // which draws the object's `highlightFields` (ADR-0085) whether or not the
82+ // view shows them as columns (objectstack#37891).
83+ const synthesizeFieldColumn = useCallback ( ( fieldName : string ) : ObjectGridColumnDraft | null => {
84+ if ( ! objectSchema ) return null ;
85+ const settledFor = ( field : unknown , row : Record < string , unknown > | undefined ) : boolean =>
86+ isDeadlineSettled ( field as Parameters < typeof isDeadlineSettled > [ 0 ] , row , { scope : predicateScope , fields : objectFields } ) ;
87+ const field = objectSchema . fields ?. [ fieldName ] ;
88+ if ( ! field ) return null ;
89+
90+ // FLS: drop columns the current user cannot read (server-resolved
91+ // /me/permissions via checkField — the schema itself carries no
92+ // per-caller permission bits, objectstack#3661). Same gate ListView
93+ // applies to its auto-derived columns.
94+ if ( perms ?. isLoaded && schema . objectName
95+ && ! perms . checkField ( schema . objectName , fieldName , 'read' ) ) return null ;
96+
97+ // Annotated for the same reason as paths A-C (objectui#6004): `field` is
98+ // `any`, so these values have to be named before they reach a spread
99+ // below — the naming now lives on `GridCellRendering`'s `string | null`
100+ // members. `fieldType` is the DECLARED type the emit forwards to the
101+ // inline editor; the renderer comes from the `format`-promoted key, which
102+ // this path used to skip (objectui#8920).
103+ const { declaredType : fieldType , rendererType, Renderer : CellRenderer } = resolveGridCellRendering ( field ) ;
104+ const translatedField = field . options
105+ ? { ...field , options : translateOptions ( schema . objectName , fieldName , field . options ) }
106+ : field ;
107+ const header = schema . objectName ? resolveFieldLabel ( schema . objectName , fieldName , field . label || fieldName ) : field . label || fieldName ;
108+ // The face is handed the header's label, as paths A-C hand it
109+ // (objectui#11689).
110+ const fieldForCell : any = field . label ? { ...translatedField , label : header } : translatedField ;
111+ // A `referenceVia` pointer column (objectui#12608), as path A.
112+ const pointerFace = recordPointerFace ( fieldName , fieldType , field , dataSource ) ;
113+ return {
114+ header,
115+ accessorKey : fieldName ,
116+ // Forward the field type for the type-aware inline editor.
117+ ...( fieldType && { type : fieldType } ) ,
118+ // Aligned on the RENDERER key, like paths A-C: a `text` column with
119+ // `format: 'currency'` renders as currency, so it aligns as currency.
120+ ...( alignsAsNumber ( rendererType , field . returnType ) && { align : 'right' as const } ) ,
121+ cell : ( value : any , row : any ) => pointerFace ?.( row ) ?? < CellRenderer value = { value } field = { fieldForCell } dependentValues = { row } deadlineSettled = { settledFor ( fieldForCell , row ) } inGridColumn /> ,
122+ sortable : field . sortable !== false ,
123+ } ;
124+ } , [ objectSchema , objectFields , resolveFieldLabel , translateOptions , schema . objectName , perms , dataSource , predicateScope ] ) ;
125+
77126 const generateColumns = useCallback ( ( ) : ObjectGridColumnDraft [ ] => {
78127 // objectui#11815 — the host's verdict on a declared deadline's
79128 // `settledWhen` for ONE row, handed to the cell as `deadlineSettled`. The
@@ -965,47 +1014,12 @@ export function useObjectGridGenerateColumns({
9651014 }
9661015
9671016 fieldsToShow . forEach ( ( fieldName ) => {
968- const field = objectSchema . fields ?. [ fieldName ] ;
969- if ( ! field ) return ;
970-
971- // FLS: drop columns the current user cannot read (server-resolved
972- // /me/permissions via checkField — the schema itself carries no
973- // per-caller permission bits, objectstack#3661). Same gate ListView
974- // applies to its auto-derived columns.
975- if ( perms ?. isLoaded && schema . objectName
976- && ! perms . checkField ( schema . objectName , fieldName , 'read' ) ) return ;
977-
978- // Annotated for the same reason as paths A-C (objectui#6004): `field` is
979- // `any`, so these values have to be named before they reach a spread
980- // below — the naming now lives on `GridCellRendering`'s `string | null`
981- // members. `fieldType` is the DECLARED type the emit forwards to the
982- // inline editor; the renderer comes from the `format`-promoted key, which
983- // this path used to skip (objectui#8920).
984- const { declaredType : fieldType , rendererType, Renderer : CellRenderer } = resolveGridCellRendering ( field ) ;
985- const translatedField = field . options
986- ? { ...field , options : translateOptions ( schema . objectName , fieldName , field . options ) }
987- : field ;
988- const header = schema . objectName ? resolveFieldLabel ( schema . objectName , fieldName , field . label || fieldName ) : field . label || fieldName ;
989- // The face is handed the header's label, as paths A-C hand it
990- // (objectui#11689).
991- const fieldForCell : any = field . label ? { ...translatedField , label : header } : translatedField ;
992- // A `referenceVia` pointer column (objectui#12608), as path A.
993- const pointerFace = recordPointerFace ( fieldName , fieldType , field , dataSource ) ;
994- generatedColumns . push ( {
995- header,
996- accessorKey : fieldName ,
997- // Forward the field type for the type-aware inline editor.
998- ...( fieldType && { type : fieldType } ) ,
999- // Aligned on the RENDERER key, like paths A-C: a `text` column with
1000- // `format: 'currency'` renders as currency, so it aligns as currency.
1001- ...( alignsAsNumber ( rendererType , field . returnType ) && { align : 'right' as const } ) ,
1002- cell : ( value : any , row : any ) => pointerFace ?.( row ) ?? < CellRenderer value = { value } field = { fieldForCell } dependentValues = { row } deadlineSettled = { settledFor ( fieldForCell , row ) } inGridColumn /> ,
1003- sortable : field . sortable !== false ,
1004- } ) ;
1017+ const column = synthesizeFieldColumn ( fieldName ) ;
1018+ if ( column ) generatedColumns . push ( column ) ;
10051019 } ) ;
10061020
10071021 return generatedColumns ;
1008- } , [ objectSchema , objectFields , objectTypesPending , schemaFields , schemaColumns , dataConfig , hasInlineData , objectName , navigation . handleClick , executeAction , data , resolveFieldLabel , translateOptions , schema . objectName , perms , uiLanguage , dataSource , predicateScope , recordLinkAdornment , rowOpensRecord ] ) ;
1022+ } , [ objectSchema , objectFields , objectTypesPending , schemaFields , schemaColumns , dataConfig , hasInlineData , objectName , navigation . handleClick , executeAction , data , resolveFieldLabel , translateOptions , schema . objectName , perms , uiLanguage , dataSource , predicateScope , recordLinkAdornment , rowOpensRecord , synthesizeFieldColumn ] ) ;
10091023
1010- return { generateColumns } ;
1024+ return { generateColumns, synthesizeFieldColumn } ;
10111025}
0 commit comments