Skip to content

Commit

Permalink
adds default filter to view referenced row
Browse files Browse the repository at this point in the history
  • Loading branch information
alaister authored and joshenlim committed Mar 15, 2023
1 parent ed91bf5 commit e4442c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@ const ForeignRowSelector = ({
encryptedColumns
)

const [params, setParams] = useState<any>({ filter: [], sort: [] })
const [params, setParams] = useState<any>(() => {
const targetColName = referenceRow?.foreignKey?.target_column_name
const value = referenceRow?.value

const initialFilters = targetColName && value ? [`${targetColName}:eq:${value}`] : []

return { filter: initialFilters, sort: [] }
})

const sorts = formatSortURLParams(params.sort ?? [])
const filters = formatFilterURLParams(params.filter ?? [])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ const RowEditor = ({
/>

<ForeignRowSelector
key={`foreign-row-selector-${referenceRow?.name}`}
visible={isSelectingForeignKey}
referenceRow={referenceRow}
onSelect={onSelectForeignRowValue}
Expand Down

0 comments on commit e4442c2

Please sign in to comment.