-
Notifications
You must be signed in to change notification settings - Fork 2
feat: Airtable Interfaces-style userFilters (dropdown/tabs/toggle) for ListView #638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import type { SortItem } from '@object-ui/components'; | |
| import { Search, SlidersHorizontal, ArrowUpDown, X, EyeOff, Group, Paintbrush, Ruler, Inbox, Download, AlignJustify, Share2, icons, type LucideIcon } from 'lucide-react'; | ||
| import type { FilterGroup } from '@object-ui/components'; | ||
| import { ViewSwitcher, ViewType } from './ViewSwitcher'; | ||
| import { UserFilters } from './UserFilters'; | ||
| import { SchemaRenderer, useNavigationOverlay } from '@object-ui/react'; | ||
| import { useDensityMode } from '@object-ui/react'; | ||
| import type { ListViewSchema } from '@object-ui/types'; | ||
|
|
@@ -233,6 +234,9 @@ export const ListView: React.FC<ListViewProps> = ({ | |
| return defaults; | ||
| }); | ||
|
|
||
| // User Filters State (Airtable Interfaces-style) | ||
| const [userFilterConditions, setUserFilterConditions] = React.useState<any[]>([]); | ||
|
|
||
| // Hidden Fields State (initialized from schema) | ||
| const [hiddenFields, setHiddenFields] = React.useState<Set<string>>( | ||
| () => new Set(schema.hiddenFields || []) | ||
|
|
@@ -314,11 +318,12 @@ export const ListView: React.FC<ListViewProps> = ({ | |
| }); | ||
| } | ||
|
|
||
| // Merge base filters, user filters, and quick filters | ||
| // Merge base filters, user filters, quick filters, and user filter bar conditions | ||
| const allFilters = [ | ||
| ...(baseFilter.length > 0 ? [baseFilter] : []), | ||
| ...(userFilter.length > 0 ? [userFilter] : []), | ||
| ...quickFilterConditions, | ||
| ...userFilterConditions, | ||
| ]; | ||
|
|
||
| if (allFilters.length > 1) { | ||
|
|
@@ -365,7 +370,7 @@ export const ListView: React.FC<ListViewProps> = ({ | |
| fetchData(); | ||
|
|
||
| return () => { isMounted = false; }; | ||
| }, [schema.objectName, dataSource, schema.filters, currentSort, currentFilters, activeQuickFilters, refreshKey]); // Re-fetch on filter/sort change | ||
| }, [schema.objectName, dataSource, schema.filters, currentSort, currentFilters, activeQuickFilters, userFilterConditions, refreshKey]); // Re-fetch on filter/sort change | ||
|
|
||
| // Available view types based on schema configuration | ||
| const availableViews = React.useMemo(() => { | ||
|
|
@@ -964,6 +969,18 @@ export const ListView: React.FC<ListViewProps> = ({ | |
| </div> | ||
| )} | ||
|
|
||
| {/* User Filters Row (Airtable Interfaces-style) */} | ||
| {schema.userFilters && ( | ||
| <div className="border-b px-2 sm:px-4 py-1 bg-background" data-testid="user-filters"> | ||
| <UserFilters | ||
| config={schema.userFilters} | ||
| objectDef={objectDef} | ||
| data={data} | ||
| onFilterChange={setUserFilterConditions} | ||
| /> | ||
| </div> | ||
| )} | ||
|
Comment on lines
+972
to
+982
|
||
|
|
||
| {/* View Content */} | ||
| <div key={currentView} className="flex-1 min-h-0 bg-background relative overflow-hidden animate-in fade-in-0 duration-200"> | ||
| {!loading && data.length === 0 ? ( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment on line 321 could be more descriptive about what each filter source represents:
baseFilter(schema.filters): Static filters defined in the schemauserFilter(currentFilters): Filters from the FilterBuilder UI (advanced filter panel)quickFilterConditions: Filters from toggle-style quick filter buttonsuserFilterConditions: NEW - Filters from Airtable-style user filter bar (dropdown/tabs/toggle)Consider updating the comment to clarify these distinctions, especially since userFilters is a new addition. For example:
This helps future developers understand the complete filter pipeline.