Skip to content

Commit

Permalink
Merge pull request #650 from contember/fix/datagrid-persist
Browse files Browse the repository at this point in the history
datagrid fixes
  • Loading branch information
matej21 authored Dec 8, 2023
2 parents c2005dc + afb870c commit 9c97e28
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
7 changes: 5 additions & 2 deletions build/api/admin.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -800,10 +800,13 @@ export const DataGridPageRenderer: React.NamedExoticComponent<LayoutRendererProp
export type DataGridPageRendererProps = LayoutRendererProps & DataGridContainerProps;

// @public (undocumented)
export const DataGridScope: <StateProps>({ stateComponent, stateProps, ...props }: DataGridScopeProps<StateProps>) => JSX.Element;
export const DataGridScope: <StateProps>({ stateComponent, stateProps, skipBindingStateUpdateAfterPersist, refreshDataBindingOnPersist, ...props }: DataGridScopeProps<StateProps>) => JSX.Element;

// @public (undocumented)
export type DataGridScopeProps<StateProps> = PropsWithChildren<DataGridProps<DataGridContainerPublicProps>> & DataBindingProviderStateComponent<StateProps>;
export type DataGridScopeProps<StateProps> = PropsWithChildren<DataGridProps<DataGridContainerPublicProps>> & DataBindingProviderStateComponent<StateProps> & {
refreshDataBindingOnPersist?: boolean;
skipBindingStateUpdateAfterPersist?: boolean;
};

// @public (undocumented)
export const DefaultElement: FunctionComponent<DefaultElementProps>;
Expand Down
13 changes: 11 additions & 2 deletions packages/admin/src/components/pageRouting/Scopes/DataGridScope.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,22 @@ import { scopeComponent } from './scopeComponent'
export type DataGridScopeProps<StateProps> =
& PropsWithChildren<DataGridProps<DataGridContainerPublicProps>>
& DataBindingProviderStateComponent<StateProps>
& {
refreshDataBindingOnPersist?: boolean
skipBindingStateUpdateAfterPersist?: boolean
}

/**
* @group Scopes
*/
export const DataGridScope = scopeComponent(
<StateProps, /*JSX FIX*/>({ stateComponent, stateProps, ...props }: DataGridScopeProps<StateProps>) => (
<DataBindingProvider stateComponent={stateComponent ?? FeedbackRenderer} stateProps={stateProps}>
<StateProps, >({ stateComponent, stateProps, skipBindingStateUpdateAfterPersist, refreshDataBindingOnPersist, ...props }: DataGridScopeProps<StateProps>) => (
<DataBindingProvider
stateComponent={stateComponent ?? FeedbackRenderer}
stateProps={stateProps}
skipStateUpdateAfterPersist={skipBindingStateUpdateAfterPersist}
refreshOnPersist={refreshDataBindingOnPersist ?? true}
>
<DataGrid {...props} />
</DataBindingProvider>
),
Expand Down
6 changes: 4 additions & 2 deletions packages/react-datagrid/src/grid/createDataGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ const dummyStateMethods: DataGridStateMethods = {

const createInitialState = (props: DataGridProps<{}>, environment: Environment): DataGridState<any> => {
const columns = extractDataGridColumns(props.children, environment)
const entities = QueryLanguage.desugarQualifiedEntityList({ entities: props.entities }, environment)
const filter = { and: [entities.filter ?? {}] }
return {
columns,
paging: {
Expand All @@ -46,8 +48,8 @@ const createInitialState = (props: DataGridProps<{}>, environment: Environment):
filterArtifacts: {},
orderDirections: {},
orderBy: [],
entities: QueryLanguage.desugarQualifiedEntityList({ entities: props.entities }, environment),
filter: { and: [{}] },
entities: entities,
filter,
layout: 'default',
}
}

0 comments on commit 9c97e28

Please sign in to comment.