Skip to content
Merged
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
13 changes: 13 additions & 0 deletions .changeset/34898-grid-draft-only-fields.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/plugin-grid': patch
'@object-ui/i18n': patch
---

fix(plugin-grid): a grouped grid under draft preview no longer asks the data door for fields only the draft declares

Clause-②: yes — one new locale key (the visible "this grouping waits for publish" note the card's Expected names), locale-only; no spec, no new exported prop
Metadata-protocol: none

Under the console's draft preview (`?preview=draft`) the object definition marks each field only the draft adds with `_draftOnly`, while the data door still checks every requested field against the published object. A grouped grid built its own requests from that definition, so a draft-only column went into every group's row request and every group showed `INVALID_FIELD`, and a grouping on a draft-only field went out as the header query's `groupBy` and the whole grid showed "Error loading grid".

The grid now leaves a draft-only field out of its row `$select` and `$expand`, on the flat fetch and on every group's row page; the column still draws, empty, under its draft label. A grouping entry on a draft-only field is dropped the way a masked grouping key is: the grid groups by the published entries left, or draws ungrouped, and one note above the rows (`grid.grouping.draftOnly`, new in every locale pack) names the field and says grouping by it waits for publish. After Publish the marker is gone, and the grouping and the column work on the next definition read without a reload. Outside the preview no field carries the marker and nothing changes.
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@ const ar = {
"هذا العرض مُجمَّع، لكن مصدر بياناته لا يطبّق queryGroupHeaders، لذا لا يمكن عدّ المجموعات. أزِل التجميع لعرض السجلات.",
needsWholeRows:
"يتطلب التجميع جميع السجلات، لكن هذه الشبكة تلقّت صفحة واحدة منها فقط، لذا لا يمكن عدّ المجموعات. مرّر جميع السجلات، أو دع الشبكة تجلبها من مصدر بيانات يطبّق queryGroupHeaders.",
draftOnly: "لم يتم التجميع حسب {{fields}}: هذا الحقل موجود في المسودة فقط حتى تقوم بالنشر.",
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ const de = {
"Diese Ansicht ist gruppiert, aber ihre Datenquelle implementiert queryGroupHeaders nicht, daher können die Gruppen nicht gezählt werden. Entfernen Sie die Gruppierung, um die Datensätze anzuzeigen.",
needsWholeRows:
"Die Gruppierung benötigt alle Datensätze, aber dieses Raster hat nur eine Seite davon erhalten, daher können die Gruppen nicht gezählt werden. Übergeben Sie alle Datensätze oder lassen Sie das Raster sie aus einer Datenquelle laden, die queryGroupHeaders implementiert.",
draftOnly: "Nicht nach {{fields}} gruppiert: Das Feld existiert nur im Entwurf, bis Sie veröffentlichen.",
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -816,6 +816,7 @@ const en = {
'This view is grouped, but its data source does not implement queryGroupHeaders, so the groups cannot be counted. Remove the grouping to show the records.',
needsWholeRows:
'Grouping needs every record, but this grid was handed one page of them, so the groups cannot be counted. Hand in every record, or let the grid fetch them from a data source that implements queryGroupHeaders.',
draftOnly: 'Not grouped by {{fields}}: it exists only in the draft until you publish.',
},
// Column-footer aggregate prefixes, keyed by the spec's `ColumnSummary`
// vocabulary (objectui#4024). The footer already formatted its NUMBER
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ const es = {
"Esta vista está agrupada, pero su origen de datos no implementa queryGroupHeaders, por lo que no se pueden contar los grupos. Quite la agrupación para mostrar los registros.",
needsWholeRows:
"La agrupación necesita todos los registros, pero esta cuadrícula recibió solo una página de ellos, por lo que no se pueden contar los grupos. Entregue todos los registros o deje que la cuadrícula los obtenga de un origen de datos que implemente queryGroupHeaders.",
draftOnly: "No agrupado por {{fields}}: solo existe en el borrador hasta que publique.",
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ const fr = {
"Cette vue est groupée, mais sa source de données n'implémente pas queryGroupHeaders : les groupes ne peuvent donc pas être comptés. Supprimez le regroupement pour afficher les enregistrements.",
needsWholeRows:
"Le regroupement a besoin de tous les enregistrements, mais cette grille n'en a reçu qu'une page : les groupes ne peuvent donc pas être comptés. Fournissez tous les enregistrements, ou laissez la grille les charger depuis une source de données qui implémente queryGroupHeaders.",
draftOnly: "Non regroupé par {{fields}} : ce champ n'existe que dans le brouillon jusqu'à la publication.",
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ const ja = {
"このビューはグループ化されていますが、データソースが queryGroupHeaders を実装していないため、グループの件数を数えられません。レコードを表示するにはグループ化を解除してください。",
needsWholeRows:
"グループ化にはすべてのレコードが必要ですが、このグリッドにはその一部のページしか渡されていないため、グループの件数を数えられません。すべてのレコードを渡すか、queryGroupHeaders を実装したデータソースからグリッドに読み込ませてください。",
draftOnly: "{{fields}} ではグループ化されていません:公開するまで下書きにのみ存在します。",
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,7 @@ const ko = {
"이 뷰는 그룹화되어 있지만 데이터 소스가 queryGroupHeaders를 구현하지 않아 그룹 개수를 셀 수 없습니다. 레코드를 표시하려면 그룹화를 제거하세요.",
needsWholeRows:
"그룹화에는 모든 레코드가 필요하지만 이 그리드에는 한 페이지만 전달되어 그룹 개수를 셀 수 없습니다. 모든 레코드를 전달하거나 queryGroupHeaders를 구현하는 데이터 소스에서 그리드가 불러오도록 하세요.",
draftOnly: "{{fields}}(으)로 그룹화되지 않았습니다: 게시할 때까지 초안에만 존재합니다.",
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ const pt = {
"Esta visão está agrupada, mas sua fonte de dados não implementa queryGroupHeaders, portanto os grupos não podem ser contados. Remova o agrupamento para mostrar os registros.",
needsWholeRows:
"O agrupamento precisa de todos os registros, mas esta grade recebeu apenas uma página deles, portanto os grupos não podem ser contados. Entregue todos os registros ou deixe a grade buscá-los em uma fonte de dados que implemente queryGroupHeaders.",
draftOnly: "Não agrupado por {{fields}}: existe apenas no rascunho até você publicar.",
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,7 @@ const ru = {
"Это представление сгруппировано, но его источник данных не реализует queryGroupHeaders, поэтому группы невозможно подсчитать. Уберите группировку, чтобы показать записи.",
needsWholeRows:
"Для группировки нужны все записи, но этой таблице передана только одна их страница, поэтому группы невозможно подсчитать. Передайте все записи или позвольте таблице загрузить их из источника данных, который реализует queryGroupHeaders.",
draftOnly: "Без группировки по {{fields}}: это поле существует только в черновике до публикации.",
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/zh-Hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ const zh = {
'此视图已分组,但其数据源未实现 queryGroupHeaders,因此无法统计分组。移除分组即可显示记录。',
needsWholeRows:
'分组需要全部记录,但此表格只收到其中一页,因此无法统计分组。请传入全部记录,或让表格从实现了 queryGroupHeaders 的数据源获取记录。',
draftOnly: '未按 {{fields}} 分组:它仅存在于草稿中,发布后才生效。',
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
1 change: 1 addition & 0 deletions ui/packages/i18n/src/locales/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,7 @@ const zhHant = {
'此檢視已分組,但其資料來源未實現 queryGroupHeaders,因此無法統計分組。移除分組即可顯示記錄。',
needsWholeRows:
'分組需要全部記錄,但此表格只收到其中一頁,因此無法統計分組。請傳入全部記錄,或讓表格從實現了 queryGroupHeaders 的資料來源獲取記錄。',
draftOnly: '未按 {{fields}} 分組:它僅存在於草稿中,釋出後才生效。',
},
// objectui#4024 — column-footer aggregate prefixes, keyed by the spec's
// `ColumnSummary` vocabulary. `pattern` owns the label/value join so this
Expand Down
28 changes: 28 additions & 0 deletions ui/packages/plugin-grid/src/ObjectGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,7 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
// grouping refusals and the fetch window (`./objectGridGroupingDecisions`).
const {
unmaskedGroupingFields,
draftOnlyGroupingFields,
groupingRefusesNothing,
groupingKeyReadable,
serverGroupedFetch,
Expand Down Expand Up @@ -1732,6 +1733,31 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
);
}

// objectstack#34898 — the grouping sentences' non-blocking sibling. A
// grouping entry on a field only the draft declares is dropped
// (`draftOnlyGroupingFields`) and the grid draws ungrouped, or grouped by the
// published entries left. Unlike the two refusals above nothing is withheld,
// so this is no panel replacing the grid: it is one line drawn above the
// rows, under the description, by every branch that draws them (the card
// view and the table), in the strip `ListView` draws its own draft-preview
// note in, so it is read before the rows it explains.
const groupingDraftOnlyNote = draftOnlyGroupingFields.length > 0 ? (
<p
role="status"
className="px-3 sm:px-4 py-1.5 text-xs text-muted-foreground border-b bg-muted/40"
data-testid="grid-grouping-draft-only"
>
{t('grid.grouping.draftOnly', {
fields: draftOnlyGroupingFields
.map((field) => {
const fallback = (objectFields?.[field] as { label?: string } | undefined)?.label || field;
return schema.objectName ? resolveFieldLabel(schema.objectName, field, fallback) : fallback;
})
.join(', '),
})}
</p>
) : null;

// The generated columns, enriched and folded, with the persisted widths and
// order applied (`./objectGridPersistedColumns`).
const { persistedColumns } = resolveObjectGridPersistedColumns({
Expand Down Expand Up @@ -3517,6 +3543,7 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
data-testid="object-grid-card-scroller"
>
{gridDescription}
{groupingDraftOnlyNote}
<div className="space-y-2 p-2">
{data.map(renderMobileCard)}
</div>
Expand Down Expand Up @@ -4126,6 +4153,7 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
</div>
)}
{gridDescription}
{groupingDraftOnlyNote}
{gridToolbar}
{renderedGridContent}
{isGrouped && onRowGroupsChange && (
Expand Down
Loading
Loading