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/36169-filterbuilderfield-multiple.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/app-shell': patch
'@object-ui/console': patch
---

fix(console): the view and page-block filter editor offers a multiple: true field only Contains, Does not contain and the empty checks

Clause-②: no
Metadata-protocol: none

A `select`, `lookup` or `user` field declared `multiple: true` holds a list. Studio's filter editor for a view's filter, a page's base filter and tab presets, and a related-list block's filter built its field list without `multiple`, so it offered Equals and Is any of on such a field, and the saved filter was refused by the data door with 400 `INVALID_FILTER` for every reader of that view. Every host that builds the editor's field list now carries the field's declared `multiple` (the generic metadata editor, the list-view and view-variant inspectors, the in-app view configuration panel and the page block inspector), and the shared filter builder offers such a field Contains, Does not contain, Is empty and Is not empty, the operators the other condition editors already give it.

A single-value field of the same types keeps its operators. A stored Equals rule on a list-valued field still opens as its row, so it can be changed. No metadata key, value or default changes.
7 changes: 6 additions & 1 deletion ui/packages/app-shell/src/views/ViewConfigPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,10 @@ type AuthoredSeed =
* Map an Object definition's `fields` record into the inspector's flat field
* catalog so it can render field-reference pickers (columns, groupByField, …)
* without a network fetch.
*
* @internal exported for tests
*/
function mapObjectFields(objectDef: ViewConfigPanelProps['objectDef']): ObjectFieldInfo[] {
export function mapObjectFields(objectDef: ViewConfigPanelProps['objectDef']): ObjectFieldInfo[] {
const fields = objectDef.fields;
if (!fields || typeof fields !== 'object') return [];
return Object.entries(fields).map(([name, def]) => {
Expand All @@ -150,6 +152,9 @@ function mapObjectFields(objectDef: ViewConfigPanelProps['objectDef']): ObjectFi
label: typeof f.label === 'string' && f.label ? f.label : name,
type: typeof f.type === 'string' ? f.type : 'text',
hidden: f.hidden === true,
// The filter builder offers a list-valued column membership and
// the empty checks only (`operatorsForField`).
...(f.multiple === true ? { multiple: true } : {}),
};
});
}
Expand Down
40 changes: 29 additions & 11 deletions ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,34 @@ type ObjectCatalog = {
actions: ObjectActionOption[];
};

/**
* The field and action catalogs of one served object document, as the
* pickers read them. A field's declared `multiple: true` rides along: the
* `filter-builder` widget reads it to offer a list-valued column membership
* and the empty checks only (`operatorsForField`).
*
* @internal exported for tests
*/
export function objectCatalogOf(obj: { fields?: Record<string, any> | Array<any> } | null | undefined): ObjectCatalog {
const fieldOf = (name: unknown, f: any): ObjectFieldOption => ({
name: name as string,
label: f?.label,
type: f?.type,
...(f?.multiple === true ? { multiple: true } : {}),
});
const raw = obj?.fields;
const list = Array.isArray(raw)
? raw.map((f: any) => fieldOf(f?.name, f))
: raw && typeof raw === 'object'
? Object.entries(raw).map(([name, f]: [string, any]) => fieldOf(name, f))
: [];
const rawActions = (obj as any)?.actions;
const acts = Array.isArray(rawActions)
? rawActions.map((a: any) => ({ name: a?.name, label: a?.label, locations: a?.locations })).filter((a: any) => !!a.name)
: [];
return { fields: list.filter((f) => !!f.name), actions: acts };
}

/**
* A refusal the SERVER returned for this document, held against the draft
* slices its issue paths named (`9073cf018`).
Expand Down Expand Up @@ -1302,17 +1330,7 @@ function MetadataResourceEditPageImpl({
sourceObjectName
? async () => {
const obj = (await client.get('object', sourceObjectName)) as { fields?: Record<string, any> | Array<any> } | null;
const raw = obj?.fields;
const list = Array.isArray(raw)
? raw.map((f: any) => ({ name: f?.name, label: f?.label, type: f?.type }))
: raw && typeof raw === 'object'
? Object.entries(raw).map(([name, f]: [string, any]) => ({ name, label: f?.label, type: f?.type }))
: [];
const rawActions = (obj as any)?.actions;
const acts = Array.isArray(rawActions)
? rawActions.map((a: any) => ({ name: a?.name, label: a?.label, locations: a?.locations })).filter((a: any) => !!a.name)
: [];
return { fields: list.filter((f) => !!f.name), actions: acts };
return objectCatalogOf(obj);
}
: null,
[client, sourceObjectName],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ function FilterRulesField({ label, objectName, value, onChange, disabled }: {
const { fields, error } = useObjectFields(objectName);
const id = React.useId();
const builderFields = React.useMemo(
() => fields.filter((f) => !f.hidden).map((f) => ({ name: f.name, label: f.label, type: f.type })),
() => fields
.filter((f) => !f.hidden)
// `multiple` decides the operators the builder offers a list-valued column.
.map((f) => ({ name: f.name, label: f.label, type: f.type, ...(f.multiple ? { multiple: true } : {}) })),
[fields],
);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ export function ViewVariantInspector({
fieldCatalog = { status: 'loading' };
} else {
fieldCatalog = loaded(
objectFields.map((f) => ({ name: f.name, label: f.label, type: f.type })),
// `multiple` rides along for the filter's operator set: a list-valued
// column is offered membership and the empty checks only.
objectFields.map((f) => ({ name: f.name, label: f.label, type: f.type, ...(f.multiple ? { multiple: true } : {}) })),
);
}
// objectui#8167 — `none`, and the reason is recorded here rather than
Expand Down
Loading
Loading